summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux
diff options
context:
space:
mode:
Diffstat (limited to 'libc/sysdeps/linux')
-rw-r--r--libc/sysdeps/linux/alpha/fpu_control.h2
-rw-r--r--libc/sysdeps/linux/arm/fpu_control.h6
-rw-r--r--libc/sysdeps/linux/i386/fpu_control.h14
-rw-r--r--libc/sysdeps/linux/m68k/fpu_control.h100
-rw-r--r--libc/sysdeps/linux/mips/fpu_control.h2
-rw-r--r--libc/sysdeps/linux/nios/fpu_control.h2
-rw-r--r--libc/sysdeps/linux/nios2/fpu_control.h2
-rw-r--r--libc/sysdeps/linux/powerpc/fpu_control.h2
-rw-r--r--libc/sysdeps/linux/sh/fpu_control.h4
-rw-r--r--libc/sysdeps/linux/sparc/fpu_control.h2
-rw-r--r--libc/sysdeps/linux/x86_64/fpu_control.h2
11 files changed, 99 insertions, 39 deletions
diff --git a/libc/sysdeps/linux/alpha/fpu_control.h b/libc/sysdeps/linux/alpha/fpu_control.h
index 28acdf170..cdffcfb9d 100644
--- a/libc/sysdeps/linux/alpha/fpu_control.h
+++ b/libc/sysdeps/linux/alpha/fpu_control.h
@@ -100,7 +100,9 @@
/* Type of the control word. */
typedef unsigned int fpu_control_t;
+#if 0
/* Default control word set at startup. */
extern fpu_control_t __fpu_control;
+#endif
#endif /* _ALPHA_FPU_CONTROL */
diff --git a/libc/sysdeps/linux/arm/fpu_control.h b/libc/sysdeps/linux/arm/fpu_control.h
index 31d81ea29..1170c9e97 100644
--- a/libc/sysdeps/linux/arm/fpu_control.h
+++ b/libc/sysdeps/linux/arm/fpu_control.h
@@ -89,7 +89,7 @@ typedef unsigned int fpu_control_t;
#define _FPU_GETCW(cw) ({ \
register int __t1, __t2; \
\
- __asm__ volatile ( \
+ __asm__ __volatile__ ( \
"cfmvr64l %1, mvdx0\n\t" \
"cfmvr64h %2, mvdx0\n\t" \
"cfmv32sc mvdx0, dspsc\n\t" \
@@ -103,7 +103,7 @@ typedef unsigned int fpu_control_t;
#define _FPU_SETCW(cw) ({ \
register int __t0, __t1, __t2; \
\
- __asm__ volatile ( \
+ __asm__ __volatile__ ( \
"cfmvr64l %1, mvdx0\n\t" \
"cfmvr64h %2, mvdx0\n\t" \
"cfmv64lr mvdx0, %0\n\t" \
@@ -195,7 +195,9 @@ typedef unsigned int fpu_control_t;
#endif /* __MAVERICK__ */
+#if 0
/* Default control word set at startup. */
extern fpu_control_t __fpu_control;
+#endif
#endif /* _FPU_CONTROL_H */
diff --git a/libc/sysdeps/linux/i386/fpu_control.h b/libc/sysdeps/linux/i386/fpu_control.h
index ed9bf388a..c6cb005d7 100644
--- a/libc/sysdeps/linux/i386/fpu_control.h
+++ b/libc/sysdeps/linux/i386/fpu_control.h
@@ -1,5 +1,5 @@
/* FPU control word bits. i387 version.
- Copyright (C) 1993,1995,1996,1997,1998,2000,2001 Free Software Foundation, Inc.
+ Copyright (C) 1993,1995-1998,2000,2001,2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Olaf Flebbe.
@@ -88,11 +88,17 @@
/* Type of the control word. */
typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
-/* Macros for accessing the hardware control word. */
-#define _FPU_GETCW(cw) __asm__ ("fnstcw %0" : "=m" (*&cw))
-#define _FPU_SETCW(cw) __asm__ ("fldcw %0" : : "m" (*&cw))
+/* Macros for accessing the hardware control word.
+ Note that the use of these macros is no sufficient anymore with
+ recent hardware. Some floating point operations are executed in
+ the SSE/SSE2 engines which have their own control and status register. */
+#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw))
+#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw))
+
+#if 0
/* Default control word set at startup. */
extern fpu_control_t __fpu_control;
+#endif
#endif /* fpu_control.h */
diff --git a/libc/sysdeps/linux/m68k/fpu_control.h b/libc/sysdeps/linux/m68k/fpu_control.h
index 1b2ba87c9..484bad3b9 100644
--- a/libc/sysdeps/linux/m68k/fpu_control.h
+++ b/libc/sysdeps/linux/m68k/fpu_control.h
@@ -1,4 +1,4 @@
-/* FPU control word definitions. PowerPC version.
+/* 68k FPU control word definitions.
Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -20,50 +20,84 @@
#ifndef _FPU_CONTROL_H
#define _FPU_CONTROL_H
-/* rounding control */
-#define _FPU_RC_NEAREST 0x00 /* RECOMMENDED */
-#define _FPU_RC_DOWN 0x03
-#define _FPU_RC_UP 0x02
-#define _FPU_RC_ZERO 0x01
+/*
+ * Motorola floating point control register bits.
+ *
+ * 31-16 -> reserved (read as 0, ignored on write)
+ * 15 -> enable trap for BSUN exception
+ * 14 -> enable trap for SNAN exception
+ * 13 -> enable trap for OPERR exception
+ * 12 -> enable trap for OVFL exception
+ * 11 -> enable trap for UNFL exception
+ * 10 -> enable trap for DZ exception
+ * 9 -> enable trap for INEX2 exception
+ * 8 -> enable trap for INEX1 exception
+ * 7-6 -> Precision Control
+ * 5-4 -> Rounding Control
+ * 3-0 -> zero (read as 0, write as 0)
+ *
+ *
+ * Precision Control:
+ * 00 - round to extended precision
+ * 01 - round to single precision
+ * 10 - round to double precision
+ * 11 - undefined
+ *
+ * Rounding Control:
+ * 00 - rounding to nearest (RN)
+ * 01 - rounding toward zero (RZ)
+ * 10 - rounding (down)toward minus infinity (RM)
+ * 11 - rounding (up) toward plus infinity (RP)
+ *
+ * The hardware default is 0x0000. I choose 0x5400.
+ */
-#define _FPU_MASK_NI 0x04 /* non-ieee mode */
+#include <features.h>
/* masking of interrupts */
-#define _FPU_MASK_ZM 0x10 /* zero divide */
-#define _FPU_MASK_OM 0x40 /* overflow */
-#define _FPU_MASK_UM 0x20 /* underflow */
-#define _FPU_MASK_XM 0x08 /* inexact */
-#define _FPU_MASK_IM 0x80 /* invalid operation */
+#define _FPU_MASK_BSUN 0x8000
+#define _FPU_MASK_SNAN 0x4000
+#define _FPU_MASK_OPERR 0x2000
+#define _FPU_MASK_OVFL 0x1000
+#define _FPU_MASK_UNFL 0x0800
+#define _FPU_MASK_DZ 0x0400
+#define _FPU_MASK_INEX1 0x0200
+#define _FPU_MASK_INEX2 0x0100
-#define _FPU_RESERVED 0xffffff00 /* These bits are reserved are not changed. */
+/* precision control */
+#define _FPU_EXTENDED 0x00 /* RECOMMENDED */
+#define _FPU_DOUBLE 0x80
+#define _FPU_SINGLE 0x40 /* DO NOT USE */
-/* The fdlibm code requires no interrupts for exceptions. */
-#define _FPU_DEFAULT 0x00000000 /* Default value. */
+/* rounding control */
+#define _FPU_RC_NEAREST 0x00 /* RECOMMENDED */
+#define _FPU_RC_ZERO 0x10
+#define _FPU_RC_DOWN 0x20
+#define _FPU_RC_UP 0x30
-/* IEEE: same as above, but (some) exceptions;
- we leave the 'inexact' exception off.
- */
-#define _FPU_IEEE 0x000000f0
+#define _FPU_RESERVED 0xFFFF000F /* Reserved bits in fpucr */
+
+
+/* Now two recommended fpucr */
+
+/* The fdlibm code requires no interrupts for exceptions. Don't
+ change the rounding mode, it would break long double I/O! */
+#define _FPU_DEFAULT 0x00000000
+
+/* IEEE: same as above, but exceptions. We must make it non-zero so
+ that __setfpucw works. This bit will be ignored. */
+#define _FPU_IEEE 0x00000001
/* Type of the control word. */
typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__SI__)));
/* Macros for accessing the hardware control word. */
-#define _FPU_GETCW(__cw) ( { \
- union { double d; fpu_control_t cw[2]; } \
- tmp __attribute__ ((__aligned__(8))); \
- __asm__ ("mffs 0; stfd%U0 0,%0" : "=m" (tmp.d) : : "fr0"); \
- (__cw)=tmp.cw[1]; \
- tmp.cw[1]; } )
-#define _FPU_SETCW(__cw) { \
- union { double d; fpu_control_t cw[2]; } \
- tmp __attribute__ ((__aligned__(8))); \
- tmp.cw[0] = 0xFFF80000; /* More-or-less arbitrary; this is a QNaN. */ \
- tmp.cw[1] = __cw; \
- __asm__ ("lfd%U0 0,%0; mtfsf 255,0" : : "m" (tmp.d) : "fr0"); \
-}
+#define _FPU_GETCW(cw) __asm__ ("fmove%.l %!, %0" : "=dm" (cw))
+#define _FPU_SETCW(cw) __asm__ volatile ("fmove%.l %0, %!" : : "dm" (cw))
+#if 0
/* Default control word set at startup. */
extern fpu_control_t __fpu_control;
+#endif
-#endif /* _FPU_CONTROL_H */
+#endif /* _M68K_FPU_CONTROL_H */
diff --git a/libc/sysdeps/linux/mips/fpu_control.h b/libc/sysdeps/linux/mips/fpu_control.h
index da18deab5..c58b23503 100644
--- a/libc/sysdeps/linux/mips/fpu_control.h
+++ b/libc/sysdeps/linux/mips/fpu_control.h
@@ -92,7 +92,9 @@ typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__SI__)));
#define _FPU_GETCW(cw) __asm__ ("cfc1 %0,$31" : "=r" (cw))
#define _FPU_SETCW(cw) __asm__ ("ctc1 %0,$31" : : "r" (cw))
+#if 0
/* Default control word set at startup. */
extern fpu_control_t __fpu_control;
+#endif
#endif /* fpu_control.h */
diff --git a/libc/sysdeps/linux/nios/fpu_control.h b/libc/sysdeps/linux/nios/fpu_control.h
index b7cdf2f3e..9c3174574 100644
--- a/libc/sysdeps/linux/nios/fpu_control.h
+++ b/libc/sysdeps/linux/nios/fpu_control.h
@@ -91,7 +91,9 @@ typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__SI__)));
#define _FPU_GETCW(cw) __asm__ ("cfc1 %0,$31" : "=r" (cw))
#define _FPU_SETCW(cw) __asm__ ("ctc1 %0,$31" : : "r" (cw))
+#if 0
/* Default control word set at startup. */
extern fpu_control_t __fpu_control;
+#endif
#endif /* fpu_control.h */
diff --git a/libc/sysdeps/linux/nios2/fpu_control.h b/libc/sysdeps/linux/nios2/fpu_control.h
index b7cdf2f3e..9c3174574 100644
--- a/libc/sysdeps/linux/nios2/fpu_control.h
+++ b/libc/sysdeps/linux/nios2/fpu_control.h
@@ -91,7 +91,9 @@ typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__SI__)));
#define _FPU_GETCW(cw) __asm__ ("cfc1 %0,$31" : "=r" (cw))
#define _FPU_SETCW(cw) __asm__ ("ctc1 %0,$31" : : "r" (cw))
+#if 0
/* Default control word set at startup. */
extern fpu_control_t __fpu_control;
+#endif
#endif /* fpu_control.h */
diff --git a/libc/sysdeps/linux/powerpc/fpu_control.h b/libc/sysdeps/linux/powerpc/fpu_control.h
index 1b2ba87c9..2df9ba0e7 100644
--- a/libc/sysdeps/linux/powerpc/fpu_control.h
+++ b/libc/sysdeps/linux/powerpc/fpu_control.h
@@ -63,7 +63,9 @@ typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__SI__)));
__asm__ ("lfd%U0 0,%0; mtfsf 255,0" : : "m" (tmp.d) : "fr0"); \
}
+#if 0
/* Default control word set at startup. */
extern fpu_control_t __fpu_control;
+#endif
#endif /* _FPU_CONTROL_H */
diff --git a/libc/sysdeps/linux/sh/fpu_control.h b/libc/sysdeps/linux/sh/fpu_control.h
index 43eb9e549..db3cc4557 100644
--- a/libc/sysdeps/linux/sh/fpu_control.h
+++ b/libc/sysdeps/linux/sh/fpu_control.h
@@ -20,6 +20,8 @@
#ifndef _FPU_CONTROL_H
#define _FPU_CONTROL_H
+#warning This file is only correct for sh4
+
/* masking of interrupts */
#define _FPU_MASK_VM 0x0800 /* Invalid operation */
#define _FPU_MASK_ZM 0x0400 /* Division by zero */
@@ -50,7 +52,9 @@ typedef unsigned int fpu_control_t;
#define _FPU_SETCW(cw) __asm__ ("lds %0,fpscr" : : "r" (cw))
#endif
+#if 0
/* Default control word set at startup. */
extern fpu_control_t __fpu_control;
+#endif
#endif /* _FPU_CONTROL_H */
diff --git a/libc/sysdeps/linux/sparc/fpu_control.h b/libc/sysdeps/linux/sparc/fpu_control.h
index b29734ce2..41ab0a917 100644
--- a/libc/sysdeps/linux/sparc/fpu_control.h
+++ b/libc/sysdeps/linux/sparc/fpu_control.h
@@ -67,7 +67,9 @@ typedef unsigned long int fpu_control_t;
# define _FPU_SETCW(cw) __asm__ ("ld %0,%%fsr" : : "m" (*&cw))
#endif
+#if 0
/* Default control word set at startup. */
extern fpu_control_t __fpu_control;
+#endif
#endif /* fpu_control.h */
diff --git a/libc/sysdeps/linux/x86_64/fpu_control.h b/libc/sysdeps/linux/x86_64/fpu_control.h
index 3eae48e0d..6e9b3b362 100644
--- a/libc/sysdeps/linux/x86_64/fpu_control.h
+++ b/libc/sysdeps/linux/x86_64/fpu_control.h
@@ -95,7 +95,9 @@ typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__)));
#define _FPU_GETCW(cw) __asm__ ("fnstcw %0" : "=m" (*&cw))
#define _FPU_SETCW(cw) __asm__ ("fldcw %0" : : "m" (*&cw))
+#if 0
/* Default control word set at startup. */
extern fpu_control_t __fpu_control;
+#endif
#endif /* fpu_control.h */