Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/m68k/fpe Introduce FPU_CONST_* constants to avoid a...
details: https://anonhg.NetBSD.org/src/rev/74a46a78c55a
branches: trunk
changeset: 786008:74a46a78c55a
user: isaki <isaki%NetBSD.org@localhost>
date: Thu Apr 11 13:27:11 2013 +0000
description:
Introduce FPU_CONST_* constants to avoid a magic number.
diffstat:
sys/arch/m68k/fpe/fpu_emulate.h | 7 ++++++-
sys/arch/m68k/fpe/fpu_hyperb.c | 8 ++++----
sys/arch/m68k/fpe/fpu_log.c | 16 ++++++++--------
sys/arch/m68k/fpe/fpu_trig.c | 10 +++++-----
4 files changed, 23 insertions(+), 18 deletions(-)
diffs (172 lines):
diff -r 7d95185dc6dd -r 74a46a78c55a sys/arch/m68k/fpe/fpu_emulate.h
--- a/sys/arch/m68k/fpe/fpu_emulate.h Thu Apr 11 11:24:07 2013 +0000
+++ b/sys/arch/m68k/fpe/fpu_emulate.h Thu Apr 11 13:27:11 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fpu_emulate.h,v 1.22 2013/03/26 11:30:20 isaki Exp $ */
+/* $NetBSD: fpu_emulate.h,v 1.23 2013/04/11 13:27:11 isaki Exp $ */
/*
* Copyright (c) 1995 Gordon Ross
@@ -253,6 +253,11 @@
*/
/* return values from constant rom */
struct fpn *fpu_const(struct fpn *, uint32_t);
+#define FPU_CONST_PI (0x00) /* pi */
+#define FPU_CONST_LN_2 (0x30) /* ln(2) */
+#define FPU_CONST_LN_10 (0x31) /* ln(10) */
+#define FPU_CONST_1 (0x32) /* 1.0 */
+
/* update exceptions and FPSR */
int fpu_upd_excp(struct fpemu *);
uint32_t fpu_upd_fpsr(struct fpemu *, struct fpn *);
diff -r 7d95185dc6dd -r 74a46a78c55a sys/arch/m68k/fpe/fpu_hyperb.c
--- a/sys/arch/m68k/fpe/fpu_hyperb.c Thu Apr 11 11:24:07 2013 +0000
+++ b/sys/arch/m68k/fpe/fpu_hyperb.c Thu Apr 11 13:27:11 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fpu_hyperb.c,v 1.7 2013/03/23 12:06:24 isaki Exp $ */
+/* $NetBSD: fpu_hyperb.c,v 1.8 2013/04/11 13:27:11 isaki Exp $ */
/*
* Copyright (c) 1995 Ken Nakata
@@ -57,7 +57,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fpu_hyperb.c,v 1.7 2013/03/23 12:06:24 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu_hyperb.c,v 1.8 2013/04/11 13:27:11 isaki Exp $");
#include "fpu_emulate.h"
@@ -89,7 +89,7 @@
return &fe->fe_f2;
}
- fpu_const(&s0, 0x32); /* 1.0 */
+ fpu_const(&s0, FPU_CONST_1);
r = fpu_sincos_taylor(fe, &s0, 1, hyperb);
CPYFPN(&fe->fe_f2, r);
@@ -128,7 +128,7 @@
if (ISINF(&fe->fe_f2)) {
sign = fe->fe_f2.fp_sign;
- fpu_const(&fe->fe_f2, 0x32);
+ fpu_const(&fe->fe_f2, FPU_CONST_1);
fe->fe_f2.fp_sign = sign;
return &fe->fe_f2;
}
diff -r 7d95185dc6dd -r 74a46a78c55a sys/arch/m68k/fpe/fpu_log.c
--- a/sys/arch/m68k/fpe/fpu_log.c Thu Apr 11 11:24:07 2013 +0000
+++ b/sys/arch/m68k/fpe/fpu_log.c Thu Apr 11 13:27:11 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fpu_log.c,v 1.15 2013/03/26 11:30:21 isaki Exp $ */
+/* $NetBSD: fpu_log.c,v 1.16 2013/04/11 13:27:11 isaki Exp $ */
/*
* Copyright (c) 1995 Ken Nakata
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fpu_log.c,v 1.15 2013/03/26 11:30:21 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu_log.c,v 1.16 2013/04/11 13:27:11 isaki Exp $");
#include <sys/types.h>
#include <sys/systm.h>
@@ -210,13 +210,13 @@
printf("__fpu_logn: log near 1\n");
#endif
- fpu_const(&fe->fe_f1, 0x32);
+ fpu_const(&fe->fe_f1, FPU_CONST_1);
/* X+1 */
d = fpu_add(fe);
CPYFPN(&V, d);
CPYFPN(&fe->fe_f1, &X);
- fpu_const(&fe->fe_f2, 0x32); /* 1.0 */
+ fpu_const(&fe->fe_f2, FPU_CONST_1);
fe->fe_f2.fp_sign = 1; /* -1.0 */
/* X-1 */
d = fpu_add(fe);
@@ -352,7 +352,7 @@
/* KLOG2 = K * ln(2) */
/* fe_f1 == (fpn)k */
fpu_explode(fe, &fe->fe_f1, FTYPE_LNG, &k);
- (void)fpu_const(&fe->fe_f2, 0x30 /* ln(2) */);
+ (void)fpu_const(&fe->fe_f2, FPU_CONST_LN_2);
#if FPE_DEBUG
printf("__fpu_logn: fp(k)=(%d,%08x,%08x...)\n",
fe->fe_f1.fp_exp,
@@ -491,7 +491,7 @@
fp = __fpu_logn(fe);
if (fp != &fe->fe_f1)
CPYFPN(&fe->fe_f1, fp);
- (void)fpu_const(&fe->fe_f2, 0x31 /* ln(10) */);
+ (void)fpu_const(&fe->fe_f2, FPU_CONST_LN_10);
fp = fpu_div(fe);
} /* else if fp == +Inf, return +Inf */
} else if (fp->fp_class == FPC_ZERO) {
@@ -535,7 +535,7 @@
fp = __fpu_logn(fe);
if (fp != &fe->fe_f1)
CPYFPN(&fe->fe_f1, fp);
- (void)fpu_const(&fe->fe_f2, 0x30 /* ln(2) */);
+ (void)fpu_const(&fe->fe_f2, FPU_CONST_LN_2);
fp = fpu_div(fe);
}
} /* else if fp == +Inf, return +Inf */
@@ -594,7 +594,7 @@
struct fpn *fp;
/* build a 1.0 */
- fp = fpu_const(&fe->fe_f1, 0x32); /* get 1.0 */
+ fp = fpu_const(&fe->fe_f1, FPU_CONST_1);
/* fp = 1.0 + f2 */
fp = fpu_add(fe);
diff -r 7d95185dc6dd -r 74a46a78c55a sys/arch/m68k/fpe/fpu_trig.c
--- a/sys/arch/m68k/fpe/fpu_trig.c Thu Apr 11 11:24:07 2013 +0000
+++ b/sys/arch/m68k/fpe/fpu_trig.c Thu Apr 11 13:27:11 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fpu_trig.c,v 1.8 2013/03/26 11:30:21 isaki Exp $ */
+/* $NetBSD: fpu_trig.c,v 1.9 2013/04/11 13:27:11 isaki Exp $ */
/*
* Copyright (c) 1995 Ken Nakata
@@ -57,7 +57,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fpu_trig.c,v 1.8 2013/03/26 11:30:21 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu_trig.c,v 1.9 2013/04/11 13:27:11 isaki Exp $");
#include "fpu_emulate.h"
@@ -175,7 +175,7 @@
struct fpn s0;
/* s0 := 1 */
- fpu_const(&s0, 0x32);
+ fpu_const(&s0, FPU_CONST_1);
return fpu_sincos_taylor(fe, &s0, 1, 0);
}
@@ -251,7 +251,7 @@
sign = 0;
/* p <- 2*pi */
- fpu_const(&p, 0);
+ fpu_const(&p, FPU_CONST_PI);
p.fp_exp++;
/*
@@ -363,7 +363,7 @@
x.fp_sign = 0;
/* p <- 2*pi */
- fpu_const(&p, 0);
+ fpu_const(&p, FPU_CONST_PI);
p.fp_exp++;
/*
Home |
Main Index |
Thread Index |
Old Index