aboutsummaryrefslogtreecommitdiff
path: root/math/Makefile
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2021-09-28 23:31:35 +0000
committerJoseph Myers <joseph@codesourcery.com>2021-09-28 23:31:35 +0000
commit90f0ac10a74b2d43b5a65aab4be40565e359be43 (patch)
treeab0e73d7c60a7255fa5e7c9cbe58e80c3eb8d9cd /math/Makefile
parent5bf07e1b3a74232bfb8332275110be1a5da50f83 (diff)
downloadglibc-90f0ac10a74b2d43b5a65aab4be40565e359be43.zip
glibc-90f0ac10a74b2d43b5a65aab4be40565e359be43.tar.gz
glibc-90f0ac10a74b2d43b5a65aab4be40565e359be43.tar.bz2
Add fmaximum, fminimum functions
C2X adds new <math.h> functions for floating-point maximum and minimum, corresponding to the new operations that were added in IEEE 754-2019 because of concerns about the old operations not being associative in the presence of signaling NaNs. fmaximum and fminimum handle NaNs like most <math.h> functions (any NaN argument means the result is a quiet NaN). fmaximum_num and fminimum_num handle both quiet and signaling NaNs the way fmax and fmin handle quiet NaNs (if one argument is a number and the other is a NaN, return the number), but still raise "invalid" for a signaling NaN argument, making them exceptions to the normal rule that a function with a floating-point result raising "invalid" also returns a quiet NaN. fmaximum_mag, fminimum_mag, fmaximum_mag_num and fminimum_mag_num are corresponding functions returning the argument with greatest or least absolute value. All these functions also treat +0 as greater than -0. There are also corresponding <tgmath.h> type-generic macros. Add these functions to glibc. The implementations use type-generic templates based on those for fmax, fmin, fmaxmag and fminmag, and test inputs are based on those for those functions with appropriate adjustments to the expected results. The RISC-V maintainers might wish to add optimized versions of fmaximum_num and fminimum_num (for float and double), since RISC-V (F extension version 2.2 and later) provides instructions corresponding to those functions - though it might be at least as useful to add architecture-independent built-in functions to GCC and teach the RISC-V back end to expand those functions inline, which is what you generally want for functions that can be implemented with a single instruction. Tested for x86_64 and x86, and with build-many-glibcs.py.
Diffstat (limited to 'math/Makefile')
-rw-r--r--math/Makefile25
1 files changed, 20 insertions, 5 deletions
diff --git a/math/Makefile b/math/Makefile
index 8d67bff..af734d4 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -60,7 +60,10 @@ gen-libm-calls = cargF conjF cimagF crealF cabsF e_scalbF s_cacosF \
w_exp2F w_fmodF w_hypotF w_j0F w_j1F w_jnF w_logF \
w_log10F w_log2F w_powF w_remainderF w_scalbF \
w_sinhF w_sqrtF \
- w_tgammaF w_lgammaF w_lgammaF_r w_expF e_exp2F
+ w_tgammaF w_lgammaF w_lgammaF_r w_expF e_exp2F \
+ s_fmaximumF s_fmaximum_magF s_fmaximum_numF \
+ s_fmaximum_mag_numF s_fminimumF s_fminimum_magF \
+ s_fminimum_numF s_fminimum_mag_numF
libm-calls = \
e_acosF e_acoshF e_asinF e_atan2F e_atanhF e_coshF e_expF e_fmodF \
@@ -287,9 +290,11 @@ libm-test-funcs-auto = acos acosh asin asinh atan atan2 atanh cabs cacos \
lgamma log log10 log1p log2 pow sin sincos sinh sqrt \
tan tanh tgamma y0 y1 yn
libm-test-funcs-noauto = canonicalize ceil cimag conj copysign cproj creal \
- fabs fdim floor fmax fmaxmag fmin fminmag fmod \
- fpclassify frexp fromfp fromfpx getpayload ilogb \
- iscanonical iseqsig isfinite isgreater \
+ fabs fdim floor fmax fmaximum fmaximum_mag \
+ fmaximum_mag_num fmaximum_num fmaxmag fmin fminimum \
+ fminimum_mag fminimum_mag_num fminimum_num fminmag \
+ fmod fpclassify frexp fromfp fromfpx getpayload \
+ ilogb iscanonical iseqsig isfinite isgreater \
isgreaterequal isinf isless islessequal \
islessgreater isnan isnormal issignaling issubnormal \
isunordered iszero llogb llrint llround logb lrint \
@@ -375,7 +380,9 @@ tgmath3-macros = atan2 cbrt ceil copysign erf erfc exp2 expm1 fdim floor \
nextafter nexttoward remainder remquo rint round scalbn \
scalbln tgamma trunc acos asin atan acosh asinh atanh cos \
sin tan cosh sinh tanh exp log pow sqrt fabs carg cimag conj \
- cproj creal roundeven nextup nextdown fminmag fmaxmag llogb \
+ cproj creal roundeven nextup nextdown fminmag fmaxmag \
+ fmaximum fmaximum_mag fmaximum_num fmaximum_mag_num \
+ fminimum fminimum_mag fminimum_num fminimum_mag_num llogb \
fromfp fromfpx ufromfp ufromfpx scalb $(tgmath3-narrow-macros)
tgmath3-macro-tests = $(addprefix test-tgmath3-,$(tgmath3-macros))
tests += $(tgmath3-macro-tests)
@@ -682,8 +689,16 @@ CFLAGS-s_finite.c += -fno-builtin-finitel
CFLAGS-s_floor.c += -fno-builtin-floorl
CFLAGS-s_fma.c += -fno-builtin-fmal
CFLAGS-s_fmax.c += -fno-builtin-fmaxl
+CFLAGS-s_fmaximum.c += -fno-builtin-fmaximuml
+CFLAGS-s_fmaximum_mag.c += -fno-builtin-fmaximum_magl
+CFLAGS-s_fmaximum_mag_num.c += -fno-builtin-fmaximum_mag_numl
+CFLAGS-s_fmaximum_num.c += -fno-builtin-fmaximum_numl
CFLAGS-s_fmaxmag.c += -fno-builtin-fmaxmagl
CFLAGS-s_fmin.c += -fno-builtin-fminl
+CFLAGS-s_fminimum.c += -fno-builtin-fminimuml
+CFLAGS-s_fminimum_mag.c += -fno-builtin-fminimum_magl
+CFLAGS-s_fminimum_mag_num.c += -fno-builtin-fminimum_mag_numl
+CFLAGS-s_fminimum_num.c += -fno-builtin-fminimum_numl
CFLAGS-s_fminmag.c += -fno-builtin-fminmagl
CFLAGS-w_fmod.c += -fno-builtin-fmodl
CFLAGS-s_fmul.c += -fno-builtin-fmull