aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog30
-rw-r--r--include/fenv.h15
-rw-r--r--sysdeps/generic/math_private.h68
-rw-r--r--sysdeps/tile/math_private.h15
4 files changed, 114 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 4a574f52c3..980c5cbaf3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,35 @@
2018-02-01 Joseph Myers <joseph@codesourcery.com>
+ * include/fenv.h [!_ISOMAC && !FE_TONEAREST]: Give #error.
+ [!_ISOMAC] (FE_HAVE_ROUNDING_MODES): New macro.
+ * sysdeps/generic/math_private.h
+ [!FE_HAVE_ROUNDING_MODES && FE_ALL_EXCEPT == 0] (fegetenv): New
+ inline function.
+ [!FE_HAVE_ROUNDING_MODES && FE_ALL_EXCEPT == 0] (__fegetenv):
+ Likewise.
+ [!FE_HAVE_ROUNDING_MODES && FE_ALL_EXCEPT == 0] (fesetenv):
+ Likewise.
+ [!FE_HAVE_ROUNDING_MODES && FE_ALL_EXCEPT == 0] (__fesetenv):
+ Likewise.
+ [!FE_HAVE_ROUNDING_MODES && FE_ALL_EXCEPT == 0] (feupdateenv):
+ Likewise.
+ [!FE_HAVE_ROUNDING_MODES && FE_ALL_EXCEPT == 0] (__feupdateenv):
+ Likewise.
+ [!FE_HAVE_ROUNDING_MODES] (fegetround): Likewise.
+ [!FE_HAVE_ROUNDING_MODES] (__fegetround): Likewise.
+ [!FE_HAVE_ROUNDING_MODES] (fesetround): Likewise.
+ [!FE_HAVE_ROUNDING_MODES] (__fesetround): Likewise.
+ * sysdeps/tile/math_private.h (fegetenv): Remove inline function.
+ (__fegetenv): Likewise.
+ (fesetenv): Likewise.
+ (__fesetenv): Likewise.
+ (feupdateenv): Likewise.
+ (__feupdateenv): Likewise.
+ (fegetround): Likewise.
+ (__fegetround): Likewise.
+ (fesetround): Likewise.
+ (__fesetround): Likewise.
+
* sysdeps/generic/math_private.h [FE_ALL_EXCEPT == 0]
(feraiseexcept): New macro.
[FE_ALL_EXCEPT == 0] (__feraiseexcept): Likewise.
diff --git a/include/fenv.h b/include/fenv.h
index de4d46f8b7..76679e1e18 100644
--- a/include/fenv.h
+++ b/include/fenv.h
@@ -42,6 +42,21 @@ struct rm_ctx
fenv_t env;
bool updated_status;
};
+
+/* Track whether rounding mode macros were defined, since
+ get-rounding-mode.h may define default versions if they weren't.
+ FE_TONEAREST must always be defined (even if no changes of rounding
+ mode are supported, glibc requires it to be defined to represent
+ the default rounding mode). */
+# ifndef FE_TONEAREST
+# error "FE_TONEAREST not defined"
+# endif
+# if defined FE_DOWNWARD || defined FE_TOWARDZERO || defined FE_UPWARD
+# define FE_HAVE_ROUNDING_MODES 1
+# else
+# define FE_HAVE_ROUNDING_MODES 0
+# endif
+
#endif
#endif
diff --git a/sysdeps/generic/math_private.h b/sysdeps/generic/math_private.h
index acfbd9b6cc..f93cf6927e 100644
--- a/sysdeps/generic/math_private.h
+++ b/sysdeps/generic/math_private.h
@@ -654,4 +654,72 @@ libc_feresetround_noex_ctx (struct rm_ctx *ctx)
# define __feraiseexcept(excepts) ((void) 0)
#endif
+/* Similarly, most <fenv.h> functions have trivial implementations in
+ the absence of support for floating-point exceptions and rounding
+ modes. */
+
+#if !FE_HAVE_ROUNDING_MODES
+# if FE_ALL_EXCEPT == 0
+extern inline int
+fegetenv (fenv_t *__e)
+{
+ return 0;
+}
+
+extern inline int
+__fegetenv (fenv_t *__e)
+{
+ return 0;
+}
+
+extern inline int
+fesetenv (const fenv_t *__e)
+{
+ return 0;
+}
+
+extern inline int
+__fesetenv (const fenv_t *__e)
+{
+ return 0;
+}
+
+extern inline int
+feupdateenv (const fenv_t *__e)
+{
+ return 0;
+}
+
+extern inline int
+__feupdateenv (const fenv_t *__e)
+{
+ return 0;
+}
+# endif
+
+extern inline int
+fegetround (void)
+{
+ return FE_TONEAREST;
+}
+
+extern inline int
+__fegetround (void)
+{
+ return FE_TONEAREST;
+}
+
+extern inline int
+fesetround (int __d)
+{
+ return 0;
+}
+
+extern inline int
+__fesetround (int __d)
+{
+ return 0;
+}
+#endif
+
#endif /* _MATH_PRIVATE_H_ */
diff --git a/sysdeps/tile/math_private.h b/sysdeps/tile/math_private.h
index 6dc43f4228..32b549ff4e 100644
--- a/sysdeps/tile/math_private.h
+++ b/sysdeps/tile/math_private.h
@@ -15,9 +15,7 @@
success in every case.
The overrides for libc_ functions must happen before we include
- the generic math_private.h, and the overrides for regular
- <fenv.h> functions must happen afterwards, to avoid clashing with
- the declarations of those functions. */
+ the generic math_private.h. */
#define libc_fesetround(rnd) ({ 0; })
#define libc_fetestexcept(exc) ({ 0; })
@@ -26,15 +24,4 @@
#include_next <math_private.h>
-extern inline int fegetenv (fenv_t *__e) { return 0; }
-extern inline int __fegetenv (fenv_t *__e) { return 0; }
-extern inline int fesetenv (const fenv_t *__e) { return 0; }
-extern inline int __fesetenv (const fenv_t *__e) { return 0; }
-extern inline int feupdateenv (const fenv_t *__e) { return 0; }
-extern inline int __feupdateenv (const fenv_t *__e) { return 0; }
-extern inline int fegetround (void) { return FE_TONEAREST; }
-extern inline int __fegetround (void) { return FE_TONEAREST; }
-extern inline int fesetround (int __d) { return 0; }
-extern inline int __fesetround (int __d) { return 0; }
-
#endif