]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix libm feraiseexcept namespace (bug 17723).
authorJoseph Myers <joseph@codesourcery.com>
Tue, 30 Dec 2014 17:08:09 +0000 (17:08 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Tue, 30 Dec 2014 17:08:09 +0000 (17:08 +0000)
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.

44 files changed:
ChangeLog
NEWS
include/fenv.h
math/e_scalb.c
math/fraiseexcpt.c
math/w_acos.c
math/w_asin.c
math/w_ilogb.c
math/w_j0.c
math/w_j1.c
math/w_jn.c
math/w_log.c
math/w_log10.c
sysdeps/aarch64/fpu/feupdateenv.c
sysdeps/aarch64/fpu/fraiseexcpt.c
sysdeps/aarch64/fpu/math_private.h
sysdeps/alpha/fpu/feupdateenv.c
sysdeps/arm/fenv_private.h
sysdeps/arm/feupdateenv.c
sysdeps/arm/fraiseexcpt.c
sysdeps/hppa/fpu/fraiseexcpt.c
sysdeps/i386/fpu/fraiseexcpt.c
sysdeps/ia64/fpu/feupdateenv.c
sysdeps/ia64/fpu/fraiseexcpt.c
sysdeps/m68k/coldfire/fpu/fraiseexcpt.c
sysdeps/m68k/fpu/feupdateenv.c
sysdeps/microblaze/math_private.h
sysdeps/mips/fpu/feupdateenv.c
sysdeps/mips/fpu/fraiseexcpt.c
sysdeps/powerpc/fpu/e_sqrt.c
sysdeps/powerpc/fpu/fraiseexcpt.c
sysdeps/powerpc/nofpu/fraiseexcpt.c
sysdeps/powerpc/powerpc32/e500/nofpu/fraiseexcpt.c
sysdeps/s390/fpu/feupdateenv.c
sysdeps/s390/fpu/fraiseexcpt.c
sysdeps/sh/sh4/fpu/feupdateenv.c
sysdeps/sh/sh4/fpu/fraiseexcpt.c
sysdeps/sparc/fpu/feupdateenv.c
sysdeps/sparc/fpu/fraiseexcpt.c
sysdeps/tile/math_private.h
sysdeps/unix/sysv/linux/alpha/fraiseexcpt.S
sysdeps/x86/fpu/bits/fenv.h
sysdeps/x86/fpu/include/bits/fenv.h [new file with mode: 0644]
sysdeps/x86_64/fpu/fraiseexcpt.c

index ce76c8d8193a39fba1551fc18711d8187f505671..5780c3a7f0ad89854966389e0eadaffc839c7742 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,70 @@
+2014-12-30  Joseph Myers  <joseph@codesourcery.com>
+
+       [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  <hongjiu.lu@intel.com>
 
        [BZ #17732]
diff --git a/NEWS b/NEWS
index 0db6dbf0296b9f7def8865b5162f0db4d4c45e2b..23b1cd7c134ed14bb2b177d803b4b76a115aad82 100644 (file)
--- 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
index bd2c99db9675855108adee145860a591b549f46c..0cfbacd4ab57589fa6b9716598e2bf4bb65e78a2 100644 (file)
@@ -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)
index 146d49e1c301dfe793a8c1717e61a3ecebba1072..d315d57681f863ce13cc96f0b41362343b24013d 100644 (file)
@@ -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)
index 8809af997d9ba5e24a77050a52f33d0e698a6a6a..05caf0d187c61ae57ef9a8ee42d47e734a9b4b32 100644 (file)
@@ -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);
 
index bb641092f011f36919900fbabac023172b038319..e5e79dd2e08dbf380a2c7f7f8521c7ad58a1cae9 100644 (file)
@@ -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);
     }
 
index 9bf9374ec835ea0684b7e1d256876a49274bec30..2b744467cd7301b3e6165ff35e3f7cd36ba9d8b5 100644 (file)
@@ -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);
     }
 
index 9c0e2644839f330aef5dbc7205d3040d5047ea4c..b2b3108a635075b65cb9604c827b91cc34069028 100644 (file)
@@ -31,7 +31,7 @@ __ilogb (double x)
       || __builtin_expect (r == INT_MAX, 0))
     {
       __set_errno (EDOM);
-      feraiseexcept (FE_INVALID);
+      __feraiseexcept (FE_INVALID);
     }
   return r;
 }
index 92a834542a8f5fc82ad9f6c2ff70e65e4523aad3..1ed8c26f1c8d73d16485c80d1d7816814de97338 100644 (file)
@@ -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_)
index 37c6d1f4b598ddc292b9022d79d4ee3fb7fd45b7..63bac833890aa629a8a9456bbb3323280246f67a 100644 (file)
@@ -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_)
index 56bd280b1e50ba1c4148d2bbeee64be416f5b644..fdd2dc70e80128e8b3218f95b27b7d5623d572ab 100644 (file)
@@ -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_)
index 8c9005209422a28523de5ec3a7749c6627270b65..4383e500b337b4094f4c0fb4d101ab4976ac2bab 100644 (file)
@@ -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) */
        }
     }
index 472d2a146dbbcb868ff823a88de18c1fcc2b8f94..a0a1843ba6c84213223dd5418113134bc3c2edbb 100644 (file)
@@ -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) */
        }
     }
index ac2f6fe7f80283e30a7e73419a6a693398f8d1b8..3c675c3a4e48d44b61fae4d75d1f96c4a5f87eed 100644 (file)
@@ -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;
 }
index 77c6ca7e891abd5ea70de10e9714c22697507501..3be8fa307ea5ef60a0800151da3a4b76b63644c9 100644 (file)
@@ -21,7 +21,7 @@
 #include <float.h>
 
 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)
