summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arch/arm/bits/float.h1
-rw-r--r--arch/i386/bits/float.h1
-rw-r--r--arch/microblaze/bits/float.h1
-rw-r--r--arch/mips/bits/float.h1
-rw-r--r--arch/or1k/bits/float.h1
-rw-r--r--arch/powerpc/bits/float.h1
-rw-r--r--arch/sh/bits/float.h1
-rw-r--r--arch/x32/bits/float.h1
-rw-r--r--arch/x86_64/bits/float.h1
-rw-r--r--include/float.h3
-rw-r--r--src/fenv/__flt_rounds.c19
11 files changed, 22 insertions, 9 deletions
diff --git a/arch/arm/bits/float.h b/arch/arm/bits/float.h
index ec46b94b..c4a655e7 100644
--- a/arch/arm/bits/float.h
+++ b/arch/arm/bits/float.h
@@ -1,4 +1,3 @@
-#define FLT_ROUNDS 1
#define FLT_EVAL_METHOD 0
#define LDBL_TRUE_MIN 4.94065645841246544177e-324L
diff --git a/arch/i386/bits/float.h b/arch/i386/bits/float.h
index c356cba9..dd6e4029 100644
--- a/arch/i386/bits/float.h
+++ b/arch/i386/bits/float.h
@@ -1,4 +1,3 @@
-#define FLT_ROUNDS 1
#ifdef __FLT_EVAL_METHOD__
#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
#else
diff --git a/arch/microblaze/bits/float.h b/arch/microblaze/bits/float.h
index ec46b94b..c4a655e7 100644
--- a/arch/microblaze/bits/float.h
+++ b/arch/microblaze/bits/float.h
@@ -1,4 +1,3 @@
-#define FLT_ROUNDS 1
#define FLT_EVAL_METHOD 0
#define LDBL_TRUE_MIN 4.94065645841246544177e-324L
diff --git a/arch/mips/bits/float.h b/arch/mips/bits/float.h
index ec46b94b..c4a655e7 100644
--- a/arch/mips/bits/float.h
+++ b/arch/mips/bits/float.h
@@ -1,4 +1,3 @@
-#define FLT_ROUNDS 1
#define FLT_EVAL_METHOD 0
#define LDBL_TRUE_MIN 4.94065645841246544177e-324L
diff --git a/arch/or1k/bits/float.h b/arch/or1k/bits/float.h
index ec46b94b..c4a655e7 100644
--- a/arch/or1k/bits/float.h
+++ b/arch/or1k/bits/float.h
@@ -1,4 +1,3 @@
-#define FLT_ROUNDS 1
#define FLT_EVAL_METHOD 0
#define LDBL_TRUE_MIN 4.94065645841246544177e-324L
diff --git a/arch/powerpc/bits/float.h b/arch/powerpc/bits/float.h
index ec46b94b..c4a655e7 100644
--- a/arch/powerpc/bits/float.h
+++ b/arch/powerpc/bits/float.h
@@ -1,4 +1,3 @@
-#define FLT_ROUNDS 1
#define FLT_EVAL_METHOD 0
#define LDBL_TRUE_MIN 4.94065645841246544177e-324L
diff --git a/arch/sh/bits/float.h b/arch/sh/bits/float.h
index ec46b94b..c4a655e7 100644
--- a/arch/sh/bits/float.h
+++ b/arch/sh/bits/float.h
@@ -1,4 +1,3 @@
-#define FLT_ROUNDS 1
#define FLT_EVAL_METHOD 0
#define LDBL_TRUE_MIN 4.94065645841246544177e-324L
diff --git a/arch/x32/bits/float.h b/arch/x32/bits/float.h
index 9ea29914..4d8e7864 100644
--- a/arch/x32/bits/float.h
+++ b/arch/x32/bits/float.h
@@ -1,4 +1,3 @@
-#define FLT_ROUNDS 1
#ifdef __FLT_EVAL_METHOD__
#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
#else
diff --git a/arch/x86_64/bits/float.h b/arch/x86_64/bits/float.h
index 9ea29914..4d8e7864 100644
--- a/arch/x86_64/bits/float.h
+++ b/arch/x86_64/bits/float.h
@@ -1,4 +1,3 @@
-#define FLT_ROUNDS 1
#ifdef __FLT_EVAL_METHOD__
#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
#else
diff --git a/include/float.h b/include/float.h
index 161e167c..c6429d33 100644
--- a/include/float.h
+++ b/include/float.h
@@ -1,6 +1,9 @@
#ifndef _FLOAT_H
#define _FLOAT_H
+int __flt_rounds(void);
+#define FLT_ROUNDS (__flt_rounds())
+
#define FLT_RADIX 2
#define FLT_TRUE_MIN 1.40129846432481707092e-45F
diff --git a/src/fenv/__flt_rounds.c b/src/fenv/__flt_rounds.c
new file mode 100644
index 00000000..ec0b3689
--- /dev/null
+++ b/src/fenv/__flt_rounds.c
@@ -0,0 +1,19 @@
+#include <float.h>
+#include <fenv.h>
+
+int __flt_rounds()
+{
+ switch (fegetround()) {
+#ifdef FE_TOWARDZERO
+ case FE_TOWARDZERO: return 0;
+#endif
+ case FE_TONEAREST: return 1;
+#ifdef FE_UPWARD
+ case FE_UPWARD: return 2;
+#endif
+#ifdef FE_DOWNWARD
+ case FE_DOWNWARD: return 3;
+#endif
+ }
+ return -1;
+}