summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSzabolcs Nagy <nsz@port70.net>2015-03-07 11:00:37 +0100
committerRich Felker <dalias@aerifal.cx>2015-03-07 12:05:28 -0500
commit559de8f5f06da9022cbba70e22e14a710eb74513 (patch)
treef8980299d0f0a77f4a613c2fc58ada81b789aa66 /src
parentbd67959f3ad5049c35af0a0e2f8f1a1e60577a49 (diff)
downloadmusl-559de8f5f06da9022cbba70e22e14a710eb74513.tar.gz
musl-559de8f5f06da9022cbba70e22e14a710eb74513.tar.bz2
musl-559de8f5f06da9022cbba70e22e14a710eb74513.tar.xz
musl-559de8f5f06da9022cbba70e22e14a710eb74513.zip
fix FLT_ROUNDS to reflect the current rounding mode
Implemented as a wrapper around fegetround introducing a new function to the ABI: __flt_rounds. (fegetround cannot be used directly from float.h)
Diffstat (limited to 'src')
-rw-r--r--src/fenv/__flt_rounds.c19
1 files changed, 19 insertions, 0 deletions
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;
+}