index b13c030193498174c26f12e4de237ff53bee60ea..514339f156cc21354f42d2ce781789ae899f157f 100644 (file)
@@ -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;
 }
index af1f6309e357b5ad50b17eea57105b9be54826f3..cd192ca21343723230b25f9552e6ba252847526f 100644 (file)
@@ -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;
index 743df18c35f4597b98fd3892aadbb18d4dea25ac..5fca507d927e0fa2dc71e02ec5638302cbd473fb 100644 (file)
@@ -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;
 }
index f9a1f28552c5de0b2fb81cc03907843ce2035e85..f5d914f6c6e19890ae8814014bb342dda4e80cfe 100644 (file)
@@ -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;
 }
index 91ec86fb06147a858259950e6e83e368983a0b4f..7c02418acb6755480d3228514266c7cf0e9ce7d3 100644 (file)
@@ -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)
index 74e93508f39dfd59ba99e4218938feb83c7acf9c..920208e87ed925d06ba93046d245bd8da76348b7 100644 (file)
@@ -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)
index 076477fc5d65f4196d751c24c3c310fd159afa55..b6631986499b46d5d3ac6a246f466577a88d41f0 100644 (file)
@@ -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);
index 23185616fcdd6f656cd110cae83197a43f2d3c9c..0da87938e86af9e40531ee0f26d2dcf8fb6503af 100644 (file)
@@ -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;
index 7b70b2efca71d11bed74ebeca45a15d277994842..aa8525cb28a68129eb3565511c674c0606d92e11 100644 (file)
@@ -24,7 +24,7 @@
 #include <unistd.h>
 
 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)
index 3d75deb6acdd705cffc32c86c874bbfac62c5f32..5b3e048375ecb8d87b3674ba6a1ccc6c6fb812bd 100644 (file)
@@ -21,7 +21,7 @@
 #include <math.h>
 
 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)
index 3ed7ed00c6ad6957487f4e3074240fec1b9d774f..f3652e0458af6f219187884d4ae1ad4511123d75 100644 (file)
@@ -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;
index 39b71722d3499c3a34f0817a13ed7c35e157de0d..2cfaacad1be3009ca9a73ed469c57e5ff3ca2918 100644 (file)
@@ -28,6 +28,7 @@
 #include_next <math_private.h>
 
 #define feraiseexcept(excepts)                 ({ 0; })
+#define __feraiseexcept(excepts)               ({ 0; })
 #define feclearexcept(exc)                     ({ 0; })
 
 #endif
index 8b2572d914e30377be4ec0a9de8d1747269204b0..78ca0634fa235873e5be6b17fc92b7e1dfe5e899 100644 (file)
@@ -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;
index ab84fe1867db69eb318a4be901c09535d892900a..55d7962b40bc6f129609a545615345dfd2082919 100644 (file)
@@ -22,7 +22,7 @@
 #include <fpu_control.h>
 
 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)
index 0368e57e92ec553c9047734fa5eb5c709ec0be0b..a2d95172ae80a27030d99c2f9b6fd3b6e88d80ec 100644 (file)
@@ -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);
index 8fb6dfee2789292295dde43a4c88043e52fc76a3..37ff5d8a401e7733506e6b972e848098e7bef0f8 100644 (file)
@@ -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);
index 097502e41b175c7269b8ff4bff80529427221f7a..e390363ee27e8a13e06fe0b30d904252d5fc5ded 100644 (file)
@@ -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);
index 70fe68396cc6518fc2c98e7e858c903db37cc559..9a461eb221bf567e762ba352c090ad3d446ac3c0 100644 (file)
@@ -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);
index 710893a7b8fe00a63b4968e04978eb1599a59379..4e1b52c0d56d0e72652b975180005243d8c9d01b 100644 (file)
@@ -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;
index d99f939acbecea8a4053cd9029cc16f8299bd58c..c1f4b3ebcd11aa2f9ac52e5ad617cac93819ab95 100644 (file)
@@ -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)
index f06d80a883b796244ea49396a990f0f7a99f09f7..36ef3352564c50e0f8bb19b1bca32e1246e8a3ae 100644 (file)
@@ -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;
 }
index 944da33a8c7322b35ebccd9ef0b6efaedd315394..e89ca29cbfc662c53562c3dad4a7656c9342374f 100644 (file)
@@ -23,7 +23,7 @@
 #include <math.h>
 
 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)
index 79cb1db9febe760b53580c1649579bb23f74b610..3c176b51c56a62fc78d48e75306b98aaa6bfb292 100644 (file)
@@ -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;
index e1c63dd8950ce253189bded91d88e08f61c57eeb..43b0bac9a08ad2a53ee3458df71b04a807ac4695 100644 (file)
@@ -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);
index a58eafa57c141ca1c9a3ad3fd5bad6162aa11d25..035a83fd37d6e2823aa20e8514c3d1e171137c0b 100644 (file)
@@ -26,6 +26,7 @@
 #include_next <math_private.h>
 
 #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; }
index b8f344e6117d7d50e22d59e1edc122bc5d2e1dbc..4e1cc5780c67db9376679aacf6830b999f1de40c 100644 (file)
@@ -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
index d21b31298012a759ecc59f1dc43dd84df86a2a4c..791ade4f1c2a7f706828d451340436287d4b44a2 100644 (file)
@@ -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 (file)
index 0000000..f5d062a
--- /dev/null
@@ -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
+   <http://www.gnu.org/licenses/>.  */
+
+#include_next <bits/fenv.h>
+
+/* 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
index 5aeaf30040c10e15bc32d9722ff5c9f91146219b..aa8ce5d7655495bc411e2da6f987fd4bf976c7b4 100644 (file)
@@ -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)