aboutsummaryrefslogtreecommitdiff
path: root/math/Makefile
diff options
context:
space:
mode:
authorJoseph Myers <josmyers@redhat.com>2025-03-14 15:58:11 +0000
committerJoseph Myers <josmyers@redhat.com>2025-03-14 15:58:11 +0000
commit409668f6e88b63607e2cea29b3ce2a1c25f04bf1 (patch)
tree0711db25c83b4f0bb67fd02ceddd707d561f5e33 /math/Makefile
parentc7c4a5906f326f1290b1c2413a83c530564ec4b8 (diff)
downloadglibc-409668f6e88b63607e2cea29b3ce2a1c25f04bf1.tar.xz
glibc-409668f6e88b63607e2cea29b3ce2a1c25f04bf1.zip
Implement C23 powr
C23 adds various <math.h> function families originally defined in TS 18661-4. Add the powr functions, which are like pow, but with simpler handling of special cases (based on exp(y*log(x)), so negative x and 0^0 are domain errors, powers of -0 are always +0 or +Inf never -0 or -Inf, and 1^+-Inf and Inf^0 are also domain errors, while NaN^0 and 1^NaN are NaN). The test inputs are taken from those for pow, with appropriate adjustments (including removing all tests that would be domain errors from those in auto-libm-test-in and adding some more such tests in libm-test-powr.inc). The underlying implementation uses __ieee754_pow functions after dealing with all special cases that need to be handled differently. It might be a little faster (avoiding a wrapper and redundant checks for special cases) to have an underlying implementation built separately for both pow and powr with compile-time conditionals for special-case handling, but I expect the benefit of that would be limited given that both functions will end up needing to use the same logic for computing pow outside of special cases. My understanding is that powr(negative, qNaN) should raise "invalid": that the rule on "invalid" for an argument outside the domain of the function takes precedence over a quiet NaN argument producing a quiet NaN result with no exceptions raised (for rootn it's explicit that the 0th root of qNaN raises "invalid"). I've raised this on the WG14 reflector to confirm the intent. Tested for x86_64 and x86, and with build-many-glibcs.py.
Diffstat (limited to 'math/Makefile')
-rw-r--r--math/Makefile6
1 files changed, 6 insertions, 0 deletions
diff --git a/math/Makefile b/math/Makefile
index b1d7c767f7..64d9d4d1e5 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -139,6 +139,7 @@ gen-libm-calls = \
s_log2p1F \
s_nanF \
s_nextdownF \
+ s_powrF \
s_rsqrtF \
s_significandF \
s_sinpiF \
@@ -685,6 +686,7 @@ libm-test-funcs-auto = \
log1p \
log2p1 \
pow \
+ powr \
rsqrt \
sin \
sincos \
@@ -1016,6 +1018,7 @@ tgmath3-macros = \
nexttoward \
nextup \
pow \
+ powr \
remainder \
remquo \
rint \
@@ -1439,6 +1442,7 @@ CFLAGS-s_nexttoward.c += -fno-builtin-nexttoward -fno-builtin-nexttowardl
CFLAGS-s_nexttowardf.c += -fno-builtin-nexttowardf
CFLAGS-s_nextup.c += -fno-builtin-nextupl
CFLAGS-e_pow.c += -fno-builtin-powl
+CFLAGS-s_powr.c += -fno-builtin-powrl
CFLAGS-w_remainder.c += -fno-builtin-remainderl -fno-builtin-dreml
CFLAGS-s_remquo.c += -fno-builtin-remquol
CFLAGS-s_rint.c += -fno-builtin-rintl
@@ -1574,6 +1578,7 @@ CFLAGS-s_nextafter.c += -fno-builtin-nextafterf32x -fno-builtin-nextafterf64
CFLAGS-s_nextdown.c += -fno-builtin-nextdownf32x -fno-builtin-nextdownf64
CFLAGS-s_nextup.c += -fno-builtin-nextupf32x -fno-builtin-nextupf64
CFLAGS-e_pow.c += -fno-builtin-powf32x -fno-builtin-powf64
+CFLAGS-s_powr.c += -fno-builtin-powrf32x -fno-builtin-powrf64
CFLAGS-w_remainder.c += -fno-builtin-remainderf32x -fno-builtin-remainderf64
CFLAGS-s_remquo.c += -fno-builtin-remquof32x -fno-builtin-remquof64
CFLAGS-s_rint.c += -fno-builtin-rintf32x -fno-builtin-rintf64
@@ -1700,6 +1705,7 @@ CFLAGS-s_nextafterf.c += -fno-builtin-nextafterf32
CFLAGS-s_nextdownf.c += -fno-builtin-nextdownf32
CFLAGS-s_nextupf.c += -fno-builtin-nextupf32
CFLAGS-e_powf.c += -fno-builtin-powf32
+CFLAGS-s_powrf.c += -fno-builtin-powrf32
CFLAGS-w_remainderf.c += -fno-builtin-remainderf32
CFLAGS-s_remquof.c += -fno-builtin-remquof32
CFLAGS-s_rintf.c += -fno-builtin-rintf32