1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-29 11:41:21 +03:00

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.
This commit is contained in:
Joseph Myers
2014-12-30 17:08:09 +00:00
parent 63180606ee
commit 0747f81811
44 changed files with 215 additions and 75 deletions

View File

@ -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]

2
NEWS
View File

@ -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

View 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)

View 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)

View 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);

View 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);
}

View 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);
}

View 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;
}

View 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_)

View 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_)

View 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_)

View 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) */
}
}

View 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) */
}
}

View 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;
}

View 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)

View 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;
}

View 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;

View 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;
}

View 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;
}

View 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)

View 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)

View 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);

View 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;

View 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)

View 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)

View 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;

View File

@ -28,6 +28,7 @@
#include_next <math_private.h>
#define feraiseexcept(excepts) ({ 0; })
#define __feraiseexcept(excepts) ({ 0; })
#define feclearexcept(exc) ({ 0; })
#endif

View 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;

View 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)

View 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);

View 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);

View 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);

View 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);

View 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;

View 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)

View 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;
}

View 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)

View 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;

View 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);

View 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; }

View 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

View File

@ -107,39 +107,43 @@ __BEGIN_DECLS
/* Optimized versions. */
extern int __REDIRECT_NTH (__feraiseexcept_renamed, (int), feraiseexcept);
__extern_always_inline void
__NTH (__feraiseexcept_invalid_divbyzero (int __excepts))
{
if ((FE_INVALID & __excepts) != 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));
# else
__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;
# ifdef __SSE_MATH__
__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)");
# endif
(void) &__f;
}
}
__extern_inline int
__NTH (feraiseexcept (int __excepts))
{
if (__builtin_constant_p (__excepts)
&& (__excepts & ~(FE_INVALID | FE_DIVBYZERO)) == 0)
{
if ((FE_INVALID & __excepts) != 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));
# else
__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;
# ifdef __SSE_MATH__
__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)");
# endif
(void) &__f;
}
__feraiseexcept_invalid_divbyzero (__excepts);
return 0;
}

View File

@ -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

View 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)