summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMartynas Venckus <martynas@cvs.openbsd.org>2011-04-28 17:34:24 +0000
committerMartynas Venckus <martynas@cvs.openbsd.org>2011-04-28 17:34:24 +0000
commitf70eacf51aa926a56332357f2fd9556df8f52acb (patch)
tree8f92efc601af164ae9d2320e5eeae77bc248a633 /sys
parent8fbde66430aa8b0773d3387e5e56968cd07a3156 (diff)
fenv improvements and cleanups
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/alpha/include/fenv.h39
-rw-r--r--sys/arch/amd64/include/fenv.h41
-rw-r--r--sys/arch/arm/include/fenv.h37
-rw-r--r--sys/arch/hppa/include/fenv.h46
-rw-r--r--sys/arch/hppa64/include/fenv.h92
-rw-r--r--sys/arch/i386/include/fenv.h76
-rw-r--r--sys/arch/m68k/include/fenv.h40
-rw-r--r--sys/arch/m88k/include/fenv.h94
-rw-r--r--sys/arch/mips64/include/fenv.h46
-rw-r--r--sys/arch/powerpc/include/fenv.h36
-rw-r--r--sys/arch/sh/include/fenv.h36
-rw-r--r--sys/arch/sparc/include/fenv.h93
-rw-r--r--sys/arch/sparc64/include/fenv.h93
13 files changed, 537 insertions, 232 deletions
diff --git a/sys/arch/alpha/include/fenv.h b/sys/arch/alpha/include/fenv.h
index c3af55b79aa..c9f76150afe 100644
--- a/sys/arch/alpha/include/fenv.h
+++ b/sys/arch/alpha/include/fenv.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: fenv.h,v 1.1 2011/04/23 22:39:14 martynas Exp $ */
+/* $OpenBSD: fenv.h,v 1.2 2011/04/28 17:34:23 martynas Exp $ */
/*
* Copyright (c) 2011 Martynas Venckus <martynas@openbsd.org>
@@ -31,15 +31,13 @@
#define FE_OVERFLOW 0x04
#define FE_UNDERFLOW 0x08
#define FE_INEXACT 0x10
-#define FE_INTOVERFLOW 0x20
/*
* The following symbol is simply the bitwise-inclusive OR of all floating-point
* exception constants defined above.
*/
-#define FE_ALL_EXCEPT \
- (FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW | \
- FE_INTOVERFLOW)
+#define FE_ALL_EXCEPT (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | \
+ FE_UNDERFLOW)
/*
* Each symbol representing the rounding direction, expands to an integer
@@ -56,21 +54,30 @@
* The following symbol is simply the bitwise-inclusive OR of all floating-point
* rounding direction constants defined above.
*/
-#define _ROUND_MASK \
- (FE_TOWARDZERO | FE_DOWNWARD | FE_TONEAREST | FE_UPWARD)
+#define _ROUND_MASK (FE_TOWARDZERO | FE_DOWNWARD | FE_TONEAREST | \
+ FE_UPWARD)
#define _ROUND_SHIFT 58
/*
- * fenv_t represents the entire floating-point environment
+ * fenv_t represents the entire floating-point environment.
*/
-typedef struct {
- unsigned short __excepts;
- unsigned short __mask;
- unsigned short __round;
+typedef struct {
+ unsigned int __sticky;
+ unsigned int __mask;
+ unsigned int __round;
} fenv_t;
-extern fenv_t __fe_dfl_env;
-#define FE_DFL_ENV ((const fenv_t *) &__fe_dfl_env)
+/*
+ * The following constant represents the default floating-point environment
+ * (that is, the one installed at program startup) and has type pointer to
+ * const-qualified fenv_t.
+ *
+ * It can be used as an argument to the functions within the <fenv.h> header
+ * that manage the floating-point environment, namely fesetenv() and
+ * feupdateenv().
+ */
+extern fenv_t __fe_dfl_env;
+#define FE_DFL_ENV ((const fenv_t *)&__fe_dfl_env)
/*
* fexcept_t represents the floating-point status flags collectively, including
@@ -84,6 +91,6 @@ extern fenv_t __fe_dfl_env;
* A floating-point control mode is a system variable whose value may be set by
* the user to affect the subsequent behavior of floating-point arithmetic.
*/
-typedef unsigned short fexcept_t;
+typedef unsigned int fexcept_t;
-#endif /* ! _ALPHA_FENV_H_ */
+#endif /* !_ALPHA_FENV_H_ */
diff --git a/sys/arch/amd64/include/fenv.h b/sys/arch/amd64/include/fenv.h
index 67c5cff7889..addc8214da1 100644
--- a/sys/arch/amd64/include/fenv.h
+++ b/sys/arch/amd64/include/fenv.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: fenv.h,v 1.2 2011/04/23 21:54:20 martynas Exp $ */
+/* $OpenBSD: fenv.h,v 1.3 2011/04/28 17:34:23 martynas Exp $ */
/* $NetBSD: fenv.h,v 1.1 2010/07/31 21:47:54 joerg Exp $ */
/*-
@@ -48,9 +48,9 @@
* The following symbol is simply the bitwise-inclusive OR of all floating-point
* exception constants defined above.
*/
-#define FE_ALL_EXCEPT \
- (FE_DIVBYZERO | FE_INEXACT | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW | \
- FE_DENORMAL)
+#define FE_ALL_EXCEPT (FE_INVALID | FE_DENORMAL | FE_DIVBYZERO | \
+ FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT)
+#define _SSE_MASK_SHIFT 7
/*
* Each symbol representing the rounding direction, expands to an integer
@@ -61,22 +61,20 @@
#define FE_TONEAREST 0x000
#define FE_DOWNWARD 0x400
#define FE_UPWARD 0x800
-#define FE_TOWARDZERO 0xC00
+#define FE_TOWARDZERO 0xc00
/*
- * As compared to the x87 control word, the SSE unit's control word
- * has the rounding control bits offset by 3 and the exception mask
- * bits offset by 7.
+ * The following symbol is simply the bitwise-inclusive OR of all floating-point
+ * rounding direction constants defined above.
*/
-#define _X87_ROUND_MASK 0xC00
-#define _SSE_ROUND_MASK (0xC00 << 3)
+#define _X87_ROUND_MASK (FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | \
+ FE_TOWARDZERO)
#define _SSE_ROUND_SHIFT 3
-#define _SSE_EMASK_SHIFT 7
/*
- * fenv_t represents the entire floating-point environment
+ * fenv_t represents the entire floating-point environment.
*/
-typedef struct {
+typedef struct {
struct {
unsigned int __control; /* Control word register */
unsigned int __status; /* Status word register */
@@ -86,8 +84,17 @@ typedef struct {
unsigned int __mxcsr; /* Control, status register */
} fenv_t;
-extern fenv_t __fe_dfl_env;
-#define FE_DFL_ENV ((const fenv_t *) &__fe_dfl_env)
+/*
+ * The following constant represents the default floating-point environment
+ * (that is, the one installed at program startup) and has type pointer to
+ * const-qualified fenv_t.
+ *
+ * It can be used as an argument to the functions within the <fenv.h> header
+ * that manage the floating-point environment, namely fesetenv() and
+ * feupdateenv().
+ */
+extern fenv_t __fe_dfl_env;
+#define FE_DFL_ENV ((const fenv_t *)&__fe_dfl_env)
/*
* fexcept_t represents the floating-point status flags collectively, including
@@ -101,6 +108,6 @@ extern fenv_t __fe_dfl_env;
* A floating-point control mode is a system variable whose value may be set by
* the user to affect the subsequent behavior of floating-point arithmetic.
*/
-typedef unsigned int fexcept_t;
+typedef unsigned int fexcept_t;
-#endif /* ! _AMD64_FENV_H_ */
+#endif /* !_AMD64_FENV_H_ */
diff --git a/sys/arch/arm/include/fenv.h b/sys/arch/arm/include/fenv.h
index 51a580a8230..8811db10c7b 100644
--- a/sys/arch/arm/include/fenv.h
+++ b/sys/arch/arm/include/fenv.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: fenv.h,v 1.1 2011/04/24 00:20:27 martynas Exp $ */
+/* $OpenBSD: fenv.h,v 1.2 2011/04/28 17:34:23 martynas Exp $ */
/*
* Copyright (c) 2011 Martynas Venckus <martynas@openbsd.org>
@@ -36,8 +36,8 @@
* The following symbol is simply the bitwise-inclusive OR of all floating-point
* exception constants defined above.
*/
-#define FE_ALL_EXCEPT \
- (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT)
+#define FE_ALL_EXCEPT (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | \
+ FE_UNDERFLOW | FE_INEXACT)
/*
* Each symbol representing the rounding direction, expands to an integer
@@ -54,20 +54,29 @@
* The following symbol is simply the bitwise-inclusive OR of all floating-point
* rounding direction constants defined above.
*/
-#define _ROUND_MASK \
- (FE_TOWARDZERO | FE_DOWNWARD | FE_TONEAREST | FE_UPWARD)
+#define _ROUND_MASK (FE_TONEAREST | FE_UPWARD | FE_DOWNWARD | \
+ FE_TOWARDZERO)
/*
- * fenv_t represents the entire floating-point environment
+ * fenv_t represents the entire floating-point environment.
*/
-typedef struct {
- unsigned short __excepts;
- unsigned short __mask;
- unsigned short __round;
+typedef struct {
+ unsigned int __sticky;
+ unsigned int __mask;
+ unsigned int __round;
} fenv_t;
-extern fenv_t __fe_dfl_env;
-#define FE_DFL_ENV ((const fenv_t *) &__fe_dfl_env)
+/*
+ * The following constant represents the default floating-point environment
+ * (that is, the one installed at program startup) and has type pointer to
+ * const-qualified fenv_t.
+ *
+ * It can be used as an argument to the functions within the <fenv.h> header
+ * that manage the floating-point environment, namely fesetenv() and
+ * feupdateenv().
+ */
+extern fenv_t __fe_dfl_env;
+#define FE_DFL_ENV ((const fenv_t *)&__fe_dfl_env)
/*
* fexcept_t represents the floating-point status flags collectively, including
@@ -81,6 +90,6 @@ extern fenv_t __fe_dfl_env;
* A floating-point control mode is a system variable whose value may be set by
* the user to affect the subsequent behavior of floating-point arithmetic.
*/
-typedef unsigned short fexcept_t;
+typedef unsigned int fexcept_t;
-#endif /* ! _ARM_FENV_H_ */
+#endif /* !_ARM_FENV_H_ */
diff --git a/sys/arch/hppa/include/fenv.h b/sys/arch/hppa/include/fenv.h
index 379a469a836..1cd923e827c 100644
--- a/sys/arch/hppa/include/fenv.h
+++ b/sys/arch/hppa/include/fenv.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: fenv.h,v 1.1 2011/04/21 20:40:54 martynas Exp $ */
+/* $OpenBSD: fenv.h,v 1.2 2011/04/28 17:34:23 martynas Exp $ */
/*
* Copyright (c) 2011 Martynas Venckus <martynas@openbsd.org>
@@ -26,18 +26,19 @@
*
* We use such values that allow direct bitwise operations on FPU registers.
*/
-#define FE_INEXACT 0x08000000
-#define FE_UNDERFLOW 0x10000000
-#define FE_OVERFLOW 0x20000000
-#define FE_DIVBYZERO 0x40000000
-#define FE_INVALID 0x80000000
+#define FE_INEXACT 0x01
+#define FE_UNDERFLOW 0x02
+#define FE_OVERFLOW 0x04
+#define FE_DIVBYZERO 0x08
+#define FE_INVALID 0x10
/*
* The following symbol is simply the bitwise-inclusive OR of all floating-point
* exception constants defined above.
*/
-#define FE_ALL_EXCEPT \
- (FE_DIVBYZERO | FE_INEXACT | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
+#define FE_ALL_EXCEPT (FE_INEXACT | FE_UNDERFLOW | FE_OVERFLOW | \
+ FE_DIVBYZERO | FE_INVALID)
+#define _MASK_SHIFT 27
/*
* Each symbol representing the rounding direction, expands to an integer
@@ -51,19 +52,28 @@
#define FE_DOWNWARD 0x600
/*
- * FPSR encodes rounding modes by bits 9-10.
- * FPSR flags and exception mask shifts by 27.
+ * The following symbol is simply the bitwise-inclusive OR of all floating-point
+ * rounding direction constants defined above.
*/
-#define _ROUND_MASK 0x600
-#define _EMASK_SHIFT 27
+#define _ROUND_MASK (FE_TONEAREST | FE_TOWARDZERO | FE_UPWARD | \
+ FE_DOWNWARD)
/*
- * fenv_t represents the entire floating-point environment
+ * fenv_t represents the entire floating-point environment.
*/
-typedef unsigned int fenv_t;
+typedef unsigned int fenv_t;
-extern fenv_t __fe_dfl_env;
-#define FE_DFL_ENV ((const fenv_t *) &__fe_dfl_env)
+/*
+ * The following constant represents the default floating-point environment
+ * (that is, the one installed at program startup) and has type pointer to
+ * const-qualified fenv_t.
+ *
+ * It can be used as an argument to the functions within the <fenv.h> header
+ * that manage the floating-point environment, namely fesetenv() and
+ * feupdateenv().
+ */
+extern fenv_t __fe_dfl_env;
+#define FE_DFL_ENV ((const fenv_t *)&__fe_dfl_env)
/*
* fexcept_t represents the floating-point status flags collectively, including
@@ -77,6 +87,6 @@ extern fenv_t __fe_dfl_env;
* A floating-point control mode is a system variable whose value may be set by
* the user to affect the subsequent behavior of floating-point arithmetic.
*/
-typedef unsigned int fexcept_t;
+typedef unsigned int fexcept_t;
-#endif /* ! _HPPA_FENV_H_ */
+#endif /* !_HPPA_FENV_H_ */
diff --git a/sys/arch/hppa64/include/fenv.h b/sys/arch/hppa64/include/fenv.h
new file mode 100644
index 00000000000..33a4ee0a879
--- /dev/null
+++ b/sys/arch/hppa64/include/fenv.h
@@ -0,0 +1,92 @@
+/* $OpenBSD: fenv.h,v 1.1 2011/04/28 17:34:23 martynas Exp $ */
+
+/*
+ * Copyright (c) 2011 Martynas Venckus <martynas@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _HPPA64_FENV_H_
+#define _HPPA64_FENV_H_
+
+/*
+ * Each symbol representing a floating point exception expands to an integer
+ * constant expression with values, such that bitwise-inclusive ORs of _all
+ * combinations_ of the constants result in distinct values.
+ *
+ * We use such values that allow direct bitwise operations on FPU registers.
+ */
+#define FE_INEXACT 0x01
+#define FE_UNDERFLOW 0x02
+#define FE_OVERFLOW 0x04
+#define FE_DIVBYZERO 0x08
+#define FE_INVALID 0x10
+
+/*
+ * The following symbol is simply the bitwise-inclusive OR of all floating-point
+ * exception constants defined above.
+ */
+#define FE_ALL_EXCEPT (FE_INEXACT | FE_UNDERFLOW | FE_OVERFLOW | \
+ FE_DIVBYZERO | FE_INVALID)
+#define _MASK_SHIFT 27
+
+/*
+ * Each symbol representing the rounding direction, expands to an integer
+ * constant expression whose value is distinct non-negative value.
+ *
+ * We use such values that allow direct bitwise operations on FPU registers.
+ */
+#define FE_TONEAREST 0x000
+#define FE_TOWARDZERO 0x200
+#define FE_UPWARD 0x400
+#define FE_DOWNWARD 0x600
+
+/*
+ * The following symbol is simply the bitwise-inclusive OR of all floating-point
+ * rounding direction constants defined above.
+ */
+#define _ROUND_MASK (FE_TONEAREST | FE_TOWARDZERO | FE_UPWARD | \
+ FE_DOWNWARD)
+
+/*
+ * fenv_t represents the entire floating-point environment.
+ */
+typedef unsigned int fenv_t;
+
+/*
+ * The following constant represents the default floating-point environment
+ * (that is, the one installed at program startup) and has type pointer to
+ * const-qualified fenv_t.
+ *
+ * It can be used as an argument to the functions within the <fenv.h> header
+ * that manage the floating-point environment, namely fesetenv() and
+ * feupdateenv().
+ */
+extern fenv_t __fe_dfl_env;
+#define FE_DFL_ENV ((const fenv_t *)&__fe_dfl_env)
+
+/*
+ * fexcept_t represents the floating-point status flags collectively, including
+ * any status the implementation associates with the flags.
+ *
+ * A floating-point status flag is a system variable whose value is set (but
+ * never cleared) when a floating-point exception is raised, which occurs as a
+ * side effect of exceptional floating-point arithmetic to provide auxiliary
+ * information.
+ *
+ * A floating-point control mode is a system variable whose value may be set by
+ * the user to affect the subsequent behavior of floating-point arithmetic.
+ */
+typedef unsigned int fexcept_t;
+
+#endif /* !_HPPA64_FENV_H_ */
diff --git a/sys/arch/i386/include/fenv.h b/sys/arch/i386/include/fenv.h
index a756899525d..80d34a65325 100644
--- a/sys/arch/i386/include/fenv.h
+++ b/sys/arch/i386/include/fenv.h
@@ -1,5 +1,6 @@
-/* $OpenBSD: fenv.h,v 1.1 2011/04/24 00:35:22 martynas Exp $ */
+/* $OpenBSD: fenv.h,v 1.2 2011/04/28 17:34:23 martynas Exp $ */
/* $NetBSD: fenv.h,v 1.1.6.2 2010/10/24 22:48:02 jym Exp $ */
+
/*-
* Copyright (c) 2004-2005 David Schultz <das (at) FreeBSD.ORG>
* All rights reserved.
@@ -26,11 +27,8 @@
* SUCH DAMAGE.
*/
-#ifndef _X86_FENV_H_
-#define _X86_FENV_H_
-
-#include <sys/stdint.h>
-#include <i386/npx.h>
+#ifndef _I386_FENV_H_
+#define _I386_FENV_H_
/*
* Each symbol representing a floating point exception expands to an integer
@@ -39,19 +37,20 @@
*
* We use such values that allow direct bitwise operations on FPU/SSE registers.
*/
-#define FE_INVALID 0x01 /* 000000000001 */
-#define FE_DENORMAL 0x02 /* 000000000010 */
-#define FE_DIVBYZERO 0x04 /* 000000000100 */
-#define FE_OVERFLOW 0x08 /* 000000001000 */
-#define FE_UNDERFLOW 0x10 /* 000000010000 */
-#define FE_INEXACT 0x20 /* 000000100000 */
+#define FE_INVALID 0x01
+#define FE_DENORMAL 0x02
+#define FE_DIVBYZERO 0x04
+#define FE_OVERFLOW 0x08
+#define FE_UNDERFLOW 0x10
+#define FE_INEXACT 0x20
/*
* The following symbol is simply the bitwise-inclusive OR of all floating-point
* exception constants defined above.
*/
-#define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_DENORMAL | FE_INEXACT | \
- FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
+#define FE_ALL_EXCEPT (FE_INVALID | FE_DENORMAL | FE_DIVBYZERO | \
+ FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT)
+#define _SSE_MASK_SHIFT 7
/*
* Each symbol representing the rounding direction, expands to an integer
@@ -59,34 +58,30 @@
*
* We use such values that allow direct bitwise operations on FPU/SSE registers.
*/
-#define FE_TONEAREST 0x000 /* 000000000000 */
-#define FE_DOWNWARD 0x400 /* 010000000000 */
-#define FE_UPWARD 0x800 /* 100000000000 */
-#define FE_TOWARDZERO 0xC00 /* 110000000000 */
+#define FE_TONEAREST 0x000
+#define FE_DOWNWARD 0x400
+#define FE_UPWARD 0x800
+#define FE_TOWARDZERO 0xc00
/*
- * As compared to the x87 control word, the SSE unit's control has the rounding
- * control bits offset by 3 and the exception mask bits offset by 7
+ * The following symbol is simply the bitwise-inclusive OR of all floating-point
+ * rounding direction constants defined above.
*/
-#define __X87_ROUND_MASK 0xC00 /* 110000000000 */
-#define __SSE_ROUND_SHIFT 3
-#define __SSE_EMASK_SHIFT 7
+#define _X87_ROUND_MASK (FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | \
+ FE_TOWARDZERO)
+#define _SSE_ROUND_SHIFT 3
/*
- * fenv_t represents the entire floating-point environment
+ * fenv_t represents the entire floating-point environment.
*/
-typedef struct {
+typedef struct {
struct {
- uint16_t control; /* Control word register */
- uint16_t unused1;
- uint16_t status; /* Status word register */
- uint16_t unused2;
- uint16_t tag; /* Tag word register */
- uint16_t unused3;
- uint32_t others[4]; /* EIP, Pointer Selector, etc */
- } x87;
-
- uint32_t mxcsr; /* Control and status register */
+ unsigned int __control; /* Control word register */
+ unsigned int __status; /* Status word register */
+ unsigned int __tag; /* Tag word register */
+ unsigned int __others[4]; /* EIP, Pointer Selector, etc */
+ } __x87;
+ unsigned int __mxcsr; /* Control, status register */
} fenv_t;
/*
@@ -95,10 +90,11 @@ typedef struct {
* const-qualified fenv_t.
*
* It can be used as an argument to the functions within the <fenv.h> header
- * that manage the floating-point environment.
+ * that manage the floating-point environment, namely fesetenv() and
+ * feupdateenv().
*/
-extern fenv_t __fe_dfl_env;
-#define FE_DFL_ENV ((const fenv_t *) &__fe_dfl_env)
+extern fenv_t __fe_dfl_env;
+#define FE_DFL_ENV ((const fenv_t *)&__fe_dfl_env)
/*
* fexcept_t represents the floating-point status flags collectively, including
@@ -112,6 +108,6 @@ extern fenv_t __fe_dfl_env;
* A floating-point control mode is a system variable whose value may be set by
* the user to affect the subsequent behavior of floating-point arithmetic.
*/
-typedef uint32_t fexcept_t;
+typedef unsigned int fexcept_t;
-#endif /* ! _X86_FENV_H_ */
+#endif /* !_I386_FENV_H_ */
diff --git a/sys/arch/m68k/include/fenv.h b/sys/arch/m68k/include/fenv.h
index abf3de866e0..c7a0acf9e72 100644
--- a/sys/arch/m68k/include/fenv.h
+++ b/sys/arch/m68k/include/fenv.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: fenv.h,v 1.1 2011/04/20 22:27:59 martynas Exp $ */
+/* $OpenBSD: fenv.h,v 1.2 2011/04/28 17:34:23 martynas Exp $ */
/*
* Copyright (c) 2011 Martynas Venckus <martynas@openbsd.org>
@@ -36,8 +36,9 @@
* The following symbol is simply the bitwise-inclusive OR of all floating-point
* exception constants defined above.
*/
-#define FE_ALL_EXCEPT \
- (FE_DIVBYZERO | FE_INEXACT | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
+#define FE_ALL_EXCEPT (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | \
+ FE_OVERFLOW | FE_INVALID)
+#define _MASK_SHIFT 6
/*
* Each symbol representing the rounding direction, expands to an integer
@@ -51,22 +52,31 @@
#define FE_UPWARD 0x30
/*
- * FPCR encodes rounding modes by bits 4-5.
- * FPCR and FPSR exception mask shifts by 6.
+ * The following symbol is simply the bitwise-inclusive OR of all floating-point
+ * rounding direction constants defined above.
*/
-#define _ROUND_MASK 0x30
-#define _EMASK_SHIFT 6
+#define _ROUND_MASK (FE_TONEAREST | FE_TOWARDZERO | FE_DOWNWARD | \
+ FE_UPWARD)
/*
- * fenv_t represents the entire floating-point environment
+ * fenv_t represents the entire floating-point environment.
*/
-typedef struct {
- unsigned int __control; /* Control register */
- unsigned int __status; /* Status register */
+typedef struct {
+ unsigned int __control; /* Control register */
+ unsigned int __status; /* Status register */
} fenv_t;
-extern fenv_t __fe_dfl_env;
-#define FE_DFL_ENV ((const fenv_t *) &__fe_dfl_env)
+/*
+ * The following constant represents the default floating-point environment
+ * (that is, the one installed at program startup) and has type pointer to
+ * const-qualified fenv_t.
+ *
+ * It can be used as an argument to the functions within the <fenv.h> header
+ * that manage the floating-point environment, namely fesetenv() and
+ * feupdateenv().
+ */
+extern fenv_t __fe_dfl_env;
+#define FE_DFL_ENV ((const fenv_t *)&__fe_dfl_env)
/*
* fexcept_t represents the floating-point status flags collectively, including
@@ -80,6 +90,6 @@ extern fenv_t __fe_dfl_env;
* A floating-point control mode is a system variable whose value may be set by
* the user to affect the subsequent behavior of floating-point arithmetic.
*/
-typedef unsigned int fexcept_t;
+typedef unsigned int fexcept_t;
-#endif /* ! _M68K_FENV_H_ */
+#endif /* !_M68K_FENV_H_ */
diff --git a/sys/arch/m88k/include/fenv.h b/sys/arch/m88k/include/fenv.h
new file mode 100644
index 00000000000..f229e98557e
--- /dev/null
+++ b/sys/arch/m88k/include/fenv.h
@@ -0,0 +1,94 @@
+/* $OpenBSD: fenv.h,v 1.1 2011/04/28 17:34:23 martynas Exp $ */
+
+/*
+ * Copyright (c) 2011 Martynas Venckus <martynas@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _M88K_FENV_H_
+#define _M88K_FENV_H_
+
+/*
+ * Each symbol representing a floating point exception expands to an integer
+ * constant expression with values, such that bitwise-inclusive ORs of _all
+ * combinations_ of the constants result in distinct values.
+ *
+ * We use such values that allow direct bitwise operations on FPU registers.
+ */
+#define FE_INEXACT 0x01
+#define FE_OVERFLOW 0x02
+#define FE_UNDERFLOW 0x04
+#define FE_DIVBYZERO 0x08
+#define FE_INVALID 0x10
+
+/*
+ * The following symbol is simply the bitwise-inclusive OR of all floating-point
+ * exception constants defined above.
+ */
+#define FE_ALL_EXCEPT (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | \
+ FE_OVERFLOW | FE_INVALID)
+
+/*
+ * Each symbol representing the rounding direction, expands to an integer
+ * constant expression whose value is distinct non-negative value.
+ *
+ * We use such values that allow direct bitwise operations on FPU registers.
+ */
+#define FE_TONEAREST 0x0000
+#define FE_TOWARDZERO 0x4000
+#define FE_DOWNWARD 0x8000
+#define FE_UPWARD 0xC000
+
+/*
+ * The following symbol is simply the bitwise-inclusive OR of all floating-point
+ * rounding direction constants defined above.
+ */
+#define _ROUND_MASK (FE_TONEAREST | FE_TOWARDZERO | FE_DOWNWARD | \
+ FE_UPWARD)
+
+/*
+ * fenv_t represents the entire floating-point environment.
+ */
+typedef struct {
+ unsigned int __control; /* Control register */
+ unsigned int __status; /* Status register */
+} fenv_t;
+
+/*
+ * The following constant represents the default floating-point environment
+ * (that is, the one installed at program startup) and has type pointer to
+ * const-qualified fenv_t.
+ *
+ * It can be used as an argument to the functions within the <fenv.h> header
+ * that manage the floating-point environment, namely fesetenv() and
+ * feupdateenv().
+ */
+extern fenv_t __fe_dfl_env;
+#define FE_DFL_ENV ((const fenv_t *)&__fe_dfl_env)
+
+/*
+ * fexcept_t represents the floating-point status flags collectively, including
+ * any status the implementation associates with the flags.
+ *
+ * A floating-point status flag is a system variable whose value is set (but
+ * never cleared) when a floating-point exception is raised, which occurs as a
+ * side effect of exceptional floating-point arithmetic to provide auxiliary
+ * information.
+ *
+ * A floating-point control mode is a system variable whose value may be set by
+ * the user to affect the subsequent behavior of floating-point arithmetic.
+ */
+typedef unsigned int fexcept_t;
+
+#endif /* !_M88K_FENV_H_ */
diff --git a/sys/arch/mips64/include/fenv.h b/sys/arch/mips64/include/fenv.h
index 149572b1594..5b3b7df82bb 100644
--- a/sys/arch/mips64/include/fenv.h
+++ b/sys/arch/mips64/include/fenv.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: fenv.h,v 1.1 2011/04/26 21:14:07 martynas Exp $ */
+/* $OpenBSD: fenv.h,v 1.2 2011/04/28 17:34:23 martynas Exp $ */
/*
* Copyright (c) 2011 Martynas Venckus <martynas@openbsd.org>
@@ -26,18 +26,19 @@
*
* We use such values that allow direct bitwise operations on FPU registers.
*/
-#define FE_INEXACT 0x04
-#define FE_UNDERFLOW 0x08
-#define FE_OVERFLOW 0x10
-#define FE_DIVBYZERO 0x20
-#define FE_INVALID 0x40
+#define FE_INEXACT 0x04
+#define FE_UNDERFLOW 0x08
+#define FE_OVERFLOW 0x10
+#define FE_DIVBYZERO 0x20
+#define FE_INVALID 0x40
/*
* The following symbol is simply the bitwise-inclusive OR of all floating-point
* exception constants defined above.
*/
-#define FE_ALL_EXCEPT \
- (FE_DIVBYZERO | FE_INEXACT | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
+#define FE_ALL_EXCEPT (FE_INEXACT | FE_UNDERFLOW | FE_OVERFLOW | \
+ FE_DIVBYZERO | FE_INVALID)
+#define _MASK_SHIFT 5
/*
* Each symbol representing the rounding direction, expands to an integer
@@ -51,19 +52,28 @@
#define FE_DOWNWARD 0x3
/*
- * FPSCR encodes rounding modes by bits 0-1.
- * FPSCR flags and exception mask shifts by 5.
+ * The following symbol is simply the bitwise-inclusive OR of all floating-point
+ * rounding direction constants defined above.
*/
-#define _ROUND_MASK 0x3
-#define _EMASK_SHIFT 5
+#define _ROUND_MASK (FE_TONEAREST | FE_TOWARDZERO | FE_UPWARD | \
+ FE_DOWNWARD)
/*
- * fenv_t represents the entire floating-point environment
+ * fenv_t represents the entire floating-point environment.
*/
-typedef unsigned int fenv_t;
+typedef unsigned int fenv_t;
-extern fenv_t __fe_dfl_env;
-#define FE_DFL_ENV ((const fenv_t *) &__fe_dfl_env)
+/*
+ * The following constant represents the default floating-point environment
+ * (that is, the one installed at program startup) and has type pointer to
+ * const-qualified fenv_t.
+ *
+ * It can be used as an argument to the functions within the <fenv.h> header
+ * that manage the floating-point environment, namely fesetenv() and
+ * feupdateenv().
+ */
+extern fenv_t __fe_dfl_env;
+#define FE_DFL_ENV ((const fenv_t *)&__fe_dfl_env)
/*
* fexcept_t represents the floating-point status flags collectively, including
@@ -77,6 +87,6 @@ extern fenv_t __fe_dfl_env;
* A floating-point control mode is a system variable whose value may be set by
* the user to affect the subsequent behavior of floating-point arithmetic.
*/
-typedef unsigned int fexcept_t;
+typedef unsigned int fexcept_t;
-#endif /* ! _MIPS64_FENV_H_ */
+#endif /* !_MIPS64_FENV_H_ */
diff --git a/sys/arch/powerpc/include/fenv.h b/sys/arch/powerpc/include/fenv.h
index a09f5bbf7ce..df2ab25c00b 100644
--- a/sys/arch/powerpc/include/fenv.h
+++ b/sys/arch/powerpc/include/fenv.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: fenv.h,v 1.1 2011/04/25 20:34:09 martynas Exp $ */
+/* $OpenBSD: fenv.h,v 1.2 2011/04/28 17:34:23 martynas Exp $ */
/*
* Copyright (c) 2011 Martynas Venckus <martynas@openbsd.org>
@@ -38,8 +38,9 @@
* The following symbol is simply the bitwise-inclusive OR of all floating-point
* exception constants defined above.
*/
-#define FE_ALL_EXCEPT \
- (FE_DIVBYZERO | FE_INEXACT | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
+#define FE_ALL_EXCEPT (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | \
+ FE_OVERFLOW | FE_INVALID)
+#define _MASK_SHIFT 22
/*
* Each symbol representing the rounding direction, expands to an integer
@@ -53,19 +54,28 @@
#define FE_DOWNWARD 0x3
/*
- * FPSCR encodes rounding modes by bits 0-1.
- * FPSCR flags and exception mask shifts by 22.
+ * The following symbol is simply the bitwise-inclusive OR of all floating-point
+ * rounding direction constants defined above.
*/
-#define _ROUND_MASK 0x3
-#define _EMASK_SHIFT 22
+#define _ROUND_MASK (FE_TONEAREST | FE_TOWARDZERO | FE_UPWARD | \
+ FE_DOWNWARD)
/*
- * fenv_t represents the entire floating-point environment
+ * fenv_t represents the entire floating-point environment.
*/
-typedef unsigned int fenv_t;
+typedef unsigned int fenv_t;
-extern fenv_t __fe_dfl_env;
-#define FE_DFL_ENV ((const fenv_t *) &__fe_dfl_env)
+/*
+ * The following constant represents the default floating-point environment
+ * (that is, the one installed at program startup) and has type pointer to
+ * const-qualified fenv_t.
+ *
+ * It can be used as an argument to the functions within the <fenv.h> header
+ * that manage the floating-point environment, namely fesetenv() and
+ * feupdateenv().
+ */
+extern fenv_t __fe_dfl_env;
+#define FE_DFL_ENV ((const fenv_t *)&__fe_dfl_env)
/*
* fexcept_t represents the floating-point status flags collectively, including
@@ -79,6 +89,6 @@ extern fenv_t __fe_dfl_env;
* A floating-point control mode is a system variable whose value may be set by
* the user to affect the subsequent behavior of floating-point arithmetic.
*/
-typedef unsigned int fexcept_t;
+typedef unsigned int fexcept_t;
-#endif /* ! _POWERPC_FENV_H_ */
+#endif /* !_POWERPC_FENV_H_ */
diff --git a/sys/arch/sh/include/fenv.h b/sys/arch/sh/include/fenv.h
index 4b66fee051f..e07aae472f0 100644
--- a/sys/arch/sh/include/fenv.h
+++ b/sys/arch/sh/include/fenv.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: fenv.h,v 1.1 2011/04/24 15:05:12 martynas Exp $ */
+/* $OpenBSD: fenv.h,v 1.2 2011/04/28 17:34:23 martynas Exp $ */
/*
* Copyright (c) 2011 Martynas Venckus <martynas@openbsd.org>
@@ -36,8 +36,9 @@
* The following symbol is simply the bitwise-inclusive OR of all floating-point
* exception constants defined above.
*/
-#define FE_ALL_EXCEPT \
- (FE_DIVBYZERO | FE_INEXACT | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
+#define FE_ALL_EXCEPT (FE_INEXACT | FE_UNDERFLOW | FE_OVERFLOW | \
+ FE_DIVBYZERO | FE_INVALID)
+#define _MASK_SHIFT 5
/*
* Each symbol representing the rounding direction, expands to an integer
@@ -51,19 +52,28 @@
#define FE_DOWNWARD 0x3
/*
- * FPSCR encodes rounding modes by bits 0-1.
- * FPSCR flags and exception mask shifts by 5.
+ * The following symbol is simply the bitwise-inclusive OR of all floating-point
+ * rounding direction constants defined above.
*/
-#define _ROUND_MASK 0x3
-#define _EMASK_SHIFT 5
+#define _ROUND_MASK (FE_TONEAREST | FE_TOWARDZERO | FE_UPWARD | \
+ FE_DOWNWARD)
/*
- * fenv_t represents the entire floating-point environment
+ * fenv_t represents the entire floating-point environment.
*/
-typedef unsigned int fenv_t;
+typedef unsigned int fenv_t;
-extern fenv_t __fe_dfl_env;
-#define FE_DFL_ENV ((const fenv_t *) &__fe_dfl_env)
+/*
+ * The following constant represents the default floating-point environment
+ * (that is, the one installed at program startup) and has type pointer to
+ * const-qualified fenv_t.
+ *
+ * It can be used as an argument to the functions within the <fenv.h> header
+ * that manage the floating-point environment, namely fesetenv() and
+ * feupdateenv().
+ */
+extern fenv_t __fe_dfl_env;
+#define FE_DFL_ENV ((const fenv_t *)&__fe_dfl_env)
/*
* fexcept_t represents the floating-point status flags collectively, including
@@ -77,6 +87,6 @@ extern fenv_t __fe_dfl_env;
* A floating-point control mode is a system variable whose value may be set by
* the user to affect the subsequent behavior of floating-point arithmetic.
*/
-typedef unsigned int fexcept_t;
+typedef unsigned int fexcept_t;
-#endif /* ! _SH_FENV_H_ */
+#endif /* !_SH_FENV_H_ */
diff --git a/sys/arch/sparc/include/fenv.h b/sys/arch/sparc/include/fenv.h
index ecde9342f3e..7869d44c353 100644
--- a/sys/arch/sparc/include/fenv.h
+++ b/sys/arch/sparc/include/fenv.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: fenv.h,v 1.1 2011/04/25 21:04:29 martynas Exp $ */
+/* $OpenBSD: fenv.h,v 1.2 2011/04/28 17:34:23 martynas Exp $ */
/* $NetBSD: fenv.h,v 1.1.2.2 2011/02/08 16:19:41 bouyer Exp $ */
/*-
@@ -32,50 +32,75 @@
#ifndef _SPARC_FENV_H_
#define _SPARC_FENV_H_
-#include <sys/stdint.h>
-
-typedef unsigned long int fenv_t;
-typedef unsigned long int fexcept_t;
-
/*
- * Exception flags
+ * Each symbol representing a floating point exception expands to an integer
+ * constant expression with values, such that bitwise-inclusive ORs of _all
+ * combinations_ of the constants result in distinct values.
*
- * Symbols are defined in such a way, to correspond to the accrued
- * exception bits (aexc) fields of FSR.
+ * We use such values that allow direct bitwise operations on FPU registers.
*/
-#define FE_INEXACT 0x00000020 /* 0000100000 */
-#define FE_DIVBYZERO 0x00000040 /* 0001000000 */
-#define FE_UNDERFLOW 0x00000080 /* 0010000000 */
-#define FE_OVERFLOW 0x00000100 /* 0100000000 */
-#define FE_INVALID 0x00000200 /* 1000000000 */
+#define FE_INEXACT 0x020
+#define FE_DIVBYZERO 0x040
+#define FE_UNDERFLOW 0x080
+#define FE_OVERFLOW 0x100
+#define FE_INVALID 0x200
-#define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_INEXACT | \
- FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
+/*
+ * The following symbol is simply the bitwise-inclusive OR of all floating-point
+ * exception constants defined above.
+ */
+#define FE_ALL_EXCEPT (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | \
+ FE_OVERFLOW | FE_INVALID)
+#define _MASK_SHIFT 18
/*
- * Rounding modes
+ * Each symbol representing the rounding direction, expands to an integer
+ * constant expression whose value is distinct non-negative value.
*
- * We can't just use the hardware bit values here, because that would
- * make FE_UPWARD and FE_DOWNWARD negative, which is not allowed.
+ * We use such values that allow direct bitwise operations on FPU registers.
*/
-#define FE_TONEAREST 0x0
-#define FE_TOWARDZERO 0x1
-#define FE_UPWARD 0x2
-#define FE_DOWNWARD 0x3
-#define _ROUND_MASK (FE_TONEAREST | FE_DOWNWARD | \
- FE_UPWARD | FE_TOWARDZERO)
-#define _ROUND_SHIFT 30
+#define FE_TONEAREST 0x0
+#define FE_TOWARDZERO 0x1
+#define FE_UPWARD 0x2
+#define FE_DOWNWARD 0x3
-__BEGIN_DECLS
+/*
+ * The following symbol is simply the bitwise-inclusive OR of all floating-point
+ * rounding direction constants defined above.
+ */
+#define _ROUND_MASK (FE_TONEAREST | FE_TOWARDZERO | FE_UPWARD | \
+ FE_DOWNWARD)
+#define _ROUND_SHIFT 30
-/* Default floating-point environment */
-extern const fenv_t __fe_dfl_env;
-#define FE_DFL_ENV (&__fe_dfl_env)
+/*
+ * fenv_t represents the entire floating-point environment.
+ */
+typedef unsigned long fenv_t;
-/* We need to be able to map status flag positions to mask flag positions */
-#define _FPUSW_SHIFT 18
-#define _ENABLE_MASK (FE_ALL_EXCEPT << _FPUSW_SHIFT)
+/*
+ * The following constant represents the default floating-point environment
+ * (that is, the one installed at program startup) and has type pointer to
+ * const-qualified fenv_t.
+ *
+ * It can be used as an argument to the functions within the <fenv.h> header
+ * that manage the floating-point environment, namely fesetenv() and
+ * feupdateenv().
+ */
+extern fenv_t __fe_dfl_env;
+#define FE_DFL_ENV ((const fenv_t *)&__fe_dfl_env)
-__END_DECLS
+/*
+ * fexcept_t represents the floating-point status flags collectively, including
+ * any status the implementation associates with the flags.
+ *
+ * A floating-point status flag is a system variable whose value is set (but
+ * never cleared) when a floating-point exception is raised, which occurs as a
+ * side effect of exceptional floating-point arithmetic to provide auxiliary
+ * information.
+ *
+ * A floating-point control mode is a system variable whose value may be set by
+ * the user to affect the subsequent behavior of floating-point arithmetic.
+ */
+typedef unsigned long fexcept_t;
#endif /* !_SPARC_FENV_H_ */
diff --git a/sys/arch/sparc64/include/fenv.h b/sys/arch/sparc64/include/fenv.h
index efc95f987dd..882203e2cc6 100644
--- a/sys/arch/sparc64/include/fenv.h
+++ b/sys/arch/sparc64/include/fenv.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: fenv.h,v 1.2 2011/04/25 21:04:29 martynas Exp $ */
+/* $OpenBSD: fenv.h,v 1.3 2011/04/28 17:34:23 martynas Exp $ */
/* $NetBSD: fenv.h,v 1.1.2.2 2011/02/08 16:19:41 bouyer Exp $ */
/*-
@@ -32,50 +32,75 @@
#ifndef _SPARC64_FENV_H_
#define _SPARC64_FENV_H_
-#include <sys/stdint.h>
-
-typedef unsigned long int fenv_t;
-typedef unsigned long int fexcept_t;
-
/*
- * Exception flags
+ * Each symbol representing a floating point exception expands to an integer
+ * constant expression with values, such that bitwise-inclusive ORs of _all
+ * combinations_ of the constants result in distinct values.
*
- * Symbols are defined in such a way, to correspond to the accrued
- * exception bits (aexc) fields of FSR.
+ * We use such values that allow direct bitwise operations on FPU registers.
*/
-#define FE_INEXACT 0x00000020 /* 0000100000 */
-#define FE_DIVBYZERO 0x00000040 /* 0001000000 */
-#define FE_UNDERFLOW 0x00000080 /* 0010000000 */
-#define FE_OVERFLOW 0x00000100 /* 0100000000 */
-#define FE_INVALID 0x00000200 /* 1000000000 */
+#define FE_INEXACT 0x020
+#define FE_DIVBYZERO 0x040
+#define FE_UNDERFLOW 0x080
+#define FE_OVERFLOW 0x100
+#define FE_INVALID 0x200
-#define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_INEXACT | \
- FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
+/*
+ * The following symbol is simply the bitwise-inclusive OR of all floating-point
+ * exception constants defined above.
+ */
+#define FE_ALL_EXCEPT (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | \
+ FE_OVERFLOW | FE_INVALID)
+#define _MASK_SHIFT 18
/*
- * Rounding modes
+ * Each symbol representing the rounding direction, expands to an integer
+ * constant expression whose value is distinct non-negative value.
*
- * We can't just use the hardware bit values here, because that would
- * make FE_UPWARD and FE_DOWNWARD negative, which is not allowed.
+ * We use such values that allow direct bitwise operations on FPU registers.
*/
-#define FE_TONEAREST 0x0
-#define FE_TOWARDZERO 0x1
-#define FE_UPWARD 0x2
-#define FE_DOWNWARD 0x3
-#define _ROUND_MASK (FE_TONEAREST | FE_DOWNWARD | \
- FE_UPWARD | FE_TOWARDZERO)
-#define _ROUND_SHIFT 30
+#define FE_TONEAREST 0x0
+#define FE_TOWARDZERO 0x1
+#define FE_UPWARD 0x2
+#define FE_DOWNWARD 0x3
-__BEGIN_DECLS
+/*
+ * The following symbol is simply the bitwise-inclusive OR of all floating-point
+ * rounding direction constants defined above.
+ */
+#define _ROUND_MASK (FE_TONEAREST | FE_TOWARDZERO | FE_UPWARD | \
+ FE_DOWNWARD)
+#define _ROUND_SHIFT 30
-/* Default floating-point environment */
-extern const fenv_t __fe_dfl_env;
-#define FE_DFL_ENV (&__fe_dfl_env)
+/*
+ * fenv_t represents the entire floating-point environment.
+ */
+typedef unsigned long fenv_t;
-/* We need to be able to map status flag positions to mask flag positions */
-#define _FPUSW_SHIFT 18
-#define _ENABLE_MASK (FE_ALL_EXCEPT << _FPUSW_SHIFT)
+/*
+ * The following constant represents the default floating-point environment
+ * (that is, the one installed at program startup) and has type pointer to
+ * const-qualified fenv_t.
+ *
+ * It can be used as an argument to the functions within the <fenv.h> header
+ * that manage the floating-point environment, namely fesetenv() and
+ * feupdateenv().
+ */
+extern fenv_t __fe_dfl_env;
+#define FE_DFL_ENV ((const fenv_t *)&__fe_dfl_env)
-__END_DECLS
+/*
+ * fexcept_t represents the floating-point status flags collectively, including
+ * any status the implementation associates with the flags.
+ *
+ * A floating-point status flag is a system variable whose value is set (but
+ * never cleared) when a floating-point exception is raised, which occurs as a
+ * side effect of exceptional floating-point arithmetic to provide auxiliary
+ * information.
+ *
+ * A floating-point control mode is a system variable whose value may be set by
+ * the user to affect the subsequent behavior of floating-point arithmetic.
+ */
+typedef unsigned long fexcept_t;
#endif /* !_SPARC64_FENV_H_ */