aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/ieee754/ldbl-opt
diff options
context:
space:
mode:
authorJoseph Myers <josmyers@redhat.com>2025-05-14 10:51:46 +0000
committerJoseph Myers <josmyers@redhat.com>2025-05-14 10:51:46 +0000
commit06caf53adfae0c93062edd62f83eed16ab5cec0b (patch)
tree75282662b640f39f04d13b7ba79eb3e9fb79e5ea /sysdeps/ieee754/ldbl-opt
parent36189c76fb9c0b281de23381ae5a462a7e102ee6 (diff)
downloadglibc-master.zip
glibc-master.tar.gz
glibc-master.tar.bz2
Implement C23 rootn.HEADmaster
C23 adds various <math.h> function families originally defined in TS 18661-4. Add the rootn functions, which compute the Yth root of X for integer Y (with a domain error if Y is 0, even if X is a NaN). The integer exponent has type long long int in C23; it was intmax_t in TS 18661-4, and as with other interfaces changed after their initial appearance in the TS, I don't think we need to support the original version of the interface. As with pown and compoundn, I strongly encourage searching for worst cases for ulps error for these implementations (necessarily non-exhaustively, given the size of the input space). I also expect a custom implementation for a given format could be much faster as well as more accurate, although the implementation is simpler than those for pown and compoundn. This completes adding to glibc those TS 18661-4 functions (ignoring DFP) that are included in C23. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118592 regarding the C23 mathematical functions (not just the TS 18661-4 ones) missing built-in functions in GCC, where such functions might usefully be added. Tested for x86_64 and x86, and with build-many-glibcs.py.
Diffstat (limited to 'sysdeps/ieee754/ldbl-opt')
-rw-r--r--sysdeps/ieee754/ldbl-opt/Makefile2
-rw-r--r--sysdeps/ieee754/ldbl-opt/nldbl-rootn.c8
2 files changed, 10 insertions, 0 deletions
diff --git a/sysdeps/ieee754/ldbl-opt/Makefile b/sysdeps/ieee754/ldbl-opt/Makefile
index 72369eb..c9791c5 100644
--- a/sysdeps/ieee754/ldbl-opt/Makefile
+++ b/sysdeps/ieee754/ldbl-opt/Makefile
@@ -181,6 +181,7 @@ libnldbl-calls = \
remainder \
remquo \
rint \
+ rootn \
round \
roundeven \
rsqrt \
@@ -384,6 +385,7 @@ 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
+CFLAGS-nldbl-rootn.c = -fno-builtin-rootnl
CFLAGS-nldbl-round.c = -fno-builtin-roundl
CFLAGS-nldbl-roundeven.c = -fno-builtin-roundevenl
CFLAGS-nldbl-rsqrt.c = -fno-builtin-rsqrtl
diff --git a/sysdeps/ieee754/ldbl-opt/nldbl-rootn.c b/sysdeps/ieee754/ldbl-opt/nldbl-rootn.c
new file mode 100644
index 0000000..fb0d860
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-opt/nldbl-rootn.c
@@ -0,0 +1,8 @@
+#include "nldbl-compat.h"
+
+double
+attribute_hidden
+rootnl (double x, long long int y)
+{
+ return rootn (x, y);
+}