summaryrefslogtreecommitdiffstats
path: root/sys/i386/include
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2003-01-19 06:01:33 +0000
committermarcel <marcel@FreeBSD.org>2003-01-19 06:01:33 +0000
commitb2cf4b9bc050c2dc60962f9eccf13ce480fa8aee (patch)
tree8166c756e10c0bb505e7352042246b630b69280d /sys/i386/include
parente03de9709309a4f23e08f65f30d18b14df152919 (diff)
downloadFreeBSD-src-b2cf4b9bc050c2dc60962f9eccf13ce480fa8aee.zip
FreeBSD-src-b2cf4b9bc050c2dc60962f9eccf13ce480fa8aee.tar.gz
o Move the contents of <machine/floatingpoint.h> over to
<machine/ieeefp.h> where it belongs. o Remove the i386 specific inclusion of <machine/floatingpoint.h> from <ieeefp.h>, now that including <machine/ieeefp.h> is enough for all architectures. o Allow <machine/ieeefp.h> to inline the functions exposed by the headers by checking for _IEEEFP_INLINED_ in the MI header. When defined, prototypes are not given and it is assumed that the MD headers, when inlining only a subset of the functions provide prototypes for the functions not being inlined. Based on patch from: Terry Lambert <tlambert2@mindspring.com> Tested with: make release.
Diffstat (limited to 'sys/i386/include')
-rw-r--r--sys/i386/include/floatingpoint.h88
-rw-r--r--sys/i386/include/ieeefp.h80
2 files changed, 80 insertions, 88 deletions
diff --git a/sys/i386/include/floatingpoint.h b/sys/i386/include/floatingpoint.h
index 56c781a..fd328a9 100644
--- a/sys/i386/include/floatingpoint.h
+++ b/sys/i386/include/floatingpoint.h
@@ -37,94 +37,6 @@
#ifndef _FLOATINGPOINT_H_
#define _FLOATINGPOINT_H_
-/*
- * IEEE floating point structure and function definitions
- */
-
-/*-
- * XXX the following undocumented pollution is exported:
- * fpsetsticky().
- * FP*FLD, FP*OFF and FP*REG from <machine/ieeefp.h>
- */
-
-#include <sys/cdefs.h>
#include <machine/ieeefp.h>
-#ifdef __GNUC__
-
-#define __fldenv(addr) __asm __volatile("fldenv %0" : : "m" (*(addr)))
-#define __fnstenv(addr) __asm __volatile("fnstenv %0" : "=m" (*(addr)))
-#define __fnstcw(addr) __asm __volatile("fnstcw %0" : "=m" (*(addr)))
-#define __fnstsw(addr) __asm __volatile("fnstsw %0" : "=m" (*(addr)))
-
-/*
- * return the contents of a FP register
- */
-static __inline__ int
-__fpgetreg(int _reg)
-{
- unsigned short _mem;
-
- /*-
- * This is more efficient than it looks. The switch gets optimized
- * away if _reg is constant.
- *
- * The default case only supports _reg == 0. We could handle more
- * registers (e.g., tags) using fnstenv, but the interface doesn't
- * support more.
- */
- switch(_reg) {
- default:
- __fnstcw(&_mem);
- break;
- case FP_STKY_REG:
- __fnstsw(&_mem);
- break;
- }
- return _mem;
-}
-
-/*
- * set a FP mode; return previous mode
- */
-static __inline__ int
-__fpsetreg(int _m, int _reg, int _fld, int _off)
-{
- unsigned _env[7];
- unsigned _p;
-
- /*
- * _reg == 0 could be handled better using fnstcw/fldcw.
- */
- __fnstenv(_env);
- _p = (_env[_reg] & _fld) >> _off;
- _env[_reg] = (_env[_reg] & ~_fld) | (_m << _off & _fld);
- __fldenv(_env);
- return _p;
-}
-
-#endif /* __GNUC__ */
-
-/*
- * SysV/386 FP control interface
- */
-#define fpgetround() ((fp_rnd_t) \
- ((__fpgetreg(FP_RND_REG) & FP_RND_FLD) >> FP_RND_OFF))
-#define fpsetround(m) ((fp_rnd_t) \
- __fpsetreg((m), FP_RND_REG, FP_RND_FLD, FP_RND_OFF))
-#define fpgetprec() ((fp_prec_t) \
- ((__fpgetreg(FP_PRC_REG) & FP_PRC_FLD) >> FP_PRC_OFF))
-#define fpsetprec(m) ((fp_prec_t) \
- __fpsetreg((m), FP_PRC_REG, FP_PRC_FLD, FP_PRC_OFF))
-#define fpgetmask() ((fp_except_t) \
- ((~__fpgetreg(FP_MSKS_REG) & FP_MSKS_FLD) >> FP_MSKS_OFF))
-#define fpsetmask(m) ((fp_except_t) \
- (~__fpsetreg(~(m), FP_MSKS_REG, FP_MSKS_FLD, FP_MSKS_OFF)) & \
- (FP_MSKS_FLD >> FP_MSKS_OFF))
-#define fpgetsticky() ((fp_except_t) \
- ((__fpgetreg(FP_STKY_REG) & FP_STKY_FLD) >> FP_STKY_OFF))
-#define fpresetsticky(m) ((fp_except_t) \
- __fpsetreg(0, FP_STKY_REG, (m), FP_STKY_OFF))
-#define fpsetsticky(m) fpresetsticky(m)
-
#endif /* !_FLOATINGPOINT_H_ */
diff --git a/sys/i386/include/ieeefp.h b/sys/i386/include/ieeefp.h
index 3c9c49d..ac67be1 100644
--- a/sys/i386/include/ieeefp.h
+++ b/sys/i386/include/ieeefp.h
@@ -98,4 +98,84 @@ typedef enum {
#define FP_RND_OFF 10 /* round control offset */
#define FP_STKY_OFF 0 /* sticky flags offset */
+#ifdef __GNUC__
+
+#define __fldenv(addr) __asm __volatile("fldenv %0" : : "m" (*(addr)))
+#define __fnstenv(addr) __asm __volatile("fnstenv %0" : "=m" (*(addr)))
+#define __fnstcw(addr) __asm __volatile("fnstcw %0" : "=m" (*(addr)))
+#define __fnstsw(addr) __asm __volatile("fnstsw %0" : "=m" (*(addr)))
+
+/*
+ * return the contents of a FP register
+ */
+static __inline__ int
+__fpgetreg(int _reg)
+{
+ unsigned short _mem;
+
+ /*-
+ * This is more efficient than it looks. The switch gets optimized
+ * away if _reg is constant.
+ *
+ * The default case only supports _reg == 0. We could handle more
+ * registers (e.g., tags) using fnstenv, but the interface doesn't
+ * support more.
+ */
+ switch(_reg) {
+ default:
+ __fnstcw(&_mem);
+ break;
+ case FP_STKY_REG:
+ __fnstsw(&_mem);
+ break;
+ }
+ return _mem;
+}
+
+/*
+ * set a FP mode; return previous mode
+ */
+static __inline__ int
+__fpsetreg(int _m, int _reg, int _fld, int _off)
+{
+ unsigned _env[7];
+ unsigned _p;
+
+ /*
+ * _reg == 0 could be handled better using fnstcw/fldcw.
+ */
+ __fnstenv(_env);
+ _p = (_env[_reg] & _fld) >> _off;
+ _env[_reg] = (_env[_reg] & ~_fld) | (_m << _off & _fld);
+ __fldenv(_env);
+ return _p;
+}
+
+#endif /* __GNUC__ */
+
+/*
+ * SysV/386 FP control interface
+ */
+#define fpgetround() ((fp_rnd_t) \
+ ((__fpgetreg(FP_RND_REG) & FP_RND_FLD) >> FP_RND_OFF))
+#define fpsetround(m) ((fp_rnd_t) \
+ __fpsetreg((m), FP_RND_REG, FP_RND_FLD, FP_RND_OFF))
+#define fpgetprec() ((fp_prec_t) \
+ ((__fpgetreg(FP_PRC_REG) & FP_PRC_FLD) >> FP_PRC_OFF))
+#define fpsetprec(m) ((fp_prec_t) \
+ __fpsetreg((m), FP_PRC_REG, FP_PRC_FLD, FP_PRC_OFF))
+#define fpgetmask() ((fp_except_t) \
+ ((~__fpgetreg(FP_MSKS_REG) & FP_MSKS_FLD) >> FP_MSKS_OFF))
+#define fpsetmask(m) ((fp_except_t) \
+ (~__fpsetreg(~(m), FP_MSKS_REG, FP_MSKS_FLD, FP_MSKS_OFF)) & \
+ (FP_MSKS_FLD >> FP_MSKS_OFF))
+#define fpgetsticky() ((fp_except_t) \
+ ((__fpgetreg(FP_STKY_REG) & FP_STKY_FLD) >> FP_STKY_OFF))
+#define fpresetsticky(m) ((fp_except_t) \
+ __fpsetreg(0, FP_STKY_REG, (m), FP_STKY_OFF))
+#define fpsetsticky(m) fpresetsticky(m)
+
+/* Suppress prototypes in the MI header. */
+#define _IEEEFP_INLINED_ 1
+
#endif /* !_MACHINE_IEEEFP_H_ */
OpenPOWER on IntegriCloud