nptl: Fix tst-cancel30 on sparc64
[glibc.git] / math / w_pow_compat.c
blobcc01cca85b8e6fcc2f31588c0ae50146ccc0728e
1 /* Copyright (C) 2011-2023 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
18 #include <math.h>
19 #include <math_private.h>
20 #include <math-svid-compat.h>
21 #include <libm-alias-double.h>
24 #if LIBM_SVID_COMPAT && (SHLIB_COMPAT (libm, GLIBC_2_0, GLIBC_2_29) \
25 || defined NO_LONG_DOUBLE \
26 || defined LONG_DOUBLE_COMPAT)
27 /* wrapper pow */
28 double
29 __pow_compat (double x, double y)
31 double z = __ieee754_pow (x, y);
32 if (__glibc_unlikely (!isfinite (z)))
34 if (_LIB_VERSION != _IEEE_)
36 if (isfinite (x) && isfinite (y))
38 if (isnan (z))
39 /* pow neg**non-int */
40 return __kernel_standard (x, y, 24);
41 else if (x == 0.0 && y < 0.0)
43 if (signbit (x) && signbit (z))
44 /* pow(-0.0,negative) */
45 return __kernel_standard (x, y, 23);
46 else
47 /* pow(+0.0,negative) */
48 return __kernel_standard (x, y, 43);
50 else
51 /* pow overflow */
52 return __kernel_standard (x, y, 21);
56 else if (__builtin_expect (z == 0.0, 0)
57 && isfinite (x) && x != 0 && isfinite (y)
58 && _LIB_VERSION != _IEEE_)
59 /* pow underflow */
60 return __kernel_standard (x, y, 22);
62 return z;
64 # if SHLIB_COMPAT (libm, GLIBC_2_0, GLIBC_2_29)
65 compat_symbol (libm, __pow_compat, pow, GLIBC_2_0);
66 # endif
67 # ifdef NO_LONG_DOUBLE
68 weak_alias (__pow_compat, powl)
69 # endif
70 # ifdef LONG_DOUBLE_COMPAT
71 /* Work around gas bug "multiple versions for symbol". */
72 weak_alias (__pow_compat, __pow_compat_alias)
74 LONG_DOUBLE_COMPAT_CHOOSE_libm_powl (
75 compat_symbol (libm, __pow_compat_alias, powl, FIRST_VERSION_libm_powl), );
76 # endif
77 #endif