aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/generic/math_private.h
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2018-02-01 20:54:44 +0000
committerJoseph Myers <joseph@codesourcery.com>2018-02-01 20:54:44 +0000
commitb1c347e2cd33a1a7f705de5c0876ba47c254a55c (patch)
treead9300c8c60fb77677d44fef1641e47705a5e8cb /sysdeps/generic/math_private.h
parentd23a4962bb35a38b86bccf9ab1d426e2531c250d (diff)
downloadglibc-b1c347e2cd33a1a7f705de5c0876ba47c254a55c.tar
glibc-b1c347e2cd33a1a7f705de5c0876ba47c254a55c.tar.gz
glibc-b1c347e2cd33a1a7f705de5c0876ba47c254a55c.tar.bz2
glibc-b1c347e2cd33a1a7f705de5c0876ba47c254a55c.zip
Move fenv.h override inline functions to generic math_private.h.
The tile version of math_private.h defines some inline functions for fenv.h functions, to optimize away internal calls to these functions that do nothing given no support for floating-point exceptions and rounding modes. (Some functions may have error cases for invalid arguments, but those aren't applicable to the internal calls from within glibc.) Other configurations lacking support for exceptions and rounding modes lack such inline functions. This patch moves them to the generic math_private.h, appropriately conditioned, so that all such configurations can benefit from the. include/fenv.h is made to check whether there are any non-default rounding modes; that needs to be done there, rather than later, because get-rounding-mode.h defines values for otherwise unsupported FE_* rounding modes. It also gives an error for FE_TONEAREST undefined, a case that already did not work for building the glibc testsuite; the convention has by now been established that all architectures need to provide a version of bits/fenv.h that at least defines FE_TONEAREST. Tested with build-many-glibcs.py. As expected, installed stripped shared libraries are unchanged for tile and for architectures supporting exceptions and rounding modes, but changed for non-tile architectures not supporting exceptions and rounding modes that previously lacked this optimization (e.g. Nios II libm.so is about 1kB smaller). The optimization is not in fact complete (does not cover feholdexcept / __feholdexcept, so a few calls to those remain unnecessarily within libm even after this patch), but that can be dealt with separately. * 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.
Diffstat (limited to 'sysdeps/generic/math_private.h')
-rw-r--r--sysdeps/generic/math_private.h68
1 files changed, 68 insertions, 0 deletions
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_ */