a502c5294b
Introduce new pow symbol version that doesn't do SVID compatible error handling. The standard errno and fp exception based error handling is inline in the new code and does not have significant overhead. The wrapper is disabled for sysdeps/ieee754/dbl-64 by using empty w_pow.c and enabled for targets with their own pow implementation or ifunc dispatch on __ieee754_pow by including math/w_pow.c. The compatibility symbol version still uses the wrapper with SVID error handling around the new code. There is no new symbol version nor compatibility code on !LIBM_SVID_COMPAT targets (e.g. riscv). On targets where previously powl was an alias of pow, now it points to the compatibility symbol with the wrapper, because it still need the SVID compatible error handling. This affects NO_LONG_DOUBLE (e.g. arm) and LONG_DOUBLE_COMPAT (e.g. alpha) targets as well. The __pow_finite symbol is now an alias of pow. Both __pow_finite and pow set errno and thus not const functions. The ia64 asm is changed so the compat and new symbol versions map to the same address. On x86_64 #include <math.h> was added before macro definitions that may affect that header. Tested with build-many-glibcs.py. * math/Versions (GLIBC_2.29): Add pow. * math/w_pow_compat.c (__pow_compat): Change to versioned compat symbol. * math/w_pow.c: New file. * sysdeps/i386/fpu/w_pow.c: New file. * sysdeps/ia64/fpu/e_pow.S: Add versioned symbols. * sysdeps/ieee754/dbl-64/e_pow.c (__ieee754_pow): Rename to __pow and add necessary aliases. * sysdeps/ieee754/dbl-64/w_pow.c: New file. * sysdeps/m68k/m680x0/fpu/w_pow.c: New file. * sysdeps/mach/hurd/i386/libm.abilist: Update. * sysdeps/unix/sysv/linux/aarch64/libm.abilist: Update. * sysdeps/unix/sysv/linux/alpha/libm.abilist: Update. * sysdeps/unix/sysv/linux/arm/libm.abilist: Update. * sysdeps/unix/sysv/linux/hppa/libm.abilist: Update. * sysdeps/unix/sysv/linux/i386/libm.abilist: Update. * sysdeps/unix/sysv/linux/ia64/libm.abilist: Update. * sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Update. * sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Update. * sysdeps/unix/sysv/linux/microblaze/libm.abilist: Update. * sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Update. * sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Update. * sysdeps/unix/sysv/linux/nios2/libm.abilist: Update. * sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist: Update. * sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist: Update. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist: Update. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist: Update. * sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Update. * sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Update. * sysdeps/unix/sysv/linux/sh/libm.abilist: Update. * sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Update. * sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Update. * sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Update. * sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Update. * sysdeps/x86_64/fpu/multiarch/e_pow-fma.c (__ieee754_pow): Rename to __pow. * sysdeps/x86_64/fpu/multiarch/e_pow-fma4.c (__ieee754_pow): Likewise. * sysdeps/x86_64/fpu/multiarch/e_pow.c (__ieee754_pow): Likewise. * sysdeps/x86_64/fpu/multiarch/w_pow.c: New file.
79 lines
2.3 KiB
C
79 lines
2.3 KiB
C
/* Copyright (C) 2011-2018 Free Software Foundation, Inc.
|
|
This file is part of the GNU C Library.
|
|
Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
|
|
|
|
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 <math.h>
|
|
#include <math_private.h>
|
|
#include <math-svid-compat.h>
|
|
#include <libm-alias-double.h>
|
|
|
|
|
|
#if LIBM_SVID_COMPAT && (SHLIB_COMPAT (libm, GLIBC_2_0, GLIBC_2_29) \
|
|
|| defined NO_LONG_DOUBLE \
|
|
|| defined LONG_DOUBLE_COMPAT)
|
|
/* wrapper pow */
|
|
double
|
|
__pow_compat (double x, double y)
|
|
{
|
|
double z = __ieee754_pow (x, y);
|
|
if (__glibc_unlikely (!isfinite (z)))
|
|
{
|
|
if (_LIB_VERSION != _IEEE_)
|
|
{
|
|
if (isfinite (x) && isfinite (y))
|
|
{
|
|
if (isnan (z))
|
|
/* pow neg**non-int */
|
|
return __kernel_standard (x, y, 24);
|
|
else if (x == 0.0 && y < 0.0)
|
|
{
|
|
if (signbit (x) && signbit (z))
|
|
/* pow(-0.0,negative) */
|
|
return __kernel_standard (x, y, 23);
|
|
else
|
|
/* pow(+0.0,negative) */
|
|
return __kernel_standard (x, y, 43);
|
|
}
|
|
else
|
|
/* pow overflow */
|
|
return __kernel_standard (x, y, 21);
|
|
}
|
|
}
|
|
}
|
|
else if (__builtin_expect (z == 0.0, 0)
|
|
&& isfinite (x) && x != 0 && isfinite (y)
|
|
&& _LIB_VERSION != _IEEE_)
|
|
/* pow underflow */
|
|
return __kernel_standard (x, y, 22);
|
|
|
|
return z;
|
|
}
|
|
# if SHLIB_COMPAT (libm, GLIBC_2_0, GLIBC_2_29)
|
|
compat_symbol (libm, __pow_compat, pow, GLIBC_2_0);
|
|
# endif
|
|
# ifdef NO_LONG_DOUBLE
|
|
weak_alias (__pow_compat, powl)
|
|
# endif
|
|
# ifdef LONG_DOUBLE_COMPAT
|
|
/* Work around gas bug "multiple versions for symbol". */
|
|
weak_alias (__pow_compat, __pow_compat_alias)
|
|
|
|
LONG_DOUBLE_COMPAT_CHOOSE_libm_powl (
|
|
compat_symbol (libm, __pow_compat_alias, powl, FIRST_VERSION_libm_powl), );
|
|
# endif
|
|
#endif
|