]> git.ipfire.org Git - thirdparty/glibc.git/blame - math/w_pow_compat.c
Prefer https to http for gnu.org and fsf.org URLs
[thirdparty/glibc.git] / math / w_pow_compat.c
CommitLineData
04277e02 1/* Copyright (C) 2011-2019 Free Software Foundation, Inc.
0ac5ae23
UD
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
f7eac6eb 4
0ac5ae23
UD
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
f7eac6eb 9
0ac5ae23
UD
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
f7eac6eb 14
0ac5ae23 15 You should have received a copy of the GNU Lesser General Public
59ba27a6 16 License along with the GNU C Library; if not, see
5a82c748 17 <https://www.gnu.org/licenses/>. */
f7eac6eb 18
9d13fb24 19#include <math.h>
9277c064 20#include <math_private.h>
813378e9 21#include <math-svid-compat.h>
9ac44708 22#include <libm-alias-double.h>
f7eac6eb
RM
23
24
a502c529
SN
25#if LIBM_SVID_COMPAT && (SHLIB_COMPAT (libm, GLIBC_2_0, GLIBC_2_29) \
26 || defined NO_LONG_DOUBLE \
27 || defined LONG_DOUBLE_COMPAT)
0ac5ae23
UD
28/* wrapper pow */
29double
a502c529 30__pow_compat (double x, double y)
f7eac6eb 31{
0ac5ae23 32 double z = __ieee754_pow (x, y);
d81f90cc 33 if (__glibc_unlikely (!isfinite (z)))
0ac5ae23
UD
34 {
35 if (_LIB_VERSION != _IEEE_)
36 {
72d839a4 37 if (isfinite (x) && isfinite (y))
0ac5ae23 38 {
d81f90cc 39 if (isnan (z))
0ac5ae23
UD
40 /* pow neg**non-int */
41 return __kernel_standard (x, y, 24);
42 else if (x == 0.0 && y < 0.0)
43 {
44 if (signbit (x) && signbit (z))
45 /* pow(-0.0,negative) */
46 return __kernel_standard (x, y, 23);
47 else
48 /* pow(+0.0,negative) */
49 return __kernel_standard (x, y, 43);
50 }
0d8733c4 51 else
0ac5ae23
UD
52 /* pow overflow */
53 return __kernel_standard (x, y, 21);
7ef90c15 54 }
f7eac6eb 55 }
0ac5ae23 56 }
72d839a4
JM
57 else if (__builtin_expect (z == 0.0, 0)
58 && isfinite (x) && x != 0 && isfinite (y)
0ac5ae23 59 && _LIB_VERSION != _IEEE_)
72d839a4
JM
60 /* pow underflow */
61 return __kernel_standard (x, y, 22);
0ac5ae23
UD
62
63 return z;
f7eac6eb 64}
a502c529
SN
65# if SHLIB_COMPAT (libm, GLIBC_2_0, GLIBC_2_29)
66compat_symbol (libm, __pow_compat, pow, GLIBC_2_0);
67# endif
68# ifdef NO_LONG_DOUBLE
69weak_alias (__pow_compat, powl)
70# endif
71# ifdef LONG_DOUBLE_COMPAT
72/* Work around gas bug "multiple versions for symbol". */
73weak_alias (__pow_compat, __pow_compat_alias)
74
75LONG_DOUBLE_COMPAT_CHOOSE_libm_powl (
76 compat_symbol (libm, __pow_compat_alias, powl, FIRST_VERSION_libm_powl), );
77# endif
cccda09f 78#endif