aboutsummaryrefslogtreecommitdiff
path: root/glibc
diff options
context:
space:
mode:
authorAndrew Waterman <waterman@cs.berkeley.edu>2015-11-19 13:37:39 -0800
committerAndrew Waterman <waterman@cs.berkeley.edu>2015-11-19 13:37:39 -0800
commita7d8d18df1ef192ae9fabfe0aab65e3b6403fa97 (patch)
tree68a1f937d50941f257a81d17bb6e2dd65b911a7f /glibc
parent3ac049faf64e794c8ae4153b041ed942af9178dd (diff)
downloadriscv-gnu-toolchain-a7d8d18df1ef192ae9fabfe0aab65e3b6403fa97.zip
riscv-gnu-toolchain-a7d8d18df1ef192ae9fabfe0aab65e3b6403fa97.tar.gz
riscv-gnu-toolchain-a7d8d18df1ef192ae9fabfe0aab65e3b6403fa97.tar.bz2
glibc: fix rounding mode bug
The FP exception flags were being interpreted as the rounding mode, causing printf to do weird things.
Diffstat (limited to 'glibc')
-rw-r--r--glibc/sysdeps/riscv/fpu_control.h14
-rw-r--r--glibc/sysdeps/riscv/get-rounding-mode.h38
2 files changed, 39 insertions, 13 deletions
diff --git a/glibc/sysdeps/riscv/fpu_control.h b/glibc/sysdeps/riscv/fpu_control.h
index cd52ff9..f69e3f3 100644
--- a/glibc/sysdeps/riscv/fpu_control.h
+++ b/glibc/sysdeps/riscv/fpu_control.h
@@ -39,20 +39,8 @@ extern fpu_control_t __fpu_control;
#else /* __riscv_soft_float */
-/* rounding control */
-#define _FPU_RC_NEAREST 0x0
-#define _FPU_RC_ZERO 0x1
-#define _FPU_RC_DOWN 0x2
-#define _FPU_RC_UP 0x3
-
-#define _FPU_RESERVED 0 /* No reserved bits in FSR */
-
-/* The fdlibm code requires strict IEEE double precision arithmetic,
- and no interrupts for exceptions, rounding to nearest. */
-
+#define _FPU_RESERVED 0
#define _FPU_DEFAULT 0
-
-/* IEEE: same as above */
#define _FPU_IEEE _FPU_DEFAULT
/* Type of the control word. */
diff --git a/glibc/sysdeps/riscv/get-rounding-mode.h b/glibc/sysdeps/riscv/get-rounding-mode.h
new file mode 100644
index 0000000..0e1cce3
--- /dev/null
+++ b/glibc/sysdeps/riscv/get-rounding-mode.h
@@ -0,0 +1,38 @@
+/* Determine floating-point rounding mode within libc. RISC-V version.
+
+ Copyright (C) 2015 Free Software Foundation, Inc.
+
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _RISCV_GET_ROUNDING_MODE_H
+#define _RISCV_GET_ROUNDING_MODE_H
+
+#include <fenv.h>
+#include <fpu_control.h>
+
+/* Return the floating-point rounding mode. */
+
+static inline int
+get_rounding_mode (void)
+{
+ fpu_control_t fpcr;
+
+ _FPU_GETROUND (fpcr);
+ return fpcr;
+}
+
+#endif /* get-rounding-mode.h */