From 0747f818110fa70323aed53fd7b50587adcbf64f Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Tue, 30 Dec 2014 17:08:09 +0000 Subject: Fix libm feraiseexcept namespace (bug 17723). Various C90 and UNIX98 libm functions call feraiseexcept, which is not in those standards. This causes linknamespace test failures - except on x86 / x86_64, where feraiseexcept is inline (for the relevant constant arguments) in bits/fenv.h. This patch fixes this by making those functions call __feraiseexcept instead. All changes are applied to all architectures rather than considering the possibility that some might not be needed in some cases (e.g. x86) as it seems most maintainable to keep architectures consistent. Where __feraiseexcept does not exist, it is added, with feraiseexcept made a weak alias; where it is a strong alias, it is made weak. libm_hidden_def / libm_hidden_proto are used with __feraiseexcept (this might in some cases improve code generation for existing calls to __feraiseexcept in some code on some architectures). Where there are dummy feraiseexcept macros (on architectures without floating-point exceptions support, to avoid compile errors from references to undefined FE_* macros), corresponding dummy __feraiseexcept macros are added. And on x86, to ensure __feraiseexcept calls still get inlined, the inline function in bits/fenv.h is refactored so that most of it can be reused in an inline __feraiseexcept in a separate include/bits/fenv.h. Calls are changed in C90/UNIX98 functions, but generally not in functions missing from those standards. They are also changed in libc_fe* functions (on the basis that those might be used in any libm function), and in feupdateenv (on the same basis - may be used, via default libc_*, in any libm function - of course feupdateenv will need changing to __feupdateenv in a subsequent patch to make that fully namespace-clean). No __feraiseexcept is added corresponding to the feraiseexcept in powerpc bits/fenvinline.h, because that macro definition is conditional on !defined __NO_MATH_INLINES, and glibc libm is built with -D__NO_MATH_INLINES, so changing internal calls to use __feraiseexcept should make no difference. Tested for x86_64 (testsuite; the only change in disassembly of installed shared libraries is a slight code reordering in clog10, of no apparent significance). Also tested for MIPS, where (in the configuration tested) it eliminates math.h linknamespace failures for n32 and n64 (some for o32 remain because of other issues). [BZ #17723] * include/fenv.h (__feraiseexcept): Use libm_hidden_proto. * math/fraiseexcpt.c (__feraiseexcept): Use libm_hidden_def. * sysdeps/aarch64/fpu/fraiseexcpt.c (feraiseexcept): Rename to __feraiseexcept and define as weak alias of __feraiseexcept. Use libm_hidden_weak. * sysdeps/arm/fraiseexcpt.c (feraiseexcept): Likewise. * sysdeps/hppa/fpu/fraiseexcpt.c (feraiseexcept): Likewise. * sysdeps/i386/fpu/fraiseexcpt.c (__feraiseexcept): Use libm_hidden_def. * sysdeps/ia64/fpu/fraiseexcpt.c (feraiseexcept): Rename to __feraiseexcept and define as weak alias of __feraiseexcept. Use libm_hidden_weak. * sysdeps/m68k/coldfire/fpu/fraiseexcpt.c (feraiseexcept): Likewise. * sysdeps/microblaze/math_private.h (__feraiseexcept): New macro. * sysdeps/mips/fpu/fraiseexcpt.c (feraiseexcept): Rename to __feraiseexcept and define as weak alias of __feraiseexcept. Use libm_hidden_weak. * sysdeps/powerpc/fpu/fraiseexcpt.c (__feraiseexcept): Use libm_hidden_def. * sysdeps/powerpc/nofpu/fraiseexcpt.c (__feraiseexcept): Likewise. * sysdeps/powerpc/powerpc32/e500/nofpu/fraiseexcpt.c (__feraiseexcept): Likewise. * sysdeps/s390/fpu/fraiseexcpt.c (feraiseexcept): Rename to __feraiseexcept and define as weak alias of __feraiseexcept. Use libm_hidden_weak. * sysdeps/sh/sh4/fpu/fraiseexcpt.c (feraiseexcept): Likewise. * sysdeps/sparc/fpu/fraiseexcpt.c (__feraiseexcept): Use libm_hidden_def. * sysdeps/tile/math_private.h (__feraiseexcept): New macro. * sysdeps/unix/sysv/linux/alpha/fraiseexcpt.S (__feraiseexcept): Use libm_hidden_def. * sysdeps/x86_64/fpu/fraiseexcpt.c (__feraiseexcept): Use libm_hidden_def. (feraiseexcept): Define as weak not strong alias. Use libm_hidden_weak. * sysdeps/x86/fpu/bits/fenv.h (__feraiseexcept_invalid_divbyzero): New inline function. Factored out of ... (feraiseexcept): ... here. Use __feraiseexcept_invalid_divbyzero. * sysdeps/x86/fpu/include/bits/fenv.h: New file. * math/e_scalb.c (invalid_fn): Call __feraiseexcept instead of feraiseexcept. * math/w_acos.c (__acos): Likewise. * math/w_asin.c (__asin): Likewise. * math/w_ilogb.c (__ilogb): Likewise. * math/w_j0.c (y0): Likewise. * math/w_j1.c (y1): Likewise. * math/w_jn.c (yn): Likewise. * math/w_log.c (__log): Likewise. * math/w_log10.c (__log10): Likewise. * sysdeps/aarch64/fpu/feupdateenv.c (feupdateenv): Likewise. * sysdeps/aarch64/fpu/math_private.h (libc_feupdateenv_test_aarch64): Likewise. * sysdeps/alpha/fpu/feupdateenv.c (__feupdateenv): Likewise. * sysdeps/arm/fenv_private.h (libc_feupdateenv_test_vfp): Likewise. * sysdeps/arm/feupdateenv.c (feupdateenv): Likewise. * sysdeps/ia64/fpu/feupdateenv.c (feupdateenv): Likewise. * sysdeps/m68k/fpu/feupdateenv.c (__feupdateenv): Likewise. * sysdeps/mips/fpu/feupdateenv.c (feupdateenv): Likewise. * sysdeps/powerpc/fpu/e_sqrt.c (__slow_ieee754_sqrt): Likewise. * sysdeps/s390/fpu/feupdateenv.c (feupdateenv): Likewise. * sysdeps/sh/sh4/fpu/feupdateenv.c (feupdateenv): Likewise. * sysdeps/sparc/fpu/feupdateenv.c (__feupdateenv): Likewise. --- ChangeLog | 67 ++++++++++++++++++++++ NEWS | 2 +- include/fenv.h | 1 + math/e_scalb.c | 2 +- math/fraiseexcpt.c | 1 + math/w_acos.c | 2 +- math/w_asin.c | 2 +- math/w_ilogb.c | 2 +- math/w_j0.c | 4 +- math/w_j1.c | 4 +- math/w_jn.c | 4 +- math/w_log.c | 4 +- math/w_log10.c | 4 +- sysdeps/aarch64/fpu/feupdateenv.c | 4 +- sysdeps/aarch64/fpu/fraiseexcpt.c | 6 +- sysdeps/aarch64/fpu/math_private.h | 2 +- sysdeps/alpha/fpu/feupdateenv.c | 2 +- sysdeps/arm/fenv_private.h | 2 +- sysdeps/arm/feupdateenv.c | 4 +- sysdeps/arm/fraiseexcpt.c | 6 +- sysdeps/hppa/fpu/fraiseexcpt.c | 6 +- sysdeps/i386/fpu/fraiseexcpt.c | 1 + sysdeps/ia64/fpu/feupdateenv.c | 2 +- sysdeps/ia64/fpu/fraiseexcpt.c | 6 +- sysdeps/m68k/coldfire/fpu/fraiseexcpt.c | 6 +- sysdeps/m68k/fpu/feupdateenv.c | 2 +- sysdeps/microblaze/math_private.h | 1 + sysdeps/mips/fpu/feupdateenv.c | 2 +- sysdeps/mips/fpu/fraiseexcpt.c | 6 +- sysdeps/powerpc/fpu/e_sqrt.c | 4 +- sysdeps/powerpc/fpu/fraiseexcpt.c | 1 + sysdeps/powerpc/nofpu/fraiseexcpt.c | 1 + sysdeps/powerpc/powerpc32/e500/nofpu/fraiseexcpt.c | 1 + sysdeps/s390/fpu/feupdateenv.c | 2 +- sysdeps/s390/fpu/fraiseexcpt.c | 6 +- sysdeps/sh/sh4/fpu/feupdateenv.c | 2 +- sysdeps/sh/sh4/fpu/fraiseexcpt.c | 6 +- sysdeps/sparc/fpu/feupdateenv.c | 2 +- sysdeps/sparc/fpu/fraiseexcpt.c | 1 + sysdeps/tile/math_private.h | 1 + sysdeps/unix/sysv/linux/alpha/fraiseexcpt.S | 1 + sysdeps/x86/fpu/bits/fenv.h | 50 ++++++++-------- sysdeps/x86/fpu/include/bits/fenv.h | 42 ++++++++++++++ sysdeps/x86_64/fpu/fraiseexcpt.c | 5 +- 44 files changed, 211 insertions(+), 71 deletions(-) create mode 100644 sysdeps/x86/fpu/include/bits/fenv.h diff --git a/ChangeLog b/ChangeLog index ce76c8d819..5780c3a7f0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,70 @@ +2014-12-30 Joseph Myers + + [BZ #17723] + * include/fenv.h (__feraiseexcept): Use libm_hidden_proto. + * math/fraiseexcpt.c (__feraiseexcept): Use libm_hidden_def. + * sysdeps/aarch64/fpu/fraiseexcpt.c (feraiseexcept): Rename to + __feraiseexcept and define as weak alias of __feraiseexcept. Use + libm_hidden_weak. + * sysdeps/arm/fraiseexcpt.c (feraiseexcept): Likewise. + * sysdeps/hppa/fpu/fraiseexcpt.c (feraiseexcept): Likewise. + * sysdeps/i386/fpu/fraiseexcpt.c (__feraiseexcept): Use + libm_hidden_def. + * sysdeps/ia64/fpu/fraiseexcpt.c (feraiseexcept): Rename to + __feraiseexcept and define as weak alias of __feraiseexcept. Use + libm_hidden_weak. + * sysdeps/m68k/coldfire/fpu/fraiseexcpt.c (feraiseexcept): + Likewise. + * sysdeps/microblaze/math_private.h (__feraiseexcept): New macro. + * sysdeps/mips/fpu/fraiseexcpt.c (feraiseexcept): Rename to + __feraiseexcept and define as weak alias of __feraiseexcept. Use + libm_hidden_weak. + * sysdeps/powerpc/fpu/fraiseexcpt.c (__feraiseexcept): Use + libm_hidden_def. + * sysdeps/powerpc/nofpu/fraiseexcpt.c (__feraiseexcept): Likewise. + * sysdeps/powerpc/powerpc32/e500/nofpu/fraiseexcpt.c + (__feraiseexcept): Likewise. + * sysdeps/s390/fpu/fraiseexcpt.c (feraiseexcept): Rename to + __feraiseexcept and define as weak alias of __feraiseexcept. Use + libm_hidden_weak. + * sysdeps/sh/sh4/fpu/fraiseexcpt.c (feraiseexcept): Likewise. + * sysdeps/sparc/fpu/fraiseexcpt.c (__feraiseexcept): Use + libm_hidden_def. + * sysdeps/tile/math_private.h (__feraiseexcept): New macro. + * sysdeps/unix/sysv/linux/alpha/fraiseexcpt.S (__feraiseexcept): + Use libm_hidden_def. + * sysdeps/x86_64/fpu/fraiseexcpt.c (__feraiseexcept): Use + libm_hidden_def. + (feraiseexcept): Define as weak not strong alias. Use + libm_hidden_weak. + * sysdeps/x86/fpu/bits/fenv.h (__feraiseexcept_invalid_divbyzero): + New inline function. Factored out of ... + (feraiseexcept): ... here. Use __feraiseexcept_invalid_divbyzero. + * sysdeps/x86/fpu/include/bits/fenv.h: New file. + * math/e_scalb.c (invalid_fn): Call __feraiseexcept instead of + feraiseexcept. + * math/w_acos.c (__acos): Likewise. + * math/w_asin.c (__asin): Likewise. + * math/w_ilogb.c (__ilogb): Likewise. + * math/w_j0.c (y0): Likewise. + * math/w_j1.c (y1): Likewise. + * math/w_jn.c (yn): Likewise. + * math/w_log.c (__log): Likewise. + * math/w_log10.c (__log10): Likewise. + * sysdeps/aarch64/fpu/feupdateenv.c (feupdateenv): Likewise. + * sysdeps/aarch64/fpu/math_private.h + (libc_feupdateenv_test_aarch64): Likewise. + * sysdeps/alpha/fpu/feupdateenv.c (__feupdateenv): Likewise. + * sysdeps/arm/fenv_private.h (libc_feupdateenv_test_vfp): Likewise. + * sysdeps/arm/feupdateenv.c (feupdateenv): Likewise. + * sysdeps/ia64/fpu/feupdateenv.c (feupdateenv): Likewise. + * sysdeps/m68k/fpu/feupdateenv.c (__feupdateenv): Likewise. + * sysdeps/mips/fpu/feupdateenv.c (feupdateenv): Likewise. + * sysdeps/powerpc/fpu/e_sqrt.c (__slow_ieee754_sqrt): Likewise. + * sysdeps/s390/fpu/feupdateenv.c (feupdateenv): Likewise. + * sysdeps/sh/sh4/fpu/feupdateenv.c (feupdateenv): Likewise. + * sysdeps/sparc/fpu/feupdateenv.c (__feupdateenv): Likewise. + 2014-12-30 H.J. Lu [BZ #17732] diff --git a/NEWS b/NEWS index 0db6dbf029..23b1cd7c13 100644 --- a/NEWS +++ b/NEWS @@ -15,7 +15,7 @@ Version 2.21 17522, 17555, 17570, 17571, 17572, 17573, 17574, 17581, 17582, 17583, 17584, 17585, 17589, 17594, 17601, 17608, 17616, 17625, 17630, 17633, 17634, 17647, 17653, 17657, 17664, 17665, 17668, 17682, 17717, 17719, - 17722, 17724, 17725, 17732, 17733, 17744, 17745, 17746, 17747. + 17722, 17723, 17724, 17725, 17732, 17733, 17744, 17745, 17746, 17747. * CVE-2104-7817 The wordexp function could ignore the WRDE_NOCMD flag under certain input conditions resulting in the execution of a shell for diff --git a/include/fenv.h b/include/fenv.h index bd2c99db96..0cfbacd4ab 100644 --- a/include/fenv.h +++ b/include/fenv.h @@ -15,6 +15,7 @@ extern int __fesetenv (const fenv_t *__envp); extern int __feupdateenv (const fenv_t *__envp); libm_hidden_proto (feraiseexcept) +libm_hidden_proto (__feraiseexcept) libm_hidden_proto (fegetenv) libm_hidden_proto (fegetround) libm_hidden_proto (fesetenv) diff --git a/math/e_scalb.c b/math/e_scalb.c index 146d49e1c3..d315d57681 100644 --- a/math/e_scalb.c +++ b/math/e_scalb.c @@ -27,7 +27,7 @@ invalid_fn (double x, double fn) { if (__rint (fn) != fn) { - feraiseexcept (FE_INVALID); + __feraiseexcept (FE_INVALID); return __nan (""); } else if (fn > 65000.0) diff --git a/math/fraiseexcpt.c b/math/fraiseexcpt.c index 8809af997d..05caf0d187 100644 --- a/math/fraiseexcpt.c +++ b/math/fraiseexcpt.c @@ -30,6 +30,7 @@ __feraiseexcept (int excepts) strong_alias (__feraiseexcept, __old_feraiseexcept) compat_symbol (libm, __old_feraiseexcept, feraiseexcept, GLIBC_2_1); #endif +libm_hidden_def (__feraiseexcept) libm_hidden_ver (__feraiseexcept, feraiseexcept) versioned_symbol (libm, __feraiseexcept, feraiseexcept, GLIBC_2_2); diff --git a/math/w_acos.c b/math/w_acos.c index bb641092f0..e5e79dd2e0 100644 --- a/math/w_acos.c +++ b/math/w_acos.c @@ -29,7 +29,7 @@ __acos (double x) && _LIB_VERSION != _IEEE_) { /* acos(|x|>1) */ - feraiseexcept (FE_INVALID); + __feraiseexcept (FE_INVALID); return __kernel_standard (x, x, 1); } diff --git a/math/w_asin.c b/math/w_asin.c index 9bf9374ec8..2b744467cd 100644 --- a/math/w_asin.c +++ b/math/w_asin.c @@ -29,7 +29,7 @@ __asin (double x) && _LIB_VERSION != _IEEE_) { /* asin(|x|>1) */ - feraiseexcept (FE_INVALID); + __feraiseexcept (FE_INVALID); return __kernel_standard (x, x, 2); } diff --git a/math/w_ilogb.c b/math/w_ilogb.c index 9c0e264483..b2b3108a63 100644 --- a/math/w_ilogb.c +++ b/math/w_ilogb.c @@ -31,7 +31,7 @@ __ilogb (double x) || __builtin_expect (r == INT_MAX, 0)) { __set_errno (EDOM); - feraiseexcept (FE_INVALID); + __feraiseexcept (FE_INVALID); } return r; } diff --git a/math/w_j0.c b/math/w_j0.c index 92a834542a..1ed8c26f1c 100644 --- a/math/w_j0.c +++ b/math/w_j0.c @@ -47,13 +47,13 @@ y0 (double x) if (x < 0.0) { /* d = zero/(x-x) */ - feraiseexcept (FE_INVALID); + __feraiseexcept (FE_INVALID); return __kernel_standard (x, x, 9); } else if (x == 0.0) { /* d = -one/(x-x) */ - feraiseexcept (FE_DIVBYZERO); + __feraiseexcept (FE_DIVBYZERO); return __kernel_standard (x, x, 8); } else if (_LIB_VERSION != _POSIX_) diff --git a/math/w_j1.c b/math/w_j1.c index 37c6d1f4b5..63bac83389 100644 --- a/math/w_j1.c +++ b/math/w_j1.c @@ -47,13 +47,13 @@ y1 (double x) if (x < 0.0) { /* d = zero/(x-x) */ - feraiseexcept (FE_INVALID); + __feraiseexcept (FE_INVALID); return __kernel_standard (x, x, 11); } else if (x == 0.0) { /* d = -one/(x-x) */ - feraiseexcept (FE_DIVBYZERO); + __feraiseexcept (FE_DIVBYZERO); return __kernel_standard (x, x, 10); } else if (_LIB_VERSION != _POSIX_) diff --git a/math/w_jn.c b/math/w_jn.c index 56bd280b1e..fdd2dc70e8 100644 --- a/math/w_jn.c +++ b/math/w_jn.c @@ -47,13 +47,13 @@ yn (int n, double x) if (x < 0.0) { /* d = zero/(x-x) */ - feraiseexcept (FE_INVALID); + __feraiseexcept (FE_INVALID); return __kernel_standard (n, x, 13); } else if (x == 0.0) { /* d = -one/(x-x) */ - feraiseexcept (FE_DIVBYZERO); + __feraiseexcept (FE_DIVBYZERO); return __kernel_standard (n, x, 12); } else if (_LIB_VERSION != _POSIX_) diff --git a/math/w_log.c b/math/w_log.c index 8c90052094..4383e500b3 100644 --- a/math/w_log.c +++ b/math/w_log.c @@ -29,12 +29,12 @@ __log (double x) { if (x == 0.0) { - feraiseexcept (FE_DIVBYZERO); + __feraiseexcept (FE_DIVBYZERO); return __kernel_standard (x, x, 16); /* log(0) */ } else { - feraiseexcept (FE_INVALID); + __feraiseexcept (FE_INVALID); return __kernel_standard (x, x, 17); /* log(x<0) */ } } diff --git a/math/w_log10.c b/math/w_log10.c index 472d2a146d..a0a1843ba6 100644 --- a/math/w_log10.c +++ b/math/w_log10.c @@ -29,12 +29,12 @@ __log10 (double x) { if (x == 0.0) { - feraiseexcept (FE_DIVBYZERO); + __feraiseexcept (FE_DIVBYZERO); return __kernel_standard (x, x, 18); /* log10(0) */ } else { - feraiseexcept (FE_INVALID); + __feraiseexcept (FE_INVALID); return __kernel_standard (x, x, 19); /* log10(x<0) */ } } diff --git a/sysdeps/aarch64/fpu/feupdateenv.c b/sysdeps/aarch64/fpu/feupdateenv.c index ac2f6fe7f8..3c675c3a4e 100644 --- a/sysdeps/aarch64/fpu/feupdateenv.c +++ b/sysdeps/aarch64/fpu/feupdateenv.c @@ -45,7 +45,7 @@ feupdateenv (const fenv_t *envp) _FPU_SETFPSR (fpsr_new); if (excepts & (fpcr_new >> FE_EXCEPT_SHIFT)) - return feraiseexcept (excepts); + return __feraiseexcept (excepts); return 0; } @@ -80,7 +80,7 @@ feupdateenv (const fenv_t *envp) } if (excepts & (fpcr_new >> FE_EXCEPT_SHIFT)) - return feraiseexcept (excepts); + return __feraiseexcept (excepts); return 0; } diff --git a/sysdeps/aarch64/fpu/fraiseexcpt.c b/sysdeps/aarch64/fpu/fraiseexcpt.c index 77c6ca7e89..3be8fa307e 100644 --- a/sysdeps/aarch64/fpu/fraiseexcpt.c +++ b/sysdeps/aarch64/fpu/fraiseexcpt.c @@ -21,7 +21,7 @@ #include int -feraiseexcept (int excepts) +__feraiseexcept (int excepts) { int fpsr; const float fp_zero = 0.0; @@ -88,4 +88,6 @@ feraiseexcept (int excepts) return 0; } -libm_hidden_def (feraiseexcept) +libm_hidden_def (__feraiseexcept) +weak_alias (__feraiseexcept, feraiseexcept) +libm_hidden_weak (feraiseexcept) diff --git a/sysdeps/aarch64/fpu/math_private.h b/sysdeps/aarch64/fpu/math_private.h index b13c030193..514339f156 100644 --- a/sysdeps/aarch64/fpu/math_private.h +++ b/sysdeps/aarch64/fpu/math_private.h @@ -159,7 +159,7 @@ libc_feupdateenv_test_aarch64 (const fenv_t *envp, int ex) /* Raise the exceptions if enabled in the new FP state. */ if (__glibc_unlikely (excepts & (new_fpcr >> FE_EXCEPT_SHIFT))) - feraiseexcept (excepts); + __feraiseexcept (excepts); return excepts & ex; } diff --git a/sysdeps/alpha/fpu/feupdateenv.c b/sysdeps/alpha/fpu/feupdateenv.c index af1f6309e3..cd192ca213 100644 --- a/sysdeps/alpha/fpu/feupdateenv.c +++ b/sysdeps/alpha/fpu/feupdateenv.c @@ -33,7 +33,7 @@ __feupdateenv (const fenv_t *envp) /* Raise the saved exception. Incidently for us the implementation defined format of the values in objects of type fexcept_t is the same as the ones specified using the FE_* constants. */ - feraiseexcept (tmp & SWCR_STATUS_MASK); + __feraiseexcept (tmp & SWCR_STATUS_MASK); /* Success. */ return 0; diff --git a/sysdeps/arm/fenv_private.h b/sysdeps/arm/fenv_private.h index 743df18c35..5fca507d92 100644 --- a/sysdeps/arm/fenv_private.h +++ b/sysdeps/arm/fenv_private.h @@ -129,7 +129,7 @@ libc_feupdateenv_test_vfp (const fenv_t *envp, int ex) /* Raise the exceptions if enabled in the new FP state. */ if (__glibc_unlikely (excepts & (new_fpscr >> FE_EXCEPT_SHIFT))) - feraiseexcept (excepts); + __feraiseexcept (excepts); return excepts & ex; } diff --git a/sysdeps/arm/feupdateenv.c b/sysdeps/arm/feupdateenv.c index f9a1f28552..f5d914f6c6 100644 --- a/sysdeps/arm/feupdateenv.c +++ b/sysdeps/arm/feupdateenv.c @@ -46,7 +46,7 @@ feupdateenv (const fenv_t *envp) /* Raise the exceptions if enabled in the new FP state. */ if (excepts & (new_fpscr >> FE_EXCEPT_SHIFT)) - return feraiseexcept (excepts); + return __feraiseexcept (excepts); return 0; } @@ -69,7 +69,7 @@ feupdateenv (const fenv_t *envp) /* Raise the exceptions if enabled in the new FP state. */ if (excepts & (new_fpscr >> FE_EXCEPT_SHIFT)) - return feraiseexcept (excepts); + return __feraiseexcept (excepts); return 0; } diff --git a/sysdeps/arm/fraiseexcpt.c b/sysdeps/arm/fraiseexcpt.c index 91ec86fb06..7c02418acb 100644 --- a/sysdeps/arm/fraiseexcpt.c +++ b/sysdeps/arm/fraiseexcpt.c @@ -23,7 +23,7 @@ int -feraiseexcept (int excepts) +__feraiseexcept (int excepts) { /* Fail if a VFP unit isn't present unless nothing needs to be done. */ if (!ARM_HAVE_VFP) @@ -102,4 +102,6 @@ feraiseexcept (int excepts) return 0; } } -libm_hidden_def (feraiseexcept) +libm_hidden_def (__feraiseexcept) +weak_alias (__feraiseexcept, feraiseexcept) +libm_hidden_weak (feraiseexcept) diff --git a/sysdeps/hppa/fpu/fraiseexcpt.c b/sysdeps/hppa/fpu/fraiseexcpt.c index 74e93508f3..920208e87e 100644 --- a/sysdeps/hppa/fpu/fraiseexcpt.c +++ b/sysdeps/hppa/fpu/fraiseexcpt.c @@ -25,7 +25,7 @@ page 10-5 "Delayed Trapping" in the PA-RISC 2.0 Architecture manual */ int -feraiseexcept (int excepts) +__feraiseexcept (int excepts) { /* Raise exceptions represented by EXCEPTS. But we must raise only one signal at a time. It is important that if the overflow/underflow @@ -98,4 +98,6 @@ feraiseexcept (int excepts) /* Success. */ return 0; } -libm_hidden_def (feraiseexcept) +libm_hidden_def (__feraiseexcept) +weak_alias (__feraiseexcept, feraiseexcept) +libm_hidden_weak (feraiseexcept) diff --git a/sysdeps/i386/fpu/fraiseexcpt.c b/sysdeps/i386/fpu/fraiseexcpt.c index 076477fc5d..b663198649 100644 --- a/sysdeps/i386/fpu/fraiseexcpt.c +++ b/sysdeps/i386/fpu/fraiseexcpt.c @@ -119,5 +119,6 @@ strong_alias (__feraiseexcept, __old_feraiseexcept) compat_symbol (libm, __old_feraiseexcept, feraiseexcept, GLIBC_2_1); #endif +libm_hidden_def (__feraiseexcept) libm_hidden_ver (__feraiseexcept, feraiseexcept) versioned_symbol (libm, __feraiseexcept, feraiseexcept, GLIBC_2_2); diff --git a/sysdeps/ia64/fpu/feupdateenv.c b/sysdeps/ia64/fpu/feupdateenv.c index 23185616fc..0da87938e8 100644 --- a/sysdeps/ia64/fpu/feupdateenv.c +++ b/sysdeps/ia64/fpu/feupdateenv.c @@ -32,7 +32,7 @@ feupdateenv (const fenv_t *envp) fesetenv (envp); /* Raise the saved exceptions. */ - feraiseexcept ((int) (fpsr >> 13) & FE_ALL_EXCEPT); + __feraiseexcept ((int) (fpsr >> 13) & FE_ALL_EXCEPT); /* Success. */ return 0; diff --git a/sysdeps/ia64/fpu/fraiseexcpt.c b/sysdeps/ia64/fpu/fraiseexcpt.c index 7b70b2efca..aa8525cb28 100644 --- a/sysdeps/ia64/fpu/fraiseexcpt.c +++ b/sysdeps/ia64/fpu/fraiseexcpt.c @@ -24,7 +24,7 @@ #include int -feraiseexcept (int excepts) +__feraiseexcept (int excepts) { double tmp; double dummy; @@ -75,4 +75,6 @@ feraiseexcept (int excepts) /* Success. */ return 0; } -libm_hidden_def (feraiseexcept) +libm_hidden_def (__feraiseexcept) +weak_alias (__feraiseexcept, feraiseexcept) +libm_hidden_weak (feraiseexcept) diff --git a/sysdeps/m68k/coldfire/fpu/fraiseexcpt.c b/sysdeps/m68k/coldfire/fpu/fraiseexcpt.c index 3d75deb6ac..5b3e048375 100644 --- a/sysdeps/m68k/coldfire/fpu/fraiseexcpt.c +++ b/sysdeps/m68k/coldfire/fpu/fraiseexcpt.c @@ -21,7 +21,7 @@ #include int -feraiseexcept (int excepts) +__feraiseexcept (int excepts) { /* Raise exceptions represented by EXCEPTS. But we must raise only one signal at a time. It is important that if the overflow/underflow @@ -63,4 +63,6 @@ feraiseexcept (int excepts) /* Success. */ return 0; } -libm_hidden_def (feraiseexcept) +libm_hidden_def (__feraiseexcept) +weak_alias (__feraiseexcept, feraiseexcept) +libm_hidden_weak (feraiseexcept) diff --git a/sysdeps/m68k/fpu/feupdateenv.c b/sysdeps/m68k/fpu/feupdateenv.c index 3ed7ed00c6..f3652e0458 100644 --- a/sysdeps/m68k/fpu/feupdateenv.c +++ b/sysdeps/m68k/fpu/feupdateenv.c @@ -34,7 +34,7 @@ __feupdateenv (const fenv_t *envp) /* Raise the saved exception. Incidently for us the implementation defined format of the values in objects of type fexcept_t is the same as the ones specified using the FE_* constants. */ - feraiseexcept ((int) fpsr); + __feraiseexcept ((int) fpsr); /* Success. */ return 0; diff --git a/sysdeps/microblaze/math_private.h b/sysdeps/microblaze/math_private.h index 39b71722d3..2cfaacad1b 100644 --- a/sysdeps/microblaze/math_private.h +++ b/sysdeps/microblaze/math_private.h @@ -28,6 +28,7 @@ #include_next #define feraiseexcept(excepts) ({ 0; }) +#define __feraiseexcept(excepts) ({ 0; }) #define feclearexcept(exc) ({ 0; }) #endif diff --git a/sysdeps/mips/fpu/feupdateenv.c b/sysdeps/mips/fpu/feupdateenv.c index 8b2572d914..78ca0634fa 100644 --- a/sysdeps/mips/fpu/feupdateenv.c +++ b/sysdeps/mips/fpu/feupdateenv.c @@ -35,7 +35,7 @@ feupdateenv (const fenv_t *envp) /* Raise the safed exception. Incidently for us the implementation defined format of the values in objects of type fexcept_t is the same as the ones specified using the FE_* constants. */ - feraiseexcept (temp); + __feraiseexcept (temp); /* Success. */ return 0; diff --git a/sysdeps/mips/fpu/fraiseexcpt.c b/sysdeps/mips/fpu/fraiseexcpt.c index ab84fe1867..55d7962b40 100644 --- a/sysdeps/mips/fpu/fraiseexcpt.c +++ b/sysdeps/mips/fpu/fraiseexcpt.c @@ -22,7 +22,7 @@ #include int -feraiseexcept (int excepts) +__feraiseexcept (int excepts) { fpu_control_t cw; @@ -43,4 +43,6 @@ feraiseexcept (int excepts) return 0; } -libm_hidden_def (feraiseexcept) +libm_hidden_def (__feraiseexcept) +weak_alias (__feraiseexcept, feraiseexcept) +libm_hidden_weak (feraiseexcept) diff --git a/sysdeps/powerpc/fpu/e_sqrt.c b/sysdeps/powerpc/fpu/e_sqrt.c index 0368e57e92..a2d95172ae 100644 --- a/sysdeps/powerpc/fpu/e_sqrt.c +++ b/sysdeps/powerpc/fpu/e_sqrt.c @@ -142,12 +142,12 @@ __slow_ieee754_sqrt (double x) /* For some reason, some PowerPC32 processors don't implement FE_INVALID_SQRT. */ #ifdef FE_INVALID_SQRT - feraiseexcept (FE_INVALID_SQRT); + __feraiseexcept (FE_INVALID_SQRT); fenv_union_t u = { .fenv = fegetenv_register () }; if ((u.l & FE_INVALID) == 0) #endif - feraiseexcept (FE_INVALID); + __feraiseexcept (FE_INVALID); x = a_nan.value; } return f_wash (x); diff --git a/sysdeps/powerpc/fpu/fraiseexcpt.c b/sysdeps/powerpc/fpu/fraiseexcpt.c index 8fb6dfee27..37ff5d8a40 100644 --- a/sysdeps/powerpc/fpu/fraiseexcpt.c +++ b/sysdeps/powerpc/fpu/fraiseexcpt.c @@ -63,5 +63,6 @@ strong_alias (__feraiseexcept, __old_feraiseexcept) compat_symbol (libm, __old_feraiseexcept, feraiseexcept, GLIBC_2_1); #endif +libm_hidden_def (__feraiseexcept) libm_hidden_ver (__feraiseexcept, feraiseexcept) versioned_symbol (libm, __feraiseexcept, feraiseexcept, GLIBC_2_2); diff --git a/sysdeps/powerpc/nofpu/fraiseexcpt.c b/sysdeps/powerpc/nofpu/fraiseexcpt.c index 097502e41b..e390363ee2 100644 --- a/sysdeps/powerpc/nofpu/fraiseexcpt.c +++ b/sysdeps/powerpc/nofpu/fraiseexcpt.c @@ -38,5 +38,6 @@ strong_alias (__feraiseexcept, __old_feraiseexcept) compat_symbol (libm, __old_feraiseexcept, feraiseexcept, GLIBC_2_1); #endif +libm_hidden_def (__feraiseexcept) libm_hidden_ver (__feraiseexcept, feraiseexcept) versioned_symbol (libm, __feraiseexcept, feraiseexcept, GLIBC_2_2); diff --git a/sysdeps/powerpc/powerpc32/e500/nofpu/fraiseexcpt.c b/sysdeps/powerpc/powerpc32/e500/nofpu/fraiseexcpt.c index 70fe68396c..9a461eb221 100644 --- a/sysdeps/powerpc/powerpc32/e500/nofpu/fraiseexcpt.c +++ b/sysdeps/powerpc/powerpc32/e500/nofpu/fraiseexcpt.c @@ -36,5 +36,6 @@ strong_alias (__feraiseexcept, __old_feraiseexcept) compat_symbol (libm, __old_feraiseexcept, feraiseexcept, GLIBC_2_1); #endif +libm_hidden_def (__feraiseexcept) libm_hidden_ver (__feraiseexcept, feraiseexcept) versioned_symbol (libm, __feraiseexcept, feraiseexcept, GLIBC_2_2); diff --git a/sysdeps/s390/fpu/feupdateenv.c b/sysdeps/s390/fpu/feupdateenv.c index 710893a7b8..4e1b52c0d5 100644 --- a/sysdeps/s390/fpu/feupdateenv.c +++ b/sysdeps/s390/fpu/feupdateenv.c @@ -32,7 +32,7 @@ feupdateenv (const fenv_t *envp) /* Raise the exceptions since the last call to feholdenv */ /* re install saved environment. */ fesetenv (envp); - feraiseexcept ((int) temp); + __feraiseexcept ((int) temp); /* Success. */ return 0; diff --git a/sysdeps/s390/fpu/fraiseexcpt.c b/sysdeps/s390/fpu/fraiseexcpt.c index d99f939acb..c1f4b3ebcd 100644 --- a/sysdeps/s390/fpu/fraiseexcpt.c +++ b/sysdeps/s390/fpu/fraiseexcpt.c @@ -37,7 +37,7 @@ fexceptadd (float d, float e) int -feraiseexcept (int excepts) +__feraiseexcept (int excepts) { /* Raise exceptions represented by EXPECTS. But we must raise only one signal at a time. It is important that if the overflow/underflow @@ -69,4 +69,6 @@ feraiseexcept (int excepts) /* Success. */ return 0; } -libm_hidden_def (feraiseexcept) +libm_hidden_def (__feraiseexcept) +weak_alias (__feraiseexcept, feraiseexcept) +libm_hidden_weak (feraiseexcept) diff --git a/sysdeps/sh/sh4/fpu/feupdateenv.c b/sysdeps/sh/sh4/fpu/feupdateenv.c index f06d80a883..36ef335256 100644 --- a/sysdeps/sh/sh4/fpu/feupdateenv.c +++ b/sysdeps/sh/sh4/fpu/feupdateenv.c @@ -32,7 +32,7 @@ feupdateenv (const fenv_t *envp) defined format of the values in objects of type fexcept_t is the same as the ones specified using the FE_* constants. */ fesetenv (envp); - feraiseexcept ((int) temp); + __feraiseexcept ((int) temp); return 0; } diff --git a/sysdeps/sh/sh4/fpu/fraiseexcpt.c b/sysdeps/sh/sh4/fpu/fraiseexcpt.c index 944da33a8c..e89ca29cbf 100644 --- a/sysdeps/sh/sh4/fpu/fraiseexcpt.c +++ b/sysdeps/sh/sh4/fpu/fraiseexcpt.c @@ -23,7 +23,7 @@ #include int -feraiseexcept (int excepts) +__feraiseexcept (int excepts) { if (excepts == 0) return 0; @@ -70,4 +70,6 @@ feraiseexcept (int excepts) return 0; } -libm_hidden_def (feraiseexcept) +libm_hidden_def (__feraiseexcept) +weak_alias (__feraiseexcept, feraiseexcept) +libm_hidden_weak (feraiseexcept) diff --git a/sysdeps/sparc/fpu/feupdateenv.c b/sysdeps/sparc/fpu/feupdateenv.c index 79cb1db9fe..3c176b51c5 100644 --- a/sysdeps/sparc/fpu/feupdateenv.c +++ b/sysdeps/sparc/fpu/feupdateenv.c @@ -34,7 +34,7 @@ __feupdateenv (const fenv_t *envp) /* Raise the safed exception. Incidently for us the implementation defined format of the values in objects of type fexcept_t is the same as the ones specified using the FE_* constants. */ - feraiseexcept ((int) tmp); + __feraiseexcept ((int) tmp); /* Success. */ return 0; diff --git a/sysdeps/sparc/fpu/fraiseexcpt.c b/sysdeps/sparc/fpu/fraiseexcpt.c index e1c63dd895..43b0bac9a0 100644 --- a/sysdeps/sparc/fpu/fraiseexcpt.c +++ b/sysdeps/sparc/fpu/fraiseexcpt.c @@ -86,5 +86,6 @@ strong_alias (__feraiseexcept, __old_feraiseexcept) compat_symbol (libm, __old_feraiseexcept, feraiseexcept, GLIBC_2_1); #endif +libm_hidden_def (__feraiseexcept) libm_hidden_ver (__feraiseexcept, feraiseexcept) versioned_symbol (libm, __feraiseexcept, feraiseexcept, GLIBC_2_2); diff --git a/sysdeps/tile/math_private.h b/sysdeps/tile/math_private.h index a58eafa57c..035a83fd37 100644 --- a/sysdeps/tile/math_private.h +++ b/sysdeps/tile/math_private.h @@ -26,6 +26,7 @@ #include_next #define feraiseexcept(excepts) ({ 0; }) +#define __feraiseexcept(excepts) ({ 0; }) #define feclearexcept(exc) ({ 0; }) #define fetestexcept(exc) ({ 0; }) extern inline int fegetenv (fenv_t *__e) { return 0; } diff --git a/sysdeps/unix/sysv/linux/alpha/fraiseexcpt.S b/sysdeps/unix/sysv/linux/alpha/fraiseexcpt.S index b8f344e611..4e1cc5780c 100644 --- a/sysdeps/unix/sysv/linux/alpha/fraiseexcpt.S +++ b/sysdeps/unix/sysv/linux/alpha/fraiseexcpt.S @@ -52,6 +52,7 @@ END(__feraiseexcept) strong_alias (__feraiseexcept, __old_feraiseexcept) compat_symbol (libm, __old_feraiseexcept, feraiseexcept, GLIBC_2_1); # endif +libm_hidden_def (__feraiseexcept) libm_hidden_ver (__feraiseexcept, feraiseexcept) versioned_symbol (libm, __feraiseexcept, feraiseexcept, GLIBC_2_2); #endif diff --git a/sysdeps/x86/fpu/bits/fenv.h b/sysdeps/x86/fpu/bits/fenv.h index d21b312980..791ade4f1c 100644 --- a/sysdeps/x86/fpu/bits/fenv.h +++ b/sysdeps/x86/fpu/bits/fenv.h @@ -107,39 +107,43 @@ __BEGIN_DECLS /* Optimized versions. */ extern int __REDIRECT_NTH (__feraiseexcept_renamed, (int), feraiseexcept); -__extern_inline int -__NTH (feraiseexcept (int __excepts)) +__extern_always_inline void +__NTH (__feraiseexcept_invalid_divbyzero (int __excepts)) { - if (__builtin_constant_p (__excepts) - && (__excepts & ~(FE_INVALID | FE_DIVBYZERO)) == 0) + if ((FE_INVALID & __excepts) != 0) { - if ((FE_INVALID & __excepts) != 0) - { - /* One example of an invalid operation is 0.0 / 0.0. */ - float __f = 0.0; + /* One example of an invalid operation is 0.0 / 0.0. */ + float __f = 0.0; # ifdef __SSE_MATH__ - __asm__ __volatile__ ("divss %0, %0 " : : "x" (__f)); + __asm__ __volatile__ ("divss %0, %0 " : : "x" (__f)); # else - __asm__ __volatile__ ("fdiv %%st, %%st(0); fwait" - : "=t" (__f) : "0" (__f)); + __asm__ __volatile__ ("fdiv %%st, %%st(0); fwait" + : "=t" (__f) : "0" (__f)); # endif - (void) &__f; - } - if ((FE_DIVBYZERO & __excepts) != 0) - { - float __f = 1.0; - float __g = 0.0; + (void) &__f; + } + if ((FE_DIVBYZERO & __excepts) != 0) + { + float __f = 1.0; + float __g = 0.0; # ifdef __SSE_MATH__ - __asm__ __volatile__ ("divss %1, %0" : : "x" (__f), "x" (__g)); + __asm__ __volatile__ ("divss %1, %0" : : "x" (__f), "x" (__g)); # else - __asm__ __volatile__ ("fdivp %%st, %%st(1); fwait" - : "=t" (__f) : "0" (__f), "u" (__g) : "st(1)"); + __asm__ __volatile__ ("fdivp %%st, %%st(1); fwait" + : "=t" (__f) : "0" (__f), "u" (__g) : "st(1)"); # endif - (void) &__f; - } - + (void) &__f; + } +} +__extern_inline int +__NTH (feraiseexcept (int __excepts)) +{ + if (__builtin_constant_p (__excepts) + && (__excepts & ~(FE_INVALID | FE_DIVBYZERO)) == 0) + { + __feraiseexcept_invalid_divbyzero (__excepts); return 0; } diff --git a/sysdeps/x86/fpu/include/bits/fenv.h b/sysdeps/x86/fpu/include/bits/fenv.h new file mode 100644 index 0000000000..f5d062aae3 --- /dev/null +++ b/sysdeps/x86/fpu/include/bits/fenv.h @@ -0,0 +1,42 @@ +/* Wrapper for x86 bits/fenv.h for use when building glibc. + Copyright (C) 1997-2014 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 + . */ + +#include_next + +/* Ensure __feraiseexcept calls in glibc are optimized the same as + feraiseexcept calls. */ + +#ifdef __USE_EXTERN_INLINES +__BEGIN_DECLS + +extern int __REDIRECT_NTH (____feraiseexcept_renamed, (int), __feraiseexcept); +__extern_inline int +__NTH (__feraiseexcept (int __excepts)) +{ + if (__builtin_constant_p (__excepts) + && (__excepts & ~(FE_INVALID | FE_DIVBYZERO)) == 0) + { + __feraiseexcept_invalid_divbyzero (__excepts); + return 0; + } + + return ____feraiseexcept_renamed (__excepts); +} + +__END_DECLS +#endif diff --git a/sysdeps/x86_64/fpu/fraiseexcpt.c b/sysdeps/x86_64/fpu/fraiseexcpt.c index 5aeaf30040..aa8ce5d765 100644 --- a/sysdeps/x86_64/fpu/fraiseexcpt.c +++ b/sysdeps/x86_64/fpu/fraiseexcpt.c @@ -116,5 +116,6 @@ __feraiseexcept (int excepts) /* Success. */ return 0; } -strong_alias (__feraiseexcept, feraiseexcept) -libm_hidden_def (feraiseexcept) +libm_hidden_def (__feraiseexcept) +weak_alias (__feraiseexcept, feraiseexcept) +libm_hidden_weak (feraiseexcept) -- cgit 1.4.1