PERFORCE change 34809 for review
Peter Wemm
peter at FreeBSD.org
Mon Jul 21 20:04:41 PDT 2003
http://perforce.freebsd.org/chv.cgi?CH=34809
Change 34809 by peter at peter_hammer on 2003/07/21 20:03:40
flip-flop again. Dont give into the C++ evilness. Instead,
instantiate the fp*() functions in libc and have C++ call it
there. This also makes it more easily available to non-gcc apps.
Affected files ...
.. //depot/projects/hammer/lib/libc/amd64/gen/Makefile.inc#11 edit
.. //depot/projects/hammer/lib/libc/amd64/gen/fpgetmask.c#1 add
.. //depot/projects/hammer/lib/libc/amd64/gen/fpgetprec.c#1 add
.. //depot/projects/hammer/lib/libc/amd64/gen/fpgetround.c#1 add
.. //depot/projects/hammer/lib/libc/amd64/gen/fpgetsticky.c#1 add
.. //depot/projects/hammer/lib/libc/amd64/gen/fpsetmask.c#1 add
.. //depot/projects/hammer/lib/libc/amd64/gen/fpsetprec.c#1 add
.. //depot/projects/hammer/lib/libc/amd64/gen/fpsetround.c#1 add
.. //depot/projects/hammer/lib/libc/amd64/gen/fpsetsticky.c#1 add
.. //depot/projects/hammer/sys/amd64/include/ieeefp.h#6 edit
Differences ...
==== //depot/projects/hammer/lib/libc/amd64/gen/Makefile.inc#11 (text+ko) ====
@@ -4,4 +4,7 @@
SRCS+= _setjmp.S setjmp.S sigsetjmp.S \
fabs.S modf.S \
frexp.c infinity.c isinf.c ldexp.c \
- makecontext.c signalcontext.c
+ makecontext.c signalcontext.c \
+ fpgetmask.c fpsetmask.c fpgetprec.c fpsetprec.c \
+ fpgetround.c fpsetround.c fpgetsticky.c fpsetsticky.c
+
==== //depot/projects/hammer/sys/amd64/include/ieeefp.h#6 (text+ko) ====
@@ -111,7 +111,7 @@
#define SSE_RND_OFF 13 /* rounding control offset */
#define SSE_FZ_OFF 15 /* flush to zero offset */
-#ifdef __GNUC__
+#if defined(__GNUC__) && !defined(__cplusplus)
#define __fldenv(addr) __asm __volatile("fldenv %0" : : "m" (*(addr)))
#define __fnstenv(addr) __asm __volatile("fnstenv %0" : "=m" (*(addr)))
@@ -134,53 +134,23 @@
/* Set rounding control */
static __inline__ fp_rnd_t
-fpgetround(void)
+__fpgetround(void)
{
unsigned short _cw;
__fnstcw(&_cw);
-#ifndef __cplusplus
return ((_cw & FP_RND_FLD) >> FP_RND_OFF);
-#else
- switch ((_cw & FP_RND_FLD) >> FP_RND_OFF) {
- case FP_RN:
- return FP_RN;
- case FP_RM:
- return FP_RM;
- case FP_RP:
- return FP_RP;
- case FP_RZ:
- return FP_RZ;
- }
-#endif
}
static __inline__ fp_rnd_t
-fpsetround(fp_rnd_t _m)
+__fpsetround(fp_rnd_t _m)
{
unsigned short _cw;
unsigned int _mxcsr;
fp_rnd_t _p;
__fnstcw(&_cw);
-#ifndef __cplusplus
_p = (_cw & FP_RND_FLD) >> FP_RND_OFF;
-#else
- switch ((_cw & FP_RND_FLD) >> FP_RND_OFF) {
- case FP_RN:
- _p = FP_RN;
- break;
- case FP_RM:
- _p = FP_RM;
- break;
- case FP_RP:
- _p = FP_RP;
- break;
- case FP_RZ:
- _p = FP_RZ;
- break;
- }
-#endif
_cw &= ~FP_RND_FLD;
_cw |= (_m << FP_RND_OFF) & FP_RND_FLD;
__fldcw(&_cw);
@@ -197,52 +167,22 @@
* in 64 bit precision mode for SSE2 calculations.
*/
static __inline__ fp_prec_t
-fpgetprec(void)
+__fpgetprec(void)
{
unsigned short _cw;
__fnstcw(&_cw);
-#ifndef __cplusplus
return ((_cw & FP_PRC_FLD) >> FP_PRC_OFF);
-#else
- switch ((_cw & FP_PRC_FLD) >> FP_PRC_OFF) {
- case FP_PS:
- return FP_PS;
- case FP_PRS:
- return FP_PRS;
- case FP_PD:
- return FP_PD;
- case FP_PE:
- return FP_PE;
- }
-#endif
}
static __inline__ fp_prec_t
-fpsetprec(fp_rnd_t _m)
+__fpsetprec(fp_rnd_t _m)
{
unsigned short _cw;
fp_prec_t _p;
__fnstcw(&_cw);
-#ifndef __cplusplus
_p = (_cw & FP_PRC_FLD) >> FP_PRC_OFF;
-#else
- switch ((_cw & FP_PRC_FLD) >> FP_PRC_OFF) {
- case FP_PS:
- _p = FP_PS;
- break;
- case FP_PRS:
- _p = FP_PRS;
- break;
- case FP_PD:
- _p = FP_PD;
- break;
- case FP_PE:
- _p = FP_PE;
- break;
- }
-#endif
_cw &= ~FP_PRC_FLD;
_cw |= (_m << FP_PRC_OFF) & FP_PRC_FLD;
__fldcw(&_cw);
@@ -256,7 +196,7 @@
* for the fp*() api, mask = 1 means enabled.
*/
static __inline__ fp_except_t
-fpgetmask(void)
+__fpgetmask(void)
{
unsigned short _cw;
@@ -265,7 +205,7 @@
}
static __inline__ fp_except_t
-fpsetmask(fp_except_t _m)
+__fpsetmask(fp_except_t _m)
{
unsigned short _cw;
unsigned int _mxcsr;
@@ -286,7 +226,7 @@
/* See which sticky exceptions are pending, and reset them */
static __inline__ fp_except_t
-fpgetsticky(void)
+__fpgetsticky(void)
{
unsigned short _sw;
unsigned int _mxcsr;
@@ -299,8 +239,9 @@
return (_ex);
}
+/* Note that this should really be called fpresetsticky() */
static __inline__ fp_except_t
-fpresetsticky(fp_except_t _m)
+__fpsetsticky(fp_except_t _m)
{
unsigned _env[7];
unsigned int _mxcsr;
@@ -317,13 +258,23 @@
return (_p);
}
-/* It is called fpsetsticky(), but is really a reset function */
-#define fpsetsticky(m) fpresetsticky(m)
+#endif /* __GNUC__ && !__cplusplus */
+
+#if !defined(__IEEEFP_NOINLINES__) && !defined(__cplusplus)
+
+#define fpsetround() __fpsetround()
+#define fpgetround(_m) __fpgetround(_m)
+#define fpgetprec() __fpgetprec()
+#define fpsetprec(_m) __fpsetprec(_m)
+#define fpgetmask() __fpgetmask()
+#define fpsetmask(_m) __fpsetmask(_m)
+#define fpgetsticky() __fpgetsticky()
+#define fpsetsticky(_m) __fpsetsticky(_m)
/* Suppress prototypes in the MI header. */
#define _IEEEFP_INLINED_ 1
-#else /* __GNUC__ */
+#else /* !__IEEEFP_NOINLINES__ && !__cplusplus */
/* Augment the userland declarations */
__BEGIN_DECLS
@@ -331,6 +282,6 @@
extern fp_prec_t fpsetprec(fp_prec_t);
__END_DECLS
-#endif /* __GNUC__ */
+#endif /* !__IEEEFP_NOINLINES__ && !__cplusplus */
#endif /* !_MACHINE_IEEEFP_H_ */
More information about the p4-projects
mailing list