diff options
| author | Joseph Myers <josmyers@redhat.com> | 2025-03-14 15:58:11 +0000 |
|---|---|---|
| committer | Joseph Myers <josmyers@redhat.com> | 2025-03-14 15:58:11 +0000 |
| commit | 409668f6e88b63607e2cea29b3ce2a1c25f04bf1 (patch) | |
| tree | 0711db25c83b4f0bb67fd02ceddd707d561f5e33 /sysdeps | |
| parent | c7c4a5906f326f1290b1c2413a83c530564ec4b8 (diff) | |
| download | glibc-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 'sysdeps')
35 files changed, 236 insertions, 0 deletions
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions index d535a2df1a..b93723ef75 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions @@ -154,6 +154,7 @@ libm { __tanpiieee128; } GLIBC_2.42 { + __powrieee128; __rsqrtieee128; } } diff --git a/sysdeps/ieee754/ldbl-opt/Makefile b/sysdeps/ieee754/ldbl-opt/Makefile index dbc1ec4e2d..474f68ad7e 100644 --- a/sysdeps/ieee754/ldbl-opt/Makefile +++ b/sysdeps/ieee754/ldbl-opt/Makefile @@ -166,6 +166,7 @@ libnldbl-calls = \ obstack_vprintf \ obstack_vprintf_chk \ pow \ + powr \ printf \ printf_chk \ printf_fp \ @@ -375,6 +376,7 @@ CFLAGS-nldbl-nexttoward.c = -fno-builtin-nexttoward -fno-builtin-nexttowardl CFLAGS-nldbl-nexttowardf.c = -fno-builtin-nexttowardf CFLAGS-nldbl-nextup.c = -fno-builtin-nextupl CFLAGS-nldbl-pow.c = -fno-builtin-powl +CFLAGS-nldbl-powr.c = -fno-builtin-powrl CFLAGS-nldbl-remainder.c = -fno-builtin-remainderl -fno-builtin-dreml CFLAGS-nldbl-remquo.c = -fno-builtin-remquol CFLAGS-nldbl-rint.c = -fno-builtin-rintl diff --git a/sysdeps/ieee754/ldbl-opt/nldbl-powr.c b/sysdeps/ieee754/ldbl-opt/nldbl-powr.c new file mode 100644 index 0000000000..f828c83662 --- /dev/null +++ b/sysdeps/ieee754/ldbl-opt/nldbl-powr.c @@ -0,0 +1,8 @@ +#include "nldbl-compat.h" + +double +attribute_hidden +powrl (double x, double y) +{ + return powr (x, y); +} diff --git a/sysdeps/mach/hurd/i386/libm.abilist b/sysdeps/mach/hurd/i386/libm.abilist index 9e19a563f6..436ce76f77 100644 --- a/sysdeps/mach/hurd/i386/libm.abilist +++ b/sysdeps/mach/hurd/i386/libm.abilist @@ -1277,6 +1277,14 @@ GLIBC_2.41 tanpif32x F GLIBC_2.41 tanpif64 F GLIBC_2.41 tanpif64x F GLIBC_2.41 tanpil F +GLIBC_2.42 powr F +GLIBC_2.42 powrf F +GLIBC_2.42 powrf128 F +GLIBC_2.42 powrf32 F +GLIBC_2.42 powrf32x F +GLIBC_2.42 powrf64 F +GLIBC_2.42 powrf64x F +GLIBC_2.42 powrl F GLIBC_2.42 rsqrt F GLIBC_2.42 rsqrtf F GLIBC_2.42 rsqrtf128 F diff --git a/sysdeps/mach/hurd/x86_64/libm.abilist b/sysdeps/mach/hurd/x86_64/libm.abilist index 56b5025d7b..14fe8361c7 100644 --- a/sysdeps/mach/hurd/x86_64/libm.abilist +++ b/sysdeps/mach/hurd/x86_64/libm.abilist @@ -1134,6 +1134,14 @@ GLIBC_2.41 tanpif32x F GLIBC_2.41 tanpif64 F GLIBC_2.41 tanpif64x F GLIBC_2.41 tanpil F +GLIBC_2.42 powr F +GLIBC_2.42 powrf F +GLIBC_2.42 powrf128 F +GLIBC_2.42 powrf32 F +GLIBC_2.42 powrf32x F +GLIBC_2.42 powrf64 F +GLIBC_2.42 powrf64x F +GLIBC_2.42 powrl F GLIBC_2.42 rsqrt F GLIBC_2.42 rsqrtf F GLIBC_2.42 rsqrtf128 F diff --git a/sysdeps/unix/sysv/linux/aarch64/libm.abilist b/sysdeps/unix/sysv/linux/aarch64/libm.abilist index de093b244e..75ae1682f6 100644 --- a/sysdeps/unix/sysv/linux/aarch64/libm.abilist +++ b/sysdeps/unix/sysv/linux/aarch64/libm.abilist @@ -1245,6 +1245,14 @@ GLIBC_2.41 tanpif32x F GLIBC_2.41 tanpif64 F GLIBC_2.41 tanpif64x F GLIBC_2.41 tanpil F +GLIBC_2.42 powr F +GLIBC_2.42 powrf F +GLIBC_2.42 powrf128 F +GLIBC_2.42 powrf32 F +GLIBC_2.42 powrf32x F +GLIBC_2.42 powrf64 F +GLIBC_2.42 powrf64x F +GLIBC_2.42 powrl F GLIBC_2.42 rsqrt F GLIBC_2.42 rsqrtf F GLIBC_2.42 rsqrtf128 F diff --git a/sysdeps/unix/sysv/linux/alpha/libm.abilist b/sysdeps/unix/sysv/linux/alpha/libm.abilist index ead3d7362b..98406fa8d6 100644 --- a/sysdeps/unix/sysv/linux/alpha/libm.abilist +++ b/sysdeps/unix/sysv/linux/alpha/libm.abilist @@ -1404,6 +1404,14 @@ GLIBC_2.41 tanpif32x F GLIBC_2.41 tanpif64 F GLIBC_2.41 tanpif64x F GLIBC_2.41 tanpil F +GLIBC_2.42 powr F +GLIBC_2.42 powrf F +GLIBC_2.42 powrf128 F +GLIBC_2.42 powrf32 F +GLIBC_2.42 powrf32x F +GLIBC_2.42 powrf64 F +GLIBC_2.42 powrf64x F +GLIBC_2.42 powrl F GLIBC_2.42 rsqrt F GLIBC_2.42 rsqrtf F GLIBC_2.42 rsqrtf128 F diff --git a/sysdeps/unix/sysv/linux/arc/libm.abilist b/sysdeps/unix/sysv/linux/arc/libm.abilist index e31cd32c90..5dc92d8890 100644 --- a/sysdeps/unix/sysv/linux/arc/libm.abilist +++ b/sysdeps/unix/sysv/linux/arc/libm.abilist @@ -829,6 +829,12 @@ GLIBC_2.41 tanpif32 F GLIBC_2.41 tanpif32x F GLIBC_2.41 tanpif64 F GLIBC_2.41 tanpil F +GLIBC_2.42 powr F +GLIBC_2.42 powrf F +GLIBC_2.42 powrf32 F +GLIBC_2.42 powrf32x F +GLIBC_2.42 powrf64 F +GLIBC_2.42 powrl F GLIBC_2.42 rsqrt F GLIBC_2.42 rsqrtf F GLIBC_2.42 rsqrtf32 F diff --git a/sysdeps/unix/sysv/linux/arm/be/libm.abilist b/sysdeps/unix/sysv/linux/arm/be/libm.abilist index cf32109fe3..9f5659220d 100644 --- a/sysdeps/unix/sysv/linux/arm/be/libm.abilist +++ b/sysdeps/unix/sysv/linux/arm/be/libm.abilist @@ -920,6 +920,12 @@ GLIBC_2.41 tanpif32 F GLIBC_2.41 tanpif32x F GLIBC_2.41 tanpif64 F GLIBC_2.41 tanpil F +GLIBC_2.42 powr F +GLIBC_2.42 powrf F +GLIBC_2.42 powrf32 F +GLIBC_2.42 powrf32x F +GLIBC_2.42 powrf64 F +GLIBC_2.42 powrl F GLIBC_2.42 rsqrt F GLIBC_2.42 rsqrtf F GLIBC_2.42 rsqrtf32 F diff --git a/sysdeps/unix/sysv/linux/arm/le/libm.abilist b/sysdeps/unix/sysv/linux/arm/le/libm.abilist index cf32109fe3..9f5659220d 100644 --- a/sysdeps/unix/sysv/linux/arm/le/libm.abilist +++ b/sysdeps/unix/sysv/linux/arm/le/libm.abilist @@ -920,6 +920,12 @@ GLIBC_2.41 tanpif32 F GLIBC_2.41 tanpif32x F GLIBC_2.41 tanpif64 F GLIBC_2.41 tanpil F +GLIBC_2.42 powr F +GLIBC_2.42 powrf F +GLIBC_2.42 powrf32 F +GLIBC_2.42 powrf32x F +GLIBC_2.42 powrf64 F +GLIBC_2.42 powrl F GLIBC_2.42 rsqrt F GLIBC_2.42 rsqrtf F GLIBC_2.42 rsqrtf32 F diff --git a/sysdeps/unix/sysv/linux/csky/libm.abilist b/sysdeps/unix/sysv/linux/csky/libm.abilist index 55f6bfcb72..ed35c4186e 100644 --- a/sysdeps/unix/sysv/linux/csky/libm.abilist +++ b/sysdeps/unix/sysv/linux/csky/libm.abilist @@ -895,6 +895,12 @@ GLIBC_2.41 tanpif32 F GLIBC_2.41 tanpif32x F GLIBC_2.41 tanpif64 F GLIBC_2.41 tanpil F +GLIBC_2.42 powr F +GLIBC_2.42 powrf F +GLIBC_2.42 powrf32 F +GLIBC_2.42 powrf32x F +GLIBC_2.42 powrf64 F +GLIBC_2.42 powrl F GLIBC_2.42 rsqrt F GLIBC_2.42 rsqrtf F GLIBC_2.42 rsqrtf32 F diff --git a/sysdeps/unix/sysv/linux/hppa/libm.abilist b/sysdeps/unix/sysv/linux/hppa/libm.abilist index e6aee7779e..bc2b238f72 100644 --- a/sysdeps/unix/sysv/linux/hppa/libm.abilist +++ b/sysdeps/unix/sysv/linux/hppa/libm.abilist @@ -920,6 +920,12 @@ GLIBC_2.41 tanpif32 F GLIBC_2.41 tanpif32x F GLIBC_2.41 tanpif64 F GLIBC_2.41 tanpil F +GLIBC_2.42 powr F +GLIBC_2.42 powrf F +GLIBC_2.42 powrf32 F +GLIBC_2.42 powrf32x F +GLIBC_2.42 powrf64 F +GLIBC_2.42 powrl F GLIBC_2.42 rsqrt F GLIBC_2.42 rsqrtf F GLIBC_2.42 rsqrtf32 F diff --git a/sysdeps/unix/sysv/linux/i386/libm.abilist b/sysdeps/unix/sysv/linux/i386/libm.abilist index fdf5178805..9c8ca94d07 100644 --- a/sysdeps/unix/sysv/linux/i386/libm.abilist +++ b/sysdeps/unix/sysv/linux/i386/libm.abilist @@ -1284,6 +1284,14 @@ GLIBC_2.41 tanpif32x F GLIBC_2.41 tanpif64 F GLIBC_2.41 tanpif64x F GLIBC_2.41 tanpil F +GLIBC_2.42 powr F +GLIBC_2.42 powrf F +GLIBC_2.42 powrf128 F +GLIBC_2.42 powrf32 F +GLIBC_2.42 powrf32x F +GLIBC_2.42 powrf64 F +GLIBC_2.42 powrf64x F +GLIBC_2.42 powrl F GLIBC_2.42 rsqrt F GLIBC_2.42 rsqrtf F GLIBC_2.42 rsqrtf128 F diff --git a/sysdeps/unix/sysv/linux/loongarch/lp64/libm.abilist b/sysdeps/unix/sysv/linux/loongarch/lp64/libm.abilist index deb97ccdb5..5dc51186d3 100644 --- a/sysdeps/unix/sysv/linux/loongarch/lp64/libm.abilist +++ b/sysdeps/unix/sysv/linux/loongarch/lp64/libm.abilist @@ -1124,6 +1124,14 @@ GLIBC_2.41 tanpif32x F GLIBC_2.41 tanpif64 F GLIBC_2.41 tanpif64x F GLIBC_2.41 tanpil F +GLIBC_2.42 powr F +GLIBC_2.42 powrf F +GLIBC_2.42 powrf128 F +GLIBC_2.42 powrf32 F +GLIBC_2.42 powrf32x F +GLIBC_2.42 powrf64 F +GLIBC_2.42 powrf64x F +GLIBC_2.42 powrl F GLIBC_2.42 rsqrt F GLIBC_2.42 rsqrtf F GLIBC_2.42 rsqrtf128 F diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist index cf32109fe3..9f5659220d 100644 --- a/sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist +++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist @@ -920,6 +920,12 @@ GLIBC_2.41 tanpif32 F GLIBC_2.41 tanpif32x F GLIBC_2.41 tanpif64 F GLIBC_2.41 tanpil F +GLIBC_2.42 powr F +GLIBC_2.42 powrf F +GLIBC_2.42 powrf32 F +GLIBC_2.42 powrf32x F +GLIBC_2.42 powrf64 F +GLIBC_2.42 powrl F GLIBC_2.42 rsqrt F GLIBC_2.42 rsqrtf F GLIBC_2.42 rsqrtf32 F diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist index 83d4a2e728..54c2e1414d 100644 --- a/sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist +++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist @@ -956,6 +956,12 @@ GLIBC_2.41 tanpif32 F GLIBC_2.41 tanpif32x F GLIBC_2.41 tanpif64 F GLIBC_2.41 tanpil F +GLIBC_2.42 powr F +GLIBC_2.42 powrf F +GLIBC_2.42 powrf32 F +GLIBC_2.42 powrf32x F +GLIBC_2.42 powrf64 F +GLIBC_2.42 powrl F GLIBC_2.42 rsqrt F GLIBC_2.42 rsqrtf F GLIBC_2.42 rsqrtf32 F diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libm.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libm.abilist index 1553be00f9..35b1cb1daf 100644 --- a/sysdeps/unix/sysv/linux/microblaze/be/libm.abilist +++ b/sysdeps/unix/sysv/linux/microblaze/be/libm.abilist @@ -920,6 +920,12 @@ GLIBC_2.41 tanpif32 F GLIBC_2.41 tanpif32x F GLIBC_2.41 tanpif64 F GLIBC_2.41 tanpil F +GLIBC_2.42 powr F +GLIBC_2.42 powrf F +GLIBC_2.42 powrf32 F +GLIBC_2.42 powrf32x F +GLIBC_2.42 powrf64 F +GLIBC_2.42 powrl F GLIBC_2.42 rsqrt F GLIBC_2.42 rsqrtf F GLIBC_2.42 rsqrtf32 F diff --git a/sysdeps/unix/sysv/linux/microblaze/le/libm.abilist b/sysdeps/unix/sysv/linux/microblaze/le/libm.abilist index 1553be00f9..35b1cb1daf 100644 --- a/sysdeps/unix/sysv/linux/microblaze/le/libm.abilist +++ b/sysdeps/unix/sysv/linux/microblaze/le/libm.abilist @@ -920,6 +920,12 @@ GLIBC_2.41 tanpif32 F GLIBC_2.41 tanpif32x F GLIBC_2.41 tanpif64 F GLIBC_2.41 tanpil F +GLIBC_2.42 powr F +GLIBC_2.42 powrf F +GLIBC_2.42 powrf32 F +GLIBC_2.42 powrf32x F +GLIBC_2.42 powrf64 F +GLIBC_2.42 powrl F GLIBC_2.42 rsqrt F GLIBC_2.42 rsqrtf F GLIBC_2.42 rsqrtf32 F diff --git a/sysdeps/unix/sysv/linux/mips/mips32/libm.abilist b/sysdeps/unix/sysv/linux/mips/mips32/libm.abilist index fa0a957b29..9cb21cf970 100644 --- a/sysdeps/unix/sysv/linux/mips/mips32/libm.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips32/libm.abilist @@ -920,6 +920,12 @@ GLIBC_2.41 tanpif32 F GLIBC_2.41 tanpif32x F GLIBC_2.41 tanpif64 F GLIBC_2.41 tanpil F +GLIBC_2.42 powr F +GLIBC_2.42 powrf F +GLIBC_2.42 powrf32 F +GLIBC_2.42 powrf32x F +GLIBC_2.42 powrf64 F +GLIBC_2.42 powrl F GLIBC_2.42 rsqrt F GLIBC_2.42 rsqrtf F GLIBC_2.42 rsqrtf32 F diff --git a/sysdeps/unix/sysv/linux/mips/mips64/libm.abilist b/sysdeps/unix/sysv/linux/mips/mips64/libm.abilist index 0f67bb42e4..947f69270d 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/libm.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips64/libm.abilist @@ -1245,6 +1245,14 @@ GLIBC_2.41 tanpif32x F GLIBC_2.41 tanpif64 F GLIBC_2.41 tanpif64x F GLIBC_2.41 tanpil F +GLIBC_2.42 powr F +GLIBC_2.42 powrf F +GLIBC_2.42 powrf128 F +GLIBC_2.42 powrf32 F +GLIBC_2.42 powrf32x F +GLIBC_2.42 powrf64 F +GLIBC_2.42 powrf64x F +GLIBC_2.42 powrl F GLIBC_2.42 rsqrt F |
