* [PATCH 01/12] math: Reformat Makefile.
2023-12-28 17:20 [PATCH 00/12] Improve rounding to interger function for C23 Adhemerval Zanella
@ 2023-12-28 17:20 ` Adhemerval Zanella
2024-04-01 13:57 ` H.J. Lu
2023-12-28 17:20 ` [PATCH 02/12] powerpc: Add missing arch flags on rounding ifunc variants Adhemerval Zanella
` (11 subsequent siblings)
12 siblings, 1 reply; 27+ messages in thread
From: Adhemerval Zanella @ 2023-12-28 17:20 UTC (permalink / raw)
To: libc-alpha
Reflow all long lines adding comment terminators.
Sort all reflowed text using scripts/sort-makefile-lines.py.
No code generation changes observed in binary artifacts.
No regressions on x86_64 and i686.
---
math/Makefile | 844 ++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 685 insertions(+), 159 deletions(-)
diff --git a/math/Makefile b/math/Makefile
index a9daae09de..5a912c55bd 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -22,87 +22,279 @@ subdir := math
include ../Makeconfig
# Installed header files.
-headers := math.h bits/mathcalls.h \
- fpu_control.h complex.h bits/cmathcalls.h fenv.h \
- bits/fenv.h bits/mathdef.h tgmath.h \
- bits/math-vector.h finclude/math-vector-fortran.h \
- bits/libm-simd-decl-stubs.h bits/iscanonical.h \
- bits/flt-eval-method.h bits/fp-fast.h bits/fp-logb.h \
- bits/long-double.h bits/mathcalls-helper-functions.h \
- bits/floatn.h bits/floatn-common.h bits/mathcalls-narrow.h
+headers := \
+ math.h \
+ bits/mathcalls.h \
+ fpu_control.h \
+ complex.h \
+ bits/cmathcalls.h \
+ fenv.h \
+ bits/fenv.h \
+ bits/mathdef.h \
+ tgmath.h \
+ bits/math-vector.h \
+ finclude/math-vector-fortran.h \
+ bits/libm-simd-decl-stubs.h \
+ bits/iscanonical.h \
+ bits/flt-eval-method.h \
+ bits/fp-fast.h \
+ bits/fp-logb.h \
+ bits/long-double.h \
+ bits/mathcalls-helper-functions.h \
+ bits/floatn.h \
+ bits/floatn-common.h \
+ bits/mathcalls-narrow.h
+ # headers
# FPU support code.
-aux := setfpucw fpu_control
+aux := \
+ fpu_control \
+ setfpucw \
+ # aux
# Build the -lm library.
extra-libs := libm
extra-libs-others = $(extra-libs)
-libm-support = s_lib_version s_matherr s_signgam \
- fclrexcpt fgetexcptflg fraiseexcpt fsetexcptflg \
- ftestexcept fegetround fesetround fegetenv feholdexcpt \
- fesetenv feupdateenv fedisblxcpt feenablxcpt \
- fegetexcept fesetexcept fetestexceptflag fegetmode \
- fesetmode
+libm-support = \
+ fclrexcpt \
+ fedisblxcpt \
+ feenablxcpt \
+ fegetenv \
+ fegetexcept \
+ fegetmode \
+ fegetround \
+ feholdexcpt \
+ fesetenv \
+ fesetexcept \
+ fesetmode\
+ fesetround \
+ fetestexceptflag \
+ feupdateenv \
+ fgetexcptflg \
+ fraiseexcpt \
+ fsetexcptflg \
+ ftestexcept \
+ s_lib_version \
+ s_matherr \
+ s_signgam \
+ # libm-support
# Wrappers for these functions generated per type using a file named
# <func>_template.c and the appropriate math-type-macros-<TYPE>.h.
-gen-libm-calls = cargF conjF cimagF crealF cabsF e_scalbF s_cacosF \
- s_cacoshF s_ccosF s_ccoshF s_casinF s_csinF s_casinhF \
- k_casinhF s_csinhF k_casinhF s_csinhF s_catanhF s_catanF \
- s_ctanF s_ctanhF s_cexpF s_clogF s_cprojF s_csqrtF \
- s_cpowF s_clog10F s_fdimF s_nextdownF s_fmaxF s_fminF \
- s_nanF s_iseqsigF s_canonicalizeF s_significandF \
- w_ilogbF w_llogbF \
- w_log1pF w_scalblnF s_fmaxmagF s_fminmagF w_acosF \
- w_acoshF w_asinF w_atan2F w_atanhF w_coshF w_exp10F \
- 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 \
- 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 \
- e_hypotF e_j0F e_j1F e_jnF e_lgammaF_r e_logF e_log10F e_powF \
- e_remainderF e_sinhF e_sqrtF e_gammaF_r \
- e_ilogbF \
- k_tanF s_asinhF s_atanF s_cbrtF \
- s_ceilF s_cosF s_erfF s_expm1F s_fabsF \
- s_floorF s_log1pF s_logbF \
- s_nextafterF s_nexttowardF s_rintF s_scalblnF \
- s_sinF s_tanF s_tanhF \
- s_fpclassifyF s_truncF \
- s_remquoF e_log2F s_roundF s_nearbyintF s_sincosF \
- s_fmaF s_lrintF s_llrintF s_lroundF s_llroundF e_exp10F \
- s_issignalingF $(calls:s_%=m_%) x2y2m1F \
- gamma_productF lgamma_negF lgamma_productF \
- s_nextupF s_totalorderF s_totalordermagF s_getpayloadF \
- s_setpayloadF s_setpayloadsigF s_roundevenF s_fromfpF s_ufromfpF \
- s_fromfpxF s_ufromfpxF $(gen-libm-calls)
-
-libm-compat-calls = \
- w_acosF_compat w_acoshF_compat w_asinF_compat w_atan2F_compat \
- w_atanhF_compat w_coshF_compat w_exp2F_compat w_exp10F_compat \
- w_fmodF_compat w_hypotF_compat w_j0F_compat w_j1F_compat \
- w_jnF_compat w_log2F_compat w_log10F_compat w_logF_compat \
- w_powF_compat w_remainderF_compat w_scalbF_compat \
- w_sinhF_compat w_sqrtF_compat w_tgammaF_compat \
- w_lgammaF_r_compat w_lgammaF_compat2 w_expF_compat \
- w_lgamma_compatF k_standardF
-
-libm-narrow-fns = add div fma mul sqrt sub
-libm-narrow-types-basic = s_fF s_f32xFf64
-libm-narrow-types-ldouble-yes = s_fFl s_dFl
-libm-narrow-types-float128-yes = s_f32Ff128 s_f64Ff128 s_f64xFf128
-libm-narrow-types-float128-alias-yes = s_f64xFf128
-libm-narrow-types = $(libm-narrow-types-basic) \
- $(libm-narrow-types-ldouble-$(long-double-fcts)) \
- $(libm-narrow-types-float128-$(float128-fcts)) \
- $(libm-narrow-types-float128-alias-$(float128-alias-fcts))
+gen-libm-calls = \
+ cabsF \
+ cargF \
+ cimagF \
+ conjF \
+ crealF \
+ e_exp2F \
+ e_scalbF \
+ k_casinhF \
+ k_casinhF \
+ s_cacosF \
+ s_cacoshF \
+ s_canonicalizeF \
+ s_casinF \
+ s_casinhF \
+ s_catanF \
+ s_catanhF \
+ s_ccosF \
+ s_ccoshF \
+ s_cexpF \
+ s_clog10F \
+ s_clogF \
+ s_cpowF \
+ s_cprojF \
+ s_csinF \
+ s_csinhF \
+ s_csinhF \
+ s_csqrtF \
+ s_ctanF \
+ s_ctanhF \
+ s_fdimF \
+ s_fmaxF \
+ s_fmaximumF \
+ s_fmaximum_magF \
+ s_fmaximum_mag_numF \
+ s_fmaximum_numF \
+ s_fmaxmagF \
+ s_fminF \
+ s_fminimumF \
+ s_fminimum_magF \
+ s_fminimum_mag_numF \
+ s_fminimum_numF \
+ s_fminmagF \
+ s_iseqsigF \
+ s_nanF \
+ s_nextdownF \
+ s_significandF \
+ w_acosF \
+ w_acoshF \
+ w_asinF \
+ w_atan2F \
+ w_atanhF \
+ w_coshF \
+ w_exp10F \
+ w_exp2F \
+ w_expF \
+ w_fmodF \
+ w_hypotF \
+ w_ilogbF \
+ w_j0F \
+ w_j1F \
+ w_jnF \
+ w_lgammaF \
+ w_lgammaF_r \
+ w_llogbF \
+ w_log10F \
+ w_log1pF \
+ w_log2F \
+ w_logF \
+ w_powF \
+ w_remainderF \
+ w_scalbF \
+ w_scalblnF \
+ w_sinhF \
+ w_sqrtF \
+ w_tgammaF \
+ # gen-libm-calls
+
+libm-calls = \
+ $(calls:s_%=m_%) \
+ $(gen-libm-calls) \
+ e_acosF \
+ e_acoshF \
+ e_asinF \
+ e_atan2F \
+ e_atanhF \
+ e_coshF \
+ e_exp10F \
+ e_expF \
+ e_fmodF \
+ e_gammaF_r \
+ e_hypotF \
+ e_ilogbF \
+ e_j0F \
+ e_j1F \
+ e_jnF \
+ e_lgammaF_r \
+ e_log10F \
+ e_log2F \
+ e_logF \
+ e_powF \
+ e_remainderF \
+ e_sinhF \
+ e_sqrtF \
+ gamma_productF \
+ k_tanF \
+ lgamma_negF \
+ lgamma_productF \
+ s_asinhF \
+ s_atanF \
+ s_cbrtF \
+ s_ceilF \
+ s_cosF \
+ s_erfF \
+ s_expm1F \
+ s_fabsF \
+ s_floorF \
+ s_fmaF \
+ s_fpclassifyF \
+ s_fromfpF \
+ s_fromfpxF \
+ s_getpayloadF \
+ s_issignalingF \
+ s_llrintF \
+ s_llroundF \
+ s_log1pF \
+ s_logbF \
+ s_lrintF \
+ s_lroundF \
+ s_nearbyintF \
+ s_nextafterF \
+ s_nexttowardF \
+ s_nextupF \
+ s_remquoF \
+ s_rintF \
+ s_roundF \
+ s_roundevenF \
+ s_scalblnF \
+ s_setpayloadF \
+ s_setpayloadsigF \
+ s_sinF \
+ s_sincosF \
+ s_tanF \
+ s_tanhF \
+ s_totalorderF \
+ s_totalordermagF \
+ s_truncF \
+ s_ufromfpF \
+ s_ufromfpxF \
+ x2y2m1F \
+ # libm-calls
+
+libm-compat-calls = \
+ k_standardF \
+ w_acosF_compat \
+ w_acoshF_compat \
+ w_asinF_compat \
+ w_atan2F_compat \
+ w_atanhF_compat \
+ w_coshF_compat \
+ w_exp10F_compat \
+ w_exp2F_compat \
+ w_expF_compat \
+ w_fmodF_compat \
+ w_hypotF_compat \
+ w_j0F_compat \
+ w_j1F_compat\
+ w_jnF_compat \
+ w_lgammaF_compat2 \
+ w_lgammaF_r_compat \
+ w_lgamma_compatF \
+ w_log10F_compat \
+ w_log2F_compat \
+ w_logF_compat \
+ w_powF_compat \
+ w_remainderF_compat \
+ w_scalbF_compat \
+ w_sinhF_compat \
+ w_sqrtF_compat \
+ w_tgammaF_compat \
+ # libm-compat-calls
+
+libm-narrow-fns = \
+ add \
+ div \
+ fma \
+ mul \
+ sqrt \
+ sub \
+ # libm-narrow-fns
+libm-narrow-types-basic = \
+ s_f32xFf64 \
+ s_fF \
+ # libm-narrow-types-basic
+libm-narrow-types-ldouble-yes = \
+ s_dFl \
+ s_fFl \
+ # libm-narrow-types-ldouble-yes
+libm-narrow-types-float128-yes = \
+ s_f32Ff128 \
+ s_f64Ff128 \
+ s_f64xFf128 \
+ # libm-narrow-types-float128-yes
+libm-narrow-types-float128-alias-yes = \
+ s_f64xFf128 \
+ # libm-narrow-types-float128-alias-yes
+libm-narrow-types = \
+ $(libm-narrow-types-basic) \
+ $(libm-narrow-types-float128-$(float128-fcts)) \
+ $(libm-narrow-types-float128-alias-$(float128-alias-fcts)) \
+ $(libm-narrow-types-ldouble-$(long-double-fcts)) \
+ # libm-narrow-types
# Type specific routine support.
#
@@ -115,33 +307,65 @@ libm-narrow-types = $(libm-narrow-types-basic) \
# Finally, note that types is an intentionally recursive variable.
# We only know the full set of supported types for the target machine
# after the Rules makefile has been parsed.
-types-basic = $(type-ldouble-$(long-double-fcts)) double float
+types-basic = \
+ $(type-ldouble-$(long-double-fcts)) \
+ double \
+ float \
+ # types-basic
# Like types, but includes types whose functions alias those for
# another type.
-test-types-basic = ldouble double float
+test-types-basic = \
+ double \
+ float \
+ ldouble \
+ # test-types-basic
# long double support
type-ldouble-suffix := l
-type-ldouble-routines := t_sincosl k_sinl k_cosl k_sincosl s_iscanonicall \
- e_rem_pio2l
+type-ldouble-routines := \
+ e_rem_pio2l \
+ k_cosl \
+ k_sincosl \
+ k_sinl \
+ s_iscanonicall \
+ t_sincosl \
+ # type-ldouble-routines
type-ldouble-yes := ldouble
# double support
type-double-suffix :=
-type-double-routines := branred k_rem_pio2 \
- sincostab math_err e_exp_data e_log_data \
- e_log2_data e_pow_log_data
+type-double-routines := \
+ branred \
+ e_exp_data \
+ e_log2_data \
+ e_log_data \
+ e_pow_log_data \
+ k_rem_pio2 \
+ math_err \
+ sincostab \
+ # type-double-routines
# float support
type-float-suffix := f
-type-float-routines := math_errf e_exp2f_data e_logf_data \
- e_log2f_data e_powf_log2_data s_sincosf_data
+type-float-routines := \
+ e_exp2f_data \
+ e_log2f_data \
+ e_logf_data \
+ e_powf_log2_data \
+ math_errf \
+ s_sincosf_data \
+ # type-float-routines
# _Float128 support
type-float128-suffix := f128
-type-float128-routines := t_sincosf128 k_sinf128 k_cosf128 k_sincosf128 \
- e_rem_pio2f128
+type-float128-routines := \
+ e_rem_pio2f128 \
+ k_cosf128 \
+ k_sincosf128 \
+ k_sinf128 \
+ t_sincosf128 \
+ # type-float128-routines
type-float128-yes := float128
# _Float64x may be supported, only as an alias type.
@@ -151,11 +375,20 @@ type-float64x-yes := float64x
type-ibm128-suffix := l
type-ibm128-yes := ibm128
-types = $(types-basic) $(type-float128-$(float128-fcts))
-test-types = $(test-types-basic) $(type-float128-$(float128-fcts)) \
- float32 float64 $(type-float128-$(float128-alias-fcts)) \
- float32x $(type-float64x-$(float64x-alias-fcts)) \
- $(type-ibm128-$(ibm128-fcts))
+types = \
+ $(type-float128-$(float128-fcts)) \
+ $(types-basic) \
+ # types
+test-types = \
+ $(test-types-basic) \
+ $(type-float128-$(float128-alias-fcts)) \
+ $(type-float128-$(float128-fcts)) \
+ $(type-float64x-$(float64x-alias-fcts)) \
+ $(type-ibm128-$(ibm128-fcts)) \
+ float32 \
+ float32x \
+ float64 \
+ # test-types
# Pairs of types for which narrowing functions should be tested (this
# variable has more entries than libm-narrow-types because it includes
@@ -163,14 +396,25 @@ test-types = $(test-types-basic) $(type-float128-$(float128-fcts)) \
# for other types). This definition embeds the assumption that if
# _Float64x is supported, so is _Float128, and vice versa (they may or
# may not have the same format).
-test-type-pairs = float-double float-ldouble double-ldouble \
- float32-float64 float32-float32x float32x-float64 \
- $(test-type-pairs-f64xf128-$(float128-fcts)) \
- $(test-type-pairs-f64xf128-$(float128-alias-fcts))
-test-type-pairs-f64xf128-yes = float32-float64x float32-float128 \
- float64-float64x float64-float128 \
- float32x-float64x float32x-float128 \
- float64x-float128
+test-type-pairs = \
+ $(test-type-pairs-f64xf128-$(float128-alias-fcts)) \
+ $(test-type-pairs-f64xf128-$(float128-fcts)) \
+ double-ldouble \
+ float-double \
+ float-ldouble \
+ float32-float32x \
+ float32-float64 \
+ float32x-float64 \
+ # test-type-pairs
+test-type-pairs-f64xf128-yes = \
+ float32-float128 \
+ float32-float64x \
+ float32x-float128 \
+ float32x-float64x \
+ float64-float128 \
+ float64-float64x \
+ float64x-float128 \
+ # test-type-pairs-f64xf128-yes
# For each of the basic types (float, double, long double), replace the
# occurrences of 'F' in arg 1 with the appropriate suffix for the type.
@@ -193,8 +437,17 @@ libm-routines = $(strip $(libm-support) \
# and we don't want to have to link every program with -lm.
# In libm-calls (above), list m_foo in place of s_foo for any
# routine that should be compiled separately for its libc and libm versions.
-calls = s_isinfF s_isnanF s_finiteF s_copysignF s_modfF s_scalbnF s_frexpF \
- s_signbitF $(gen-calls)
+calls = \
+ $(gen-calls) \
+ s_copysignF \
+ s_finiteF \
+ s_frexpF \
+ s_isinfF \
+ s_isnanF \
+ s_modfF \
+ s_scalbnF \
+ s_signbitF \
+ # calls
gen-calls = s_ldexpF
generated += $(foreach s,.c .S,$(call type-foreach, $(calls:s_%=m_%$(s))))
routines = $(call type-foreach, $(calls))
@@ -205,8 +458,14 @@ libm-shared-only-routines = $(call type-foreach, $(calls:s_%=m_%))
ifeq ($(build-mathvec),yes)
# We need to install libm.so and libm.a as linker scripts
# for transparent use of vector math library.
-install-lib-ldscripts := libm.so libm.a
-install-others = $(inst_libdir)/libm.so $(inst_libdir)/libm.a
+install-lib-ldscripts := \
+ libm.a \
+ libm.so \
+ # install-lib-ldscripts
+install-others = \
+ $(inst_libdir)/libm.a \
+ $(inst_libdir)/libm.so \
+ # install-others
$(inst_libdir)/libm.so: $(common-objpfx)format.lds \
$(libm) \
$(libmvec) \
@@ -234,42 +493,95 @@ $(inst_libdir)/libm.a: $(common-objpfx)format.lds \
endif
# Rules for the test suite.
-tests = test-matherr-3 test-fenv basic-test \
- test-misc test-fpucw test-fpucw-ieee tst-definitions test-tgmath \
- test-tgmath-ret bug-nextafter bug-nexttoward bug-tgmath1 \
- test-tgmath-int test-tgmath2 test-powl tst-CMPLX tst-CMPLX2 test-snan \
- test-fenv-tls test-fenv-preserve test-fenv-return \
- test-nearbyint-except test-fenv-clear \
- test-nearbyint-except-2 test-signgam-uchar test-signgam-uchar-init \
- test-signgam-uint test-signgam-uint-init test-signgam-ullong \
- test-signgam-ullong-init test-nan-overflow test-nan-payload \
- test-fexcept test-fexcept-traps test-fesetexcept \
- test-fesetexcept-traps test-fetestexceptflag test-femode \
- test-femode-traps test-iszero-excess-precision \
- test-iseqsig-excess-precision test-flt-eval-method \
- test-fp-ilogb-constants test-fp-llogb-constants \
- test-narrow-macros \
- test-nan-const $(tests-static)
+tests = \
+ $(tests-static) \
+ bug-nextafter \
+ bug-nexttoward \
+ bug-tgmath1 \
+ test-femode \
+ test-femode-traps \
+ test-fenv basic-test \
+ test-fenv-clear \
+ test-fenv-preserve \
+ test-fenv-return \
+ test-fenv-tls \
+ test-fesetexcept \
+ test-fesetexcept-traps \
+ test-fetestexceptflag \
+ test-fexcept \
+ test-fexcept-traps \
+ test-flt-eval-method \
+ test-fp-ilogb-constants \
+ test-fp-llogb-constants \
+ test-fpucw \
+ test-fpucw-ieee \
+ test-iseqsig-excess-precision \
+ test-iszero-excess-precision \
+ test-matherr-3 \
+ test-misc \
+ test-nan-const \
+ test-nan-overflow \
+ test-nan-payload \
+ test-narrow-macros \
+ test-nearbyint-except \
+ test-nearbyint-except-2 \
+ test-powl \
+ test-signgam-uchar \
+ test-signgam-uchar-init \
+ test-signgam-uint \
+ test-signgam-uint-init \
+ test-signgam-ullong \
+ test-signgam-ullong-init \
+ test-snan \
+ test-tgmath \
+ test-tgmath-int \
+ test-tgmath-ret \
+ test-tgmath2 \
+ tst-CMPLX \
+ tst-CMPLX2 \
+ tst-definitions \
+ # tests
ifneq ($(config-cflags-signaling-nans),)
-tests += test-fe-snans-always-signal
+tests += \
+ test-fe-snans-always-signal \
+ # tests
endif
-tests-static = test-fpucw-static test-fpucw-ieee-static \
- test-signgam-uchar-static test-signgam-uchar-init-static \
- test-signgam-uint-static test-signgam-uint-init-static \
- test-signgam-ullong-static test-signgam-ullong-init-static
+tests-static = \
+ test-fpucw-ieee-static \
+ test-fpucw-static \
+ test-signgam-uchar-init-static \
+ test-signgam-uchar-static \
+ test-signgam-uint-init-static \
+ test-signgam-uint-static \
+ test-signgam-ullong-init-static \
+ test-signgam-ullong-static \
+ # tests-static
# The tested symbols matherr, _LIB_VERSION have been removed in glibc 2.27.
ifeq ($(have-GLIBC_2.26)$(build-shared),yesyes)
-tests += test-matherr test-matherr-2
+tests += \
+ test-matherr \
+ test-matherr-2 \
+ # tests
endif
# These tests use internal (unexported) GMP functions and are linked
# statically to obtain access to these functions.
-tests-static += atest-exp atest-sincos atest-exp2
+tests-static += \
+ atest-exp \
+ atest-exp2 \
+ atest-sincos \
+ # tests-static
ifneq (,$(CXX))
-tests += test-math-isinff test-math-iszero test-math-issignaling \
- test-math-iscanonical test-math-cxx11 test-math-iseqsig
+tests += \
+ test-math-cxx11 \
+ test-math-iscanonical \
+ test-math-iseqsig \
+ test-math-isinff \
+ test-math-issignaling \
+ test-math-iszero \
+ # tests
endif
libm-vec-tests = $(addprefix test-,$(libmvec-tests))
@@ -286,35 +598,167 @@ $(objpfx)libm-test-ulps.h: $(ulps-file) gen-libm-test.py
$(make-target-directory)
$(PYTHON) gen-libm-test.py -u $< -H $@
-libm-test-funcs-auto = acos acosh asin asinh atan atan2 atanh cabs cacos \
- cacosh carg casin casinh catan catanh cbrt ccos ccosh \
- cexp clog clog10 cos cosh cpow csin csinh csqrt ctan \
- ctanh erf erfc exp exp10 exp2 expm1 fma hypot j0 j1 jn \
- 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 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 \
- lround modf nearbyint nextafter nextdown nexttoward \
- nextup remainder remquo rint round roundeven scalb \
- scalbln scalbn setpayload setpayloadsig signbit \
- significand totalorder totalordermag trunc ufromfp \
- ufromfpx compat_totalorder compat_totalordermag
-libm-test-funcs-compat = compat_totalorder compat_totalordermag
-libm-test-funcs-narrow = add div fma mul sqrt sub
-libm-test-funcs-all = $(libm-test-funcs-auto) $(libm-test-funcs-noauto)
+libm-test-funcs-auto = \
+ acos \
+ acosh \
+ asin \
+ asinh \
+ atan \
+ atan2 \
+ atanh \
+ cabs \
+ cacos \
+ cacosh \
+ carg \
+ casin \
+ casinh \
+ catan \
+ catanh \
+ cbrt \
+ ccos \
+ ccosh \
+ cexp \
+ clog \
+ clog10 \
+ cos \
+ cosh \
+ cpow \
+ csin \
+ csinh \
+ csqrt \
+ ctan \
+ ctanh \
+ erf \
+ erfc \
+ exp \
+ exp2 \
+ exp10 \
+ expm1 \
+ fma \
+ hypot \
+ j0 \
+ j1 \
+ jn \
+ lgamma \
+ log \
+ log10 \
+ log1p \
+ log2 \
+ pow \
+ sin \
+ sincos \
+ sinh \
+ sqrt \
+ tan \
+ tanh \
+ tgamma \
+ y0 \
+ y1 \
+ yn \
+ # libm-test-funcs-auto
+libm-test-funcs-noauto = \
+ canonicalize \
+ ceil \
+ cimag \
+ compat_totalorder \
+ compat_totalordermag \
+ conj \
+ copysign \
+ cproj \
+ creal \
+ 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 \
+ lround \
+ modf \
+ nearbyint \
+ nextafter \
+ nextdown \
+ nexttoward \
+ nextup \
+ remainder \
+ remquo \
+ rint \
+ round \
+ roundeven \
+ scalb \
+ scalbln \
+ scalbn \
+ setpayload \
+ setpayloadsig \
+ signbit \
+ significand \
+ totalorder \
+ totalordermag \
+ trunc \
+ ufromfp \
+ ufromfpx \
+ # libm-test-funcs-noauto
+libm-test-funcs-compat = \
+ compat_totalorder \
+ compat_totalordermag \
+ # libm-test-funcs-compat
+libm-test-funcs-narrow = \
+ add \
+ div \
+ fma \
+ mul \
+ sqrt \
+ sub \
+ # libm-test-funcs-narrow
+libm-test-funcs-all = \
+ $(libm-test-funcs-auto) \
+ $(libm-test-funcs-noauto) \
+ # libm-test-funcs-all
libm-test-c-auto = $(foreach f,$(libm-test-funcs-auto),libm-test-$(f).c)
libm-test-c-noauto = $(foreach f,$(libm-test-funcs-noauto),libm-test-$(f).c)
libm-test-c-narrow = $(foreach f,$(libm-test-funcs-narrow),\
libm-test-narrow-$(f).c)
-generated += libm-test-ulps.h $(libm-test-c-auto) $(libm-test-c-noauto) \
- $(libm-test-c-narrow)
+generated += \
+ $(libm-test-c-auto) \
+ $(libm-test-c-narrow) \
+ $(libm-test-c-noauto) \
+ libm-test-ulps.h \
+ # generated
libm-tests-base-normal = $(foreach t,$(test-types),test-$(t))
libm-tests-base-narrow = $(foreach t,$(test-type-pairs),test-$(t))
@@ -374,19 +818,101 @@ $(foreach t,$(libm-tests-base),\
$(objpfx)$(t)-compat_totalordermag.o): $(objpfx)libm-test-totalordermag.c
# _Float128x omitted as not supported by gen-tgmath-tests.py.
-tgmath3-narrow-types = f d f16 f32 f64 f128 f32x f64x
+tgmath3-narrow-types = \
+ d \
+ f \
+ f16 \
+ f32 \
+ f128 \
+ f32x \
+ f64 \
+ f64x \
+ # tgmath3-narrow-types
tgmath3-narrow-macros = $(foreach t,$(tgmath3-narrow-types), \
$(foreach f,$(libm-narrow-fns),$(t)$(f)))
-tgmath3-macros = atan2 cbrt ceil copysign erf erfc exp10 exp2 expm1 fdim \
- floor fma fmax fmin fmod frexp hypot ilogb ldexp lgamma \
- llrint llround log10 log1p log2 logb lrint lround nearbyint \
- 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 \
- 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-macros = \
+ $(tgmath3-narrow-macros) \
+ acos \
+ acosh \
+ asin \
+ asinh \
+ atan \
+ atan2 \
+ atanh \
+ carg \
+ cbrt \
+ ceil \
+ cimag \
+ conj \
+ copysign \
+ cos \
+ cosh \
+ cproj \
+ creal \
+ erf \
+ erfc \
+ exp \
+ exp2 \
+ exp10 \
+ expm1 \
+ fabs \
+ fdim \
+ floor \
+ fma \
+ fmax \
+ fmaximum \
+ fmaximum_mag \
+ fmaximum_mag_num \
+ fmaximum_num \
+ fmaxmag \
+ fmin \
+ fminimum \
+ fminimum_mag \
+ fminimum_mag_num \
+ fminimum_num \
+ fminmag \
+ fmod \
+ frexp \
+ fromfp \
+ fromfpx \
+ hypot \
+ ilogb \
+ ldexp \
+ lgamma \
+ llogb \
+ llrint \
+ llround \
+ log \
+ log10 \
+ log1p \
+ log2 \
+ logb \
+ lrint \
+ lround \
+ nearbyint \
+ nextafter \
+ nextdown \
+ nexttoward \
+ nextup \
+ pow \
+ remainder \
+ remquo \
+ rint \
+ round \
+ roundeven \
+ scalb \
+ scalbln \
+ scalbn \
+ sin \
+ sinh \
+ sqrt \
+ tan \
+ tanh \
+ tgamma \
+ trunc \
+ ufromfp \
+ ufromfpx \
+ # tgmath3-macros
tgmath3-macro-tests = $(addprefix test-tgmath3-,$(tgmath3-macros))
tests += $(tgmath3-macro-tests)
generated += $(addsuffix .c,$(tgmath3-macro-tests))
--
2.34.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 01/12] math: Reformat Makefile.
2023-12-28 17:20 ` [PATCH 01/12] math: Reformat Makefile Adhemerval Zanella
@ 2024-04-01 13:57 ` H.J. Lu
0 siblings, 0 replies; 27+ messages in thread
From: H.J. Lu @ 2024-04-01 13:57 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: libc-alpha
On Thu, Dec 28, 2023 at 9:21 AM Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
>
> Reflow all long lines adding comment terminators.
> Sort all reflowed text using scripts/sort-makefile-lines.py.
>
> No code generation changes observed in binary artifacts.
> No regressions on x86_64 and i686.
> ---
> math/Makefile | 844 ++++++++++++++++++++++++++++++++++++++++----------
> 1 file changed, 685 insertions(+), 159 deletions(-)
>
> diff --git a/math/Makefile b/math/Makefile
> index a9daae09de..5a912c55bd 100644
> --- a/math/Makefile
> +++ b/math/Makefile
> @@ -22,87 +22,279 @@ subdir := math
> include ../Makeconfig
>
> # Installed header files.
> -headers := math.h bits/mathcalls.h \
> - fpu_control.h complex.h bits/cmathcalls.h fenv.h \
> - bits/fenv.h bits/mathdef.h tgmath.h \
> - bits/math-vector.h finclude/math-vector-fortran.h \
> - bits/libm-simd-decl-stubs.h bits/iscanonical.h \
> - bits/flt-eval-method.h bits/fp-fast.h bits/fp-logb.h \
> - bits/long-double.h bits/mathcalls-helper-functions.h \
> - bits/floatn.h bits/floatn-common.h bits/mathcalls-narrow.h
> +headers := \
> + math.h \
> + bits/mathcalls.h \
> + fpu_control.h \
> + complex.h \
> + bits/cmathcalls.h \
> + fenv.h \
> + bits/fenv.h \
> + bits/mathdef.h \
> + tgmath.h \
> + bits/math-vector.h \
> + finclude/math-vector-fortran.h \
> + bits/libm-simd-decl-stubs.h \
> + bits/iscanonical.h \
> + bits/flt-eval-method.h \
> + bits/fp-fast.h \
> + bits/fp-logb.h \
> + bits/long-double.h \
> + bits/mathcalls-helper-functions.h \
> + bits/floatn.h \
> + bits/floatn-common.h \
> + bits/mathcalls-narrow.h
> + # headers
>
> # FPU support code.
> -aux := setfpucw fpu_control
> +aux := \
> + fpu_control \
> + setfpucw \
> + # aux
>
> # Build the -lm library.
>
> extra-libs := libm
> extra-libs-others = $(extra-libs)
>
> -libm-support = s_lib_version s_matherr s_signgam \
> - fclrexcpt fgetexcptflg fraiseexcpt fsetexcptflg \
> - ftestexcept fegetround fesetround fegetenv feholdexcpt \
> - fesetenv feupdateenv fedisblxcpt feenablxcpt \
> - fegetexcept fesetexcept fetestexceptflag fegetmode \
> - fesetmode
> +libm-support = \
> + fclrexcpt \
> + fedisblxcpt \
> + feenablxcpt \
> + fegetenv \
> + fegetexcept \
> + fegetmode \
> + fegetround \
> + feholdexcpt \
> + fesetenv \
> + fesetexcept \
> + fesetmode\
> + fesetround \
> + fetestexceptflag \
> + feupdateenv \
> + fgetexcptflg \
> + fraiseexcpt \
> + fsetexcptflg \
> + ftestexcept \
> + s_lib_version \
> + s_matherr \
> + s_signgam \
> + # libm-support
>
> # Wrappers for these functions generated per type using a file named
> # <func>_template.c and the appropriate math-type-macros-<TYPE>.h.
> -gen-libm-calls = cargF conjF cimagF crealF cabsF e_scalbF s_cacosF \
> - s_cacoshF s_ccosF s_ccoshF s_casinF s_csinF s_casinhF \
> - k_casinhF s_csinhF k_casinhF s_csinhF s_catanhF s_catanF \
> - s_ctanF s_ctanhF s_cexpF s_clogF s_cprojF s_csqrtF \
> - s_cpowF s_clog10F s_fdimF s_nextdownF s_fmaxF s_fminF \
> - s_nanF s_iseqsigF s_canonicalizeF s_significandF \
> - w_ilogbF w_llogbF \
> - w_log1pF w_scalblnF s_fmaxmagF s_fminmagF w_acosF \
> - w_acoshF w_asinF w_atan2F w_atanhF w_coshF w_exp10F \
> - 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 \
> - 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 \
> - e_hypotF e_j0F e_j1F e_jnF e_lgammaF_r e_logF e_log10F e_powF \
> - e_remainderF e_sinhF e_sqrtF e_gammaF_r \
> - e_ilogbF \
> - k_tanF s_asinhF s_atanF s_cbrtF \
> - s_ceilF s_cosF s_erfF s_expm1F s_fabsF \
> - s_floorF s_log1pF s_logbF \
> - s_nextafterF s_nexttowardF s_rintF s_scalblnF \
> - s_sinF s_tanF s_tanhF \
> - s_fpclassifyF s_truncF \
> - s_remquoF e_log2F s_roundF s_nearbyintF s_sincosF \
> - s_fmaF s_lrintF s_llrintF s_lroundF s_llroundF e_exp10F \
> - s_issignalingF $(calls:s_%=m_%) x2y2m1F \
> - gamma_productF lgamma_negF lgamma_productF \
> - s_nextupF s_totalorderF s_totalordermagF s_getpayloadF \
> - s_setpayloadF s_setpayloadsigF s_roundevenF s_fromfpF s_ufromfpF \
> - s_fromfpxF s_ufromfpxF $(gen-libm-calls)
> -
> -libm-compat-calls = \
> - w_acosF_compat w_acoshF_compat w_asinF_compat w_atan2F_compat \
> - w_atanhF_compat w_coshF_compat w_exp2F_compat w_exp10F_compat \
> - w_fmodF_compat w_hypotF_compat w_j0F_compat w_j1F_compat \
> - w_jnF_compat w_log2F_compat w_log10F_compat w_logF_compat \
> - w_powF_compat w_remainderF_compat w_scalbF_compat \
> - w_sinhF_compat w_sqrtF_compat w_tgammaF_compat \
> - w_lgammaF_r_compat w_lgammaF_compat2 w_expF_compat \
> - w_lgamma_compatF k_standardF
> -
> -libm-narrow-fns = add div fma mul sqrt sub
> -libm-narrow-types-basic = s_fF s_f32xFf64
> -libm-narrow-types-ldouble-yes = s_fFl s_dFl
> -libm-narrow-types-float128-yes = s_f32Ff128 s_f64Ff128 s_f64xFf128
> -libm-narrow-types-float128-alias-yes = s_f64xFf128
> -libm-narrow-types = $(libm-narrow-types-basic) \
> - $(libm-narrow-types-ldouble-$(long-double-fcts)) \
> - $(libm-narrow-types-float128-$(float128-fcts)) \
> - $(libm-narrow-types-float128-alias-$(float128-alias-fcts))
> +gen-libm-calls = \
> + cabsF \
> + cargF \
> + cimagF \
> + conjF \
> + crealF \
> + e_exp2F \
> + e_scalbF \
> + k_casinhF \
> + k_casinhF \
> + s_cacosF \
> + s_cacoshF \
> + s_canonicalizeF \
> + s_casinF \
> + s_casinhF \
> + s_catanF \
> + s_catanhF \
> + s_ccosF \
> + s_ccoshF \
> + s_cexpF \
> + s_clog10F \
> + s_clogF \
> + s_cpowF \
> + s_cprojF \
> + s_csinF \
> + s_csinhF \
> + s_csinhF \
> + s_csqrtF \
> + s_ctanF \
> + s_ctanhF \
> + s_fdimF \
> + s_fmaxF \
> + s_fmaximumF \
> + s_fmaximum_magF \
> + s_fmaximum_mag_numF \
> + s_fmaximum_numF \
> + s_fmaxmagF \
> + s_fminF \
> + s_fminimumF \
> + s_fminimum_magF \
> + s_fminimum_mag_numF \
> + s_fminimum_numF \
> + s_fminmagF \
> + s_iseqsigF \
> + s_nanF \
> + s_nextdownF \
> + s_significandF \
> + w_acosF \
> + w_acoshF \
> + w_asinF \
> + w_atan2F \
> + w_atanhF \
> + w_coshF \
> + w_exp10F \
> + w_exp2F \
> + w_expF \
> + w_fmodF \
> + w_hypotF \
> + w_ilogbF \
> + w_j0F \
> + w_j1F \
> + w_jnF \
> + w_lgammaF \
> + w_lgammaF_r \
> + w_llogbF \
> + w_log10F \
> + w_log1pF \
> + w_log2F \
> + w_logF \
> + w_powF \
> + w_remainderF \
> + w_scalbF \
> + w_scalblnF \
> + w_sinhF \
> + w_sqrtF \
> + w_tgammaF \
> + # gen-libm-calls
> +
> +libm-calls = \
> + $(calls:s_%=m_%) \
> + $(gen-libm-calls) \
> + e_acosF \
> + e_acoshF \
> + e_asinF \
> + e_atan2F \
> + e_atanhF \
> + e_coshF \
> + e_exp10F \
> + e_expF \
> + e_fmodF \
> + e_gammaF_r \
> + e_hypotF \
> + e_ilogbF \
> + e_j0F \
> + e_j1F \
> + e_jnF \
> + e_lgammaF_r \
> + e_log10F \
> + e_log2F \
> + e_logF \
> + e_powF \
> + e_remainderF \
> + e_sinhF \
> + e_sqrtF \
> + gamma_productF \
> + k_tanF \
> + lgamma_negF \
> + lgamma_productF \
> + s_asinhF \
> + s_atanF \
> + s_cbrtF \
> + s_ceilF \
> + s_cosF \
> + s_erfF \
> + s_expm1F \
> + s_fabsF \
> + s_floorF \
> + s_fmaF \
> + s_fpclassifyF \
> + s_fromfpF \
> + s_fromfpxF \
> + s_getpayloadF \
> + s_issignalingF \
> + s_llrintF \
> + s_llroundF \
> + s_log1pF \
> + s_logbF \
> + s_lrintF \
> + s_lroundF \
> + s_nearbyintF \
> + s_nextafterF \
> + s_nexttowardF \
> + s_nextupF \
> + s_remquoF \
> + s_rintF \
> + s_roundF \
> + s_roundevenF \
> + s_scalblnF \
> + s_setpayloadF \
> + s_setpayloadsigF \
> + s_sinF \
> + s_sincosF \
> + s_tanF \
> + s_tanhF \
> + s_totalorderF \
> + s_totalordermagF \
> + s_truncF \
> + s_ufromfpF \
> + s_ufromfpxF \
> + x2y2m1F \
> + # libm-calls
> +
> +libm-compat-calls = \
> + k_standardF \
> + w_acosF_compat \
> + w_acoshF_compat \
> + w_asinF_compat \
> + w_atan2F_compat \
> + w_atanhF_compat \
> + w_coshF_compat \
> + w_exp10F_compat \
> + w_exp2F_compat \
> + w_expF_compat \
> + w_fmodF_compat \
> + w_hypotF_compat \
> + w_j0F_compat \
> + w_j1F_compat\
> + w_jnF_compat \
> + w_lgammaF_compat2 \
> + w_lgammaF_r_compat \
> + w_lgamma_compatF \
> + w_log10F_compat \
> + w_log2F_compat \
> + w_logF_compat \
> + w_powF_compat \
> + w_remainderF_compat \
> + w_scalbF_compat \
> + w_sinhF_compat \
> + w_sqrtF_compat \
> + w_tgammaF_compat \
> + # libm-compat-calls
> +
> +libm-narrow-fns = \
> + add \
> + div \
> + fma \
> + mul \
> + sqrt \
> + sub \
> + # libm-narrow-fns
> +libm-narrow-types-basic = \
> + s_f32xFf64 \
> + s_fF \
> + # libm-narrow-types-basic
> +libm-narrow-types-ldouble-yes = \
> + s_dFl \
> + s_fFl \
> + # libm-narrow-types-ldouble-yes
> +libm-narrow-types-float128-yes = \
> + s_f32Ff128 \
> + s_f64Ff128 \
> + s_f64xFf128 \
> + # libm-narrow-types-float128-yes
> +libm-narrow-types-float128-alias-yes = \
> + s_f64xFf128 \
> + # libm-narrow-types-float128-alias-yes
> +libm-narrow-types = \
> + $(libm-narrow-types-basic) \
> + $(libm-narrow-types-float128-$(float128-fcts)) \
> + $(libm-narrow-types-float128-alias-$(float128-alias-fcts)) \
> + $(libm-narrow-types-ldouble-$(long-double-fcts)) \
> + # libm-narrow-types
>
> # Type specific routine support.
> #
> @@ -115,33 +307,65 @@ libm-narrow-types = $(libm-narrow-types-basic) \
> # Finally, note that types is an intentionally recursive variable.
> # We only know the full set of supported types for the target machine
> # after the Rules makefile has been parsed.
> -types-basic = $(type-ldouble-$(long-double-fcts)) double float
> +types-basic = \
> + $(type-ldouble-$(long-double-fcts)) \
> + double \
> + float \
> + # types-basic
>
> # Like types, but includes types whose functions alias those for
> # another type.
> -test-types-basic = ldouble double float
> +test-types-basic = \
> + double \
> + float \
> + ldouble \
> + # test-types-basic
>
> # long double support
> type-ldouble-suffix := l
> -type-ldouble-routines := t_sincosl k_sinl k_cosl k_sincosl s_iscanonicall \
> - e_rem_pio2l
> +type-ldouble-routines := \
> + e_rem_pio2l \
> + k_cosl \
> + k_sincosl \
> + k_sinl \
> + s_iscanonicall \
> + t_sincosl \
> + # type-ldouble-routines
> type-ldouble-yes := ldouble
>
> # double support
> type-double-suffix :=
> -type-double-routines := branred k_rem_pio2 \
> - sincostab math_err e_exp_data e_log_data \
> - e_log2_data e_pow_log_data
> +type-double-routines := \
> + branred \
> + e_exp_data \
> + e_log2_data \
> + e_log_data \
> + e_pow_log_data \
> + k_rem_pio2 \
> + math_err \
> + sincostab \
> + # type-double-routines
>
> # float support
> type-float-suffix := f
> -type-float-routines := math_errf e_exp2f_data e_logf_data \
> - e_log2f_data e_powf_log2_data s_sincosf_data
> +type-float-routines := \
> + e_exp2f_data \
> + e_log2f_data \
> + e_logf_data \
> + e_powf_log2_data \
> + math_errf \
> + s_sincosf_data \
> + # type-float-routines
>
> # _Float128 support
> type-float128-suffix := f128
> -type-float128-routines := t_sincosf128 k_sinf128 k_cosf128 k_sincosf128 \
> - e_rem_pio2f128
> +type-float128-routines := \
> + e_rem_pio2f128 \
> + k_cosf128 \
> + k_sincosf128 \
> + k_sinf128 \
> + t_sincosf128 \
> + # type-float128-routines
> type-float128-yes := float128
>
> # _Float64x may be supported, only as an alias type.
> @@ -151,11 +375,20 @@ type-float64x-yes := float64x
> type-ibm128-suffix := l
> type-ibm128-yes := ibm128
>
> -types = $(types-basic) $(type-float128-$(float128-fcts))
> -test-types = $(test-types-basic) $(type-float128-$(float128-fcts)) \
> - float32 float64 $(type-float128-$(float128-alias-fcts)) \
> - float32x $(type-float64x-$(float64x-alias-fcts)) \
> - $(type-ibm128-$(ibm128-fcts))
> +types = \
> + $(type-float128-$(float128-fcts)) \
> + $(types-basic) \
> + # types
> +test-types = \
> + $(test-types-basic) \
> + $(type-float128-$(float128-alias-fcts)) \
> + $(type-float128-$(float128-fcts)) \
> + $(type-float64x-$(float64x-alias-fcts)) \
> + $(type-ibm128-$(ibm128-fcts)) \
> + float32 \
> + float32x \
> + float64 \
> + # test-types
>
> # Pairs of types for which narrowing functions should be tested (this
> # variable has more entries than libm-narrow-types because it includes
> @@ -163,14 +396,25 @@ test-types = $(test-types-basic) $(type-float128-$(float128-fcts)) \
> # for other types). This definition embeds the assumption that if
> # _Float64x is supported, so is _Float128, and vice versa (they may or
> # may not have the same format).
> -test-type-pairs = float-double float-ldouble double-ldouble \
> - float32-float64 float32-float32x float32x-float64 \
> - $(test-type-pairs-f64xf128-$(float128-fcts)) \
> - $(test-type-pairs-f64xf128-$(float128-alias-fcts))
> -test-type-pairs-f64xf128-yes = float32-float64x float32-float128 \
> - float64-float64x float64-float128 \
> - float32x-float64x float32x-float128 \
> - float64x-float128
> +test-type-pairs = \
> + $(test-type-pairs-f64xf128-$(float128-alias-fcts)) \
> + $(test-type-pairs-f64xf128-$(float128-fcts)) \
> + double-ldouble \
> + float-double \
> + float-ldouble \
> + float32-float32x \
> + float32-float64 \
> + float32x-float64 \
> + # test-type-pairs
> +test-type-pairs-f64xf128-yes = \
> + float32-float128 \
> + float32-float64x \
> + float32x-float128 \
> + float32x-float64x \
> + float64-float128 \
> + float64-float64x \
> + float64x-float128 \
> + # test-type-pairs-f64xf128-yes
>
> # For each of the basic types (float, double, long double), replace the
> # occurrences of 'F' in arg 1 with the appropriate suffix for the type.
> @@ -193,8 +437,17 @@ libm-routines = $(strip $(libm-support) \
> # and we don't want to have to link every program with -lm.
> # In libm-calls (above), list m_foo in place of s_foo for any
> # routine that should be compiled separately for its libc and libm versions.
> -calls = s_isinfF s_isnanF s_finiteF s_copysignF s_modfF s_scalbnF s_frexpF \
> - s_signbitF $(gen-calls)
> +calls = \
> + $(gen-calls) \
> + s_copysignF \
> + s_finiteF \
> + s_frexpF \
> + s_isinfF \
> + s_isnanF \
> + s_modfF \
> + s_scalbnF \
> + s_signbitF \
> + # calls
> gen-calls = s_ldexpF
> generated += $(foreach s,.c .S,$(call type-foreach, $(calls:s_%=m_%$(s))))
> routines = $(call type-foreach, $(calls))
> @@ -205,8 +458,14 @@ libm-shared-only-routines = $(call type-foreach, $(calls:s_%=m_%))
> ifeq ($(build-mathvec),yes)
> # We need to install libm.so and libm.a as linker scripts
> # for transparent use of vector math library.
> -install-lib-ldscripts := libm.so libm.a
> -install-others = $(inst_libdir)/libm.so $(inst_libdir)/libm.a
> +install-lib-ldscripts := \
> + libm.a \
> + libm.so \
> + # install-lib-ldscripts
> +install-others = \
> + $(inst_libdir)/libm.a \
> + $(inst_libdir)/libm.so \
> + # install-others
> $(inst_libdir)/libm.so: $(common-objpfx)format.lds \
> $(libm) \
> $(libmvec) \
> @@ -234,42 +493,95 @@ $(inst_libdir)/libm.a: $(common-objpfx)format.lds \
> endif
>
> # Rules for the test suite.
> -tests = test-matherr-3 test-fenv basic-test \
> - test-misc test-fpucw test-fpucw-ieee tst-definitions test-tgmath \
> - test-tgmath-ret bug-nextafter bug-nexttoward bug-tgmath1 \
> - test-tgmath-int test-tgmath2 test-powl tst-CMPLX tst-CMPLX2 test-snan \
> - test-fenv-tls test-fenv-preserve test-fenv-return \
> - test-nearbyint-except test-fenv-clear \
> - test-nearbyint-except-2 test-signgam-uchar test-signgam-uchar-init \
> - test-signgam-uint test-signgam-uint-init test-signgam-ullong \
> - test-signgam-ullong-init test-nan-overflow test-nan-payload \
> - test-fexcept test-fexcept-traps test-fesetexcept \
> - test-fesetexcept-traps test-fetestexceptflag test-femode \
> - test-femode-traps test-iszero-excess-precision \
> - test-iseqsig-excess-precision test-flt-eval-method \
> - test-fp-ilogb-constants test-fp-llogb-constants \
> - test-narrow-macros \
> - test-nan-const $(tests-static)
> +tests = \
> + $(tests-static) \
> + bug-nextafter \
> + bug-nexttoward \
> + bug-tgmath1 \
> + test-femode \
> + test-femode-traps \
> + test-fenv basic-test \
> + test-fenv-clear \
> + test-fenv-preserve \
> + test-fenv-return \
> + test-fenv-tls \
> + test-fesetexcept \
> + test-fesetexcept-traps \
> + test-fetestexceptflag \
> + test-fexcept \
> + test-fexcept-traps \
> + test-flt-eval-method \
> + test-fp-ilogb-constants \
> + test-fp-llogb-constants \
> + test-fpucw \
> + test-fpucw-ieee \
> + test-iseqsig-excess-precision \
> + test-iszero-excess-precision \
> + test-matherr-3 \
> + test-misc \
> + test-nan-const \
> + test-nan-overflow \
> + test-nan-payload \
> + test-narrow-macros \
> + test-nearbyint-except \
> + test-nearbyint-except-2 \
> + test-powl \
> + test-signgam-uchar \
> + test-signgam-uchar-init \
> + test-signgam-uint \
> + test-signgam-uint-init \
> + test-signgam-ullong \
> + test-signgam-ullong-init \
> + test-snan \
> + test-tgmath \
> + test-tgmath-int \
> + test-tgmath-ret \
> + test-tgmath2 \
> + tst-CMPLX \
> + tst-CMPLX2 \
> + tst-definitions \
> + # tests
> ifneq ($(config-cflags-signaling-nans),)
> -tests += test-fe-snans-always-signal
> +tests += \
> + test-fe-snans-always-signal \
> + # tests
> endif
> -tests-static = test-fpucw-static test-fpucw-ieee-static \
> - test-signgam-uchar-static test-signgam-uchar-init-static \
> - test-signgam-uint-static test-signgam-uint-init-static \
> - test-signgam-ullong-static test-signgam-ullong-init-static
> +tests-static = \
> + test-fpucw-ieee-static \
> + test-fpucw-static \
> + test-signgam-uchar-init-static \
> + test-signgam-uchar-static \
> + test-signgam-uint-init-static \
> + test-signgam-uint-static \
> + test-signgam-ullong-init-static \
> + test-signgam-ullong-static \
> + # tests-static
>
> # The tested symbols matherr, _LIB_VERSION have been removed in glibc 2.27.
> ifeq ($(have-GLIBC_2.26)$(build-shared),yesyes)
> -tests += test-matherr test-matherr-2
> +tests += \
> + test-matherr \
> + test-matherr-2 \
> + # tests
> endif
>
> # These tests use internal (unexported) GMP functions and are linked
> # statically to obtain access to these functions.
> -tests-static += atest-exp atest-sincos atest-exp2
> +tests-static += \
> + atest-exp \
> + atest-exp2 \
> + atest-sincos \
> + # tests-static
>
> ifneq (,$(CXX))
> -tests += test-math-isinff test-math-iszero test-math-issignaling \
> - test-math-iscanonical test-math-cxx11 test-math-iseqsig
> +tests += \
> + test-math-cxx11 \
> + test-math-iscanonical \
> + test-math-iseqsig \
> + test-math-isinff \
> + test-math-issignaling \
> + test-math-iszero \
> + # tests
> endif
>
> libm-vec-tests = $(addprefix test-,$(libmvec-tests))
> @@ -286,35 +598,167 @@ $(objpfx)libm-test-ulps.h: $(ulps-file) gen-libm-test.py
> $(make-target-directory)
> $(PYTHON) gen-libm-test.py -u $< -H $@
>
> -libm-test-funcs-auto = acos acosh asin asinh atan atan2 atanh cabs cacos \
> - cacosh carg casin casinh catan catanh cbrt ccos ccosh \
> - cexp clog clog10 cos cosh cpow csin csinh csqrt ctan \
> - ctanh erf erfc exp exp10 exp2 expm1 fma hypot j0 j1 jn \
> - 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 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 \
> - lround modf nearbyint nextafter nextdown nexttoward \
> - nextup remainder remquo rint round roundeven scalb \
> - scalbln scalbn setpayload setpayloadsig signbit \
> - significand totalorder totalordermag trunc ufromfp \
> - ufromfpx compat_totalorder compat_totalordermag
> -libm-test-funcs-compat = compat_totalorder compat_totalordermag
> -libm-test-funcs-narrow = add div fma mul sqrt sub
> -libm-test-funcs-all = $(libm-test-funcs-auto) $(libm-test-funcs-noauto)
> +libm-test-funcs-auto = \
> + acos \
> + acosh \
> + asin \
> + asinh \
> + atan \
> + atan2 \
> + atanh \
> + cabs \
> + cacos \
> + cacosh \
> + carg \
> + casin \
> + casinh \
> + catan \
> + catanh \
> + cbrt \
> + ccos \
> + ccosh \
> + cexp \
> + clog \
> + clog10 \
> + cos \
> + cosh \
> + cpow \
> + csin \
> + csinh \
> + csqrt \
> + ctan \
> + ctanh \
> + erf \
> + erfc \
> + exp \
> + exp2 \
> + exp10 \
> + expm1 \
> + fma \
> + hypot \
> + j0 \
> + j1 \
> + jn \
> + lgamma \
> + log \
> + log10 \
> + log1p \
> + log2 \
> + pow \
> + sin \
> + sincos \
> + sinh \
> + sqrt \
> + tan \
> + tanh \
> + tgamma \
> + y0 \
> + y1 \
> + yn \
> + # libm-test-funcs-auto
> +libm-test-funcs-noauto = \
> + canonicalize \
> + ceil \
> + cimag \
> + compat_totalorder \
> + compat_totalordermag \
> + conj \
> + copysign \
> + cproj \
> + creal \
> + 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 \
> + lround \
> + modf \
> + nearbyint \
> + nextafter \
> + nextdown \
> + nexttoward \
> + nextup \
> + remainder \
> + remquo \
> + rint \
> + round \
> + roundeven \
> + scalb \
> + scalbln \
> + scalbn \
> + setpayload \
> + setpayloadsig \
> + signbit \
> + significand \
> + totalorder \
> + totalordermag \
> + trunc \
> + ufromfp \
> + ufromfpx \
> + # libm-test-funcs-noauto
> +libm-test-funcs-compat = \
> + compat_totalorder \
> + compat_totalordermag \
> + # libm-test-funcs-compat
> +libm-test-funcs-narrow = \
> + add \
> + div \
> + fma \
> + mul \
> + sqrt \
> + sub \
> + # libm-test-funcs-narrow
> +libm-test-funcs-all = \
> + $(libm-test-funcs-auto) \
> + $(libm-test-funcs-noauto) \
> + # libm-test-funcs-all
> libm-test-c-auto = $(foreach f,$(libm-test-funcs-auto),libm-test-$(f).c)
> libm-test-c-noauto = $(foreach f,$(libm-test-funcs-noauto),libm-test-$(f).c)
> libm-test-c-narrow = $(foreach f,$(libm-test-funcs-narrow),\
> libm-test-narrow-$(f).c)
> -generated += libm-test-ulps.h $(libm-test-c-auto) $(libm-test-c-noauto) \
> - $(libm-test-c-narrow)
> +generated += \
> + $(libm-test-c-auto) \
> + $(libm-test-c-narrow) \
> + $(libm-test-c-noauto) \
> + libm-test-ulps.h \
> + # generated
>
> libm-tests-base-normal = $(foreach t,$(test-types),test-$(t))
> libm-tests-base-narrow = $(foreach t,$(test-type-pairs),test-$(t))
> @@ -374,19 +818,101 @@ $(foreach t,$(libm-tests-base),\
> $(objpfx)$(t)-compat_totalordermag.o): $(objpfx)libm-test-totalordermag.c
>
> # _Float128x omitted as not supported by gen-tgmath-tests.py.
> -tgmath3-narrow-types = f d f16 f32 f64 f128 f32x f64x
> +tgmath3-narrow-types = \
> + d \
> + f \
> + f16 \
> + f32 \
> + f128 \
> + f32x \
> + f64 \
> + f64x \
> + # tgmath3-narrow-types
> tgmath3-narrow-macros = $(foreach t,$(tgmath3-narrow-types), \
> $(foreach f,$(libm-narrow-fns),$(t)$(f)))
> -tgmath3-macros = atan2 cbrt ceil copysign erf erfc exp10 exp2 expm1 fdim \
> - floor fma fmax fmin fmod frexp hypot ilogb ldexp lgamma \
> - llrint llround log10 log1p log2 logb lrint lround nearbyint \
> - 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 \
> - 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-macros = \
> + $(tgmath3-narrow-macros) \
> + acos \
> + acosh \
> + asin \
> + asinh \
> + atan \
> + atan2 \
> + atanh \
> + carg \
> + cbrt \
> + ceil \
> + cimag \
> + conj \
> + copysign \
> + cos \
> + cosh \
> + cproj \
> + creal \
> + erf \
> + erfc \
> + exp \
> + exp2 \
> + exp10 \
> + expm1 \
> + fabs \
> + fdim \
> + floor \
> + fma \
> + fmax \
> + fmaximum \
> + fmaximum_mag \
> + fmaximum_mag_num \
> + fmaximum_num \
> + fmaxmag \
> + fmin \
> + fminimum \
> + fminimum_mag \
> + fminimum_mag_num \
> + fminimum_num \
> + fminmag \
> + fmod \
> + frexp \
> + fromfp \
> + fromfpx \
> + hypot \
> + ilogb \
> + ldexp \
> + lgamma \
> + llogb \
> + llrint \
> + llround \
> + log \
> + log10 \
> + log1p \
> + log2 \
> + logb \
> + lrint \
> + lround \
> + nearbyint \
> + nextafter \
> + nextdown \
> + nexttoward \
> + nextup \
> + pow \
> + remainder \
> + remquo \
> + rint \
> + round \
> + roundeven \
> + scalb \
> + scalbln \
> + scalbn \
> + sin \
> + sinh \
> + sqrt \
> + tan \
> + tanh \
> + tgamma \
> + trunc \
> + ufromfp \
> + ufromfpx \
> + # tgmath3-macros
> tgmath3-macro-tests = $(addprefix test-tgmath3-,$(tgmath3-macros))
> tests += $(tgmath3-macro-tests)
> generated += $(addsuffix .c,$(tgmath3-macro-tests))
> --
> 2.34.1
>
LGTM.
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
Thanks.
--
H.J.
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 02/12] powerpc: Add missing arch flags on rounding ifunc variants
2023-12-28 17:20 [PATCH 00/12] Improve rounding to interger function for C23 Adhemerval Zanella
2023-12-28 17:20 ` [PATCH 01/12] math: Reformat Makefile Adhemerval Zanella
@ 2023-12-28 17:20 ` Adhemerval Zanella
2024-04-01 13:59 ` H.J. Lu
2023-12-28 17:20 ` [PATCH 03/12] math: Add test to check if ceil raise inexact floating-point exception Adhemerval Zanella
` (10 subsequent siblings)
12 siblings, 1 reply; 27+ messages in thread
From: Adhemerval Zanella @ 2023-12-28 17:20 UTC (permalink / raw)
To: libc-alpha
The ifunc variants now uses the powerpc implementation which in turn
uses the compiler builtin. Without the proper -mcpu switch the builtin
does not generate the expected optimization.
Checked on powerpc-linux-gnu.
---
sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
index 64317506c6..2f5c0eded6 100644
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
@@ -34,6 +34,12 @@ CFLAGS-s_modff-power5+.c = -mcpu=power5+
CFLAGS-s_logbl-power7.c = -mcpu=power7
CFLAGS-s_logb-power7.c = -mcpu=power7
CFLAGS-s_logbf-power7.c = -mcpu=power7
+CFLAGS-s_round-power5+.c += -mcpu=power5+
+CFLAGS-s_roundf-power5+.c += -mcpu=power5+
+CFLAGS-s_floor-power5+.c += -mcpu=power5+
+CFLAGS-s_floorf-power5+.c += -mcpu=power5+
+CFLAGS-s_trunc-power5+.c += -mcpu=power5+
+CFLAGS-s_truncf-power5+.c += -mcpu=power5+
# These files quiet sNaNs in a way that is optimized away without
# -fsignaling-nans.
--
2.34.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 02/12] powerpc: Add missing arch flags on rounding ifunc variants
2023-12-28 17:20 ` [PATCH 02/12] powerpc: Add missing arch flags on rounding ifunc variants Adhemerval Zanella
@ 2024-04-01 13:59 ` H.J. Lu
2024-04-01 16:50 ` Peter Bergner
0 siblings, 1 reply; 27+ messages in thread
From: H.J. Lu @ 2024-04-01 13:59 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: libc-alpha
On Thu, Dec 28, 2023 at 9:21 AM Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
>
> The ifunc variants now uses the powerpc implementation which in turn
> uses the compiler builtin. Without the proper -mcpu switch the builtin
> does not generate the expected optimization.
>
> Checked on powerpc-linux-gnu.
> ---
> sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
> index 64317506c6..2f5c0eded6 100644
> --- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
> +++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
> @@ -34,6 +34,12 @@ CFLAGS-s_modff-power5+.c = -mcpu=power5+
> CFLAGS-s_logbl-power7.c = -mcpu=power7
> CFLAGS-s_logb-power7.c = -mcpu=power7
> CFLAGS-s_logbf-power7.c = -mcpu=power7
> +CFLAGS-s_round-power5+.c += -mcpu=power5+
> +CFLAGS-s_roundf-power5+.c += -mcpu=power5+
> +CFLAGS-s_floor-power5+.c += -mcpu=power5+
> +CFLAGS-s_floorf-power5+.c += -mcpu=power5+
> +CFLAGS-s_trunc-power5+.c += -mcpu=power5+
> +CFLAGS-s_truncf-power5+.c += -mcpu=power5+
>
> # These files quiet sNaNs in a way that is optimized away without
> # -fsignaling-nans.
> --
> 2.34.1
>
LGTM.
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
Thanks.
--
H.J.
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 02/12] powerpc: Add missing arch flags on rounding ifunc variants
2024-04-01 13:59 ` H.J. Lu
@ 2024-04-01 16:50 ` Peter Bergner
0 siblings, 0 replies; 27+ messages in thread
From: Peter Bergner @ 2024-04-01 16:50 UTC (permalink / raw)
To: H.J. Lu, Adhemerval Zanella; +Cc: libc-alpha
On 4/1/24 8:59 AM, H.J. Lu wrote:
> On Thu, Dec 28, 2023 at 9:21 AM Adhemerval Zanella
> <adhemerval.zanella@linaro.org> wrote:
>>
>> The ifunc variants now uses the powerpc implementation which in turn
>> uses the compiler builtin. Without the proper -mcpu switch the builtin
>> does not generate the expected optimization.
>>
>> Checked on powerpc-linux-gnu.
>> ---
>> sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile | 6 ++++++
>> 1 file changed, 6 insertions(+)
>>
>> diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
>> index 64317506c6..2f5c0eded6 100644
>> --- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
>> +++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
>> @@ -34,6 +34,12 @@ CFLAGS-s_modff-power5+.c = -mcpu=power5+
>> CFLAGS-s_logbl-power7.c = -mcpu=power7
>> CFLAGS-s_logb-power7.c = -mcpu=power7
>> CFLAGS-s_logbf-power7.c = -mcpu=power7
>> +CFLAGS-s_round-power5+.c += -mcpu=power5+
>> +CFLAGS-s_roundf-power5+.c += -mcpu=power5+
>> +CFLAGS-s_floor-power5+.c += -mcpu=power5+
>> +CFLAGS-s_floorf-power5+.c += -mcpu=power5+
>> +CFLAGS-s_trunc-power5+.c += -mcpu=power5+
>> +CFLAGS-s_truncf-power5+.c += -mcpu=power5+
>>
>> # These files quiet sNaNs in a way that is optimized away without
>> # -fsignaling-nans.
>> --
>> 2.34.1
>>
>
> LGTM.
>
> Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
This predated me taking over the Power port, but...
LGTM too.
Reviewed-by: Peter Bergner <bergner@linux.ibm.com>
Peter
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 03/12] math: Add test to check if ceil raise inexact floating-point exception
2023-12-28 17:20 [PATCH 00/12] Improve rounding to interger function for C23 Adhemerval Zanella
2023-12-28 17:20 ` [PATCH 01/12] math: Reformat Makefile Adhemerval Zanella
2023-12-28 17:20 ` [PATCH 02/12] powerpc: Add missing arch flags on rounding ifunc variants Adhemerval Zanella
@ 2023-12-28 17:20 ` Adhemerval Zanella
2024-04-01 14:01 ` H.J. Lu
2023-12-28 17:20 ` [PATCH 04/12] math: Add test to check if floor " Adhemerval Zanella
` (9 subsequent siblings)
12 siblings, 1 reply; 27+ messages in thread
From: Adhemerval Zanella @ 2023-12-28 17:20 UTC (permalink / raw)
To: libc-alpha
It is not allowed anymore on ISO C23.
---
math/Makefile | 5 +++
math/test-ceil-except-2.c | 67 ++++++++++++++++++++++++++++++
math/test-ceil-except.c | 85 +++++++++++++++++++++++++++++++++++++++
3 files changed, 157 insertions(+)
create mode 100644 math/test-ceil-except-2.c
create mode 100644 math/test-ceil-except.c
diff --git a/math/Makefile b/math/Makefile
index 5a912c55bd..4fc7842313 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -498,6 +498,8 @@ tests = \
bug-nextafter \
bug-nexttoward \
bug-tgmath1 \
+ test-ceil-except \
+ test-ceil-except-2 \
test-femode \
test-femode-traps \
test-fenv basic-test \
@@ -989,6 +991,9 @@ CFLAGS-test-fe-snans-always-signal.c += $(config-cflags-signaling-nans)
CFLAGS-test-nan-const.c += -fno-builtin
+CFLAGS-test-ceil-except.c += -fno-builtin
+CFLAGS-test-ceil-except-2.c += -fno-builtin
+
include ../Rules
gen-all-calls = $(gen-libm-calls) $(gen-calls)
diff --git a/math/test-ceil-except-2.c b/math/test-ceil-except-2.c
new file mode 100644
index 0000000000..c25956a402
--- /dev/null
+++ b/math/test-ceil-except-2.c
@@ -0,0 +1,67 @@
+/* Test ceil functions do not disable exception traps.
+ Copyright (C) 2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <fenv.h>
+#include <math.h>
+#include <stdio.h>
+
+#ifndef FE_INEXACT
+# define FE_INEXACT 0
+#endif
+
+#define TEST_FUNC(NAME, FLOAT, SUFFIX) \
+static int \
+NAME (void) \
+{ \
+ int result = 0; \
+ volatile FLOAT a, b __attribute__ ((unused)); \
+ a = 1.5; \
+ /* ceil must work when traps on "inexact" are enabled. */ \
+ b = ceil ## SUFFIX (a); \
+ /* And it must have left those traps enabled. */ \
+ if (fegetexcept () == FE_INEXACT) \
+ puts ("PASS: " #FLOAT); \
+ else \
+ { \
+ puts ("FAIL: " #FLOAT); \
+ result = 1; \
+ } \
+ return result; \
+}
+
+TEST_FUNC (float_test, float, f)
+TEST_FUNC (double_test, double, )
+TEST_FUNC (ldouble_test, long double, l)
+
+static int
+do_test (void)
+{
+ if (feenableexcept (FE_INEXACT) == -1)
+ {
+ puts ("enabling FE_INEXACT traps failed, cannot test");
+ return 77;
+ }
+ int result = float_test ();
+ feenableexcept (FE_INEXACT);
+ result |= double_test ();
+ feenableexcept (FE_INEXACT);
+ result |= ldouble_test ();
+ return result;
+}
+
+#include <support/test-driver.c>
diff --git a/math/test-ceil-except.c b/math/test-ceil-except.c
new file mode 100644
index 0000000000..cd0717a96f
--- /dev/null
+++ b/math/test-ceil-except.c
@@ -0,0 +1,85 @@
+/* Test ceil functions do not clear exceptions.
+ Copyright (C) 2015-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <fenv.h>
+#include <math.h>
+#include <stdbool.h>
+#include <stdio.h>
+
+#include <math-tests.h>
+
+#ifndef FE_INVALID
+# define FE_INVALID 0
+#endif
+
+static bool any_supported = false;
+
+#define TEST_FUNC(NAME, FLOAT, SUFFIX) \
+static int \
+NAME (void) \
+{ \
+ int result = 0; \
+ if (!EXCEPTION_TESTS (FLOAT)) \
+ return 0; \
+ any_supported = true; \
+ volatile FLOAT a, b __attribute__ ((unused)); \
+ a = 1.0; \
+ /* ceil must not clear already-raised exceptions. */ \
+ feraiseexcept (FE_ALL_EXCEPT); \
+ b = ceil ## SUFFIX (a); \
+ if (fetestexcept (FE_ALL_EXCEPT) == FE_ALL_EXCEPT) \
+ puts ("PASS: " #FLOAT); \
+ else \
+ { \
+ puts ("FAIL: " #FLOAT); \
+ result = 1; \
+ } \
+ /* But it mustn't lose exceptions from sNaN arguments. */ \
+ if (SNAN_TESTS (FLOAT)) \
+ { \
+ static volatile FLOAT snan = __builtin_nans ## SUFFIX (""); \
+ volatile FLOAT c __attribute__ ((unused)); \
+ feclearexcept (FE_ALL_EXCEPT); \
+ c = ceil ## SUFFIX (snan); \
+ if (fetestexcept (FE_INVALID) == FE_INVALID) \
+ puts ("PASS: " #FLOAT " sNaN"); \
+ else \
+ { \
+ puts ("FAIL: " #FLOAT " sNaN"); \
+ result = 1; \
+ } \
+ } \
+ return result; \
+}
+
+TEST_FUNC (float_test, float, f)
+TEST_FUNC (double_test, double, )
+TEST_FUNC (ldouble_test, long double, l)
+
+static int
+do_test (void)
+{
+ int result = float_test ();
+ result |= double_test ();
+ result |= ldouble_test ();
+ if (!any_supported)
+ return 77;
+ return result;
+}
+
+#include <support/test-driver.c>
--
2.34.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 03/12] math: Add test to check if ceil raise inexact floating-point exception
2023-12-28 17:20 ` [PATCH 03/12] math: Add test to check if ceil raise inexact floating-point exception Adhemerval Zanella
@ 2024-04-01 14:01 ` H.J. Lu
0 siblings, 0 replies; 27+ messages in thread
From: H.J. Lu @ 2024-04-01 14:01 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: libc-alpha
On Thu, Dec 28, 2023 at 9:22 AM Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
>
> It is not allowed anymore on ISO C23.
> ---
> math/Makefile | 5 +++
> math/test-ceil-except-2.c | 67 ++++++++++++++++++++++++++++++
> math/test-ceil-except.c | 85 +++++++++++++++++++++++++++++++++++++++
> 3 files changed, 157 insertions(+)
> create mode 100644 math/test-ceil-except-2.c
> create mode 100644 math/test-ceil-except.c
>
> diff --git a/math/Makefile b/math/Makefile
> index 5a912c55bd..4fc7842313 100644
> --- a/math/Makefile
> +++ b/math/Makefile
> @@ -498,6 +498,8 @@ tests = \
> bug-nextafter \
> bug-nexttoward \
> bug-tgmath1 \
> + test-ceil-except \
> + test-ceil-except-2 \
> test-femode \
> test-femode-traps \
> test-fenv basic-test \
> @@ -989,6 +991,9 @@ CFLAGS-test-fe-snans-always-signal.c += $(config-cflags-signaling-nans)
>
> CFLAGS-test-nan-const.c += -fno-builtin
>
> +CFLAGS-test-ceil-except.c += -fno-builtin
> +CFLAGS-test-ceil-except-2.c += -fno-builtin
> +
> include ../Rules
>
> gen-all-calls = $(gen-libm-calls) $(gen-calls)
> diff --git a/math/test-ceil-except-2.c b/math/test-ceil-except-2.c
> new file mode 100644
> index 0000000000..c25956a402
> --- /dev/null
> +++ b/math/test-ceil-except-2.c
> @@ -0,0 +1,67 @@
> +/* Test ceil functions do not disable exception traps.
> + Copyright (C) 2023 Free Software Foundation, Inc.
2024
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +#include <fenv.h>
> +#include <math.h>
> +#include <stdio.h>
> +
> +#ifndef FE_INEXACT
> +# define FE_INEXACT 0
> +#endif
> +
> +#define TEST_FUNC(NAME, FLOAT, SUFFIX) \
> +static int \
> +NAME (void) \
> +{ \
> + int result = 0; \
> + volatile FLOAT a, b __attribute__ ((unused)); \
> + a = 1.5; \
> + /* ceil must work when traps on "inexact" are enabled. */ \
> + b = ceil ## SUFFIX (a); \
> + /* And it must have left those traps enabled. */ \
> + if (fegetexcept () == FE_INEXACT) \
> + puts ("PASS: " #FLOAT); \
> + else \
> + { \
> + puts ("FAIL: " #FLOAT); \
> + result = 1; \
> + } \
> + return result; \
> +}
> +
> +TEST_FUNC (float_test, float, f)
> +TEST_FUNC (double_test, double, )
> +TEST_FUNC (ldouble_test, long double, l)
> +
> +static int
> +do_test (void)
> +{
> + if (feenableexcept (FE_INEXACT) == -1)
> + {
> + puts ("enabling FE_INEXACT traps failed, cannot test");
> + return 77;
> + }
> + int result = float_test ();
> + feenableexcept (FE_INEXACT);
> + result |= double_test ();
> + feenableexcept (FE_INEXACT);
> + result |= ldouble_test ();
> + return result;
> +}
> +
> +#include <support/test-driver.c>
> diff --git a/math/test-ceil-except.c b/math/test-ceil-except.c
> new file mode 100644
> index 0000000000..cd0717a96f
> --- /dev/null
> +++ b/math/test-ceil-except.c
> @@ -0,0 +1,85 @@
> +/* Test ceil functions do not clear exceptions.
> + Copyright (C) 2015-2023 Free Software Foundation, Inc.
Just 2024.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +#include <fenv.h>
> +#include <math.h>
> +#include <stdbool.h>
> +#include <stdio.h>
> +
> +#include <math-tests.h>
> +
> +#ifndef FE_INVALID
> +# define FE_INVALID 0
> +#endif
> +
> +static bool any_supported = false;
> +
> +#define TEST_FUNC(NAME, FLOAT, SUFFIX) \
> +static int \
> +NAME (void) \
> +{ \
> + int result = 0; \
> + if (!EXCEPTION_TESTS (FLOAT)) \
> + return 0; \
> + any_supported = true; \
> + volatile FLOAT a, b __attribute__ ((unused)); \
> + a = 1.0; \
> + /* ceil must not clear already-raised exceptions. */ \
> + feraiseexcept (FE_ALL_EXCEPT); \
> + b = ceil ## SUFFIX (a); \
> + if (fetestexcept (FE_ALL_EXCEPT) == FE_ALL_EXCEPT) \
> + puts ("PASS: " #FLOAT); \
> + else \
> + { \
> + puts ("FAIL: " #FLOAT); \
> + result = 1; \
> + } \
> + /* But it mustn't lose exceptions from sNaN arguments. */ \
> + if (SNAN_TESTS (FLOAT)) \
> + { \
> + static volatile FLOAT snan = __builtin_nans ## SUFFIX (""); \
> + volatile FLOAT c __attribute__ ((unused)); \
> + feclearexcept (FE_ALL_EXCEPT); \
> + c = ceil ## SUFFIX (snan); \
> + if (fetestexcept (FE_INVALID) == FE_INVALID) \
> + puts ("PASS: " #FLOAT " sNaN"); \
> + else \
> + { \
> + puts ("FAIL: " #FLOAT " sNaN"); \
> + result = 1; \
> + } \
> + } \
> + return result; \
> +}
> +
> +TEST_FUNC (float_test, float, f)
> +TEST_FUNC (double_test, double, )
> +TEST_FUNC (ldouble_test, long double, l)
> +
> +static int
> +do_test (void)
> +{
> + int result = float_test ();
> + result |= double_test ();
> + result |= ldouble_test ();
> + if (!any_supported)
> + return 77;
> + return result;
> +}
> +
> +#include <support/test-driver.c>
> --
> 2.34.1
>
--
H.J.
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 04/12] math: Add test to check if floor raise inexact floating-point exception
2023-12-28 17:20 [PATCH 00/12] Improve rounding to interger function for C23 Adhemerval Zanella
` (2 preceding siblings ...)
2023-12-28 17:20 ` [PATCH 03/12] math: Add test to check if ceil raise inexact floating-point exception Adhemerval Zanella
@ 2023-12-28 17:20 ` Adhemerval Zanella
2024-04-01 14:02 ` H.J. Lu
2023-12-28 17:20 ` [PATCH 05/12] math: Add test to check if trunc " Adhemerval Zanella
` (8 subsequent siblings)
12 siblings, 1 reply; 27+ messages in thread
From: Adhemerval Zanella @ 2023-12-28 17:20 UTC (permalink / raw)
To: libc-alpha
It is not allowed anymore on ISO C23.
---
math/Makefile | 4 ++
math/test-floor-except-2.c | 67 ++++++++++++++++++++++++++++++
math/test-floor-except.c | 85 ++++++++++++++++++++++++++++++++++++++
3 files changed, 156 insertions(+)
create mode 100644 math/test-floor-except-2.c
create mode 100644 math/test-floor-except.c
diff --git a/math/Makefile b/math/Makefile
index 4fc7842313..19e234874a 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -512,6 +512,8 @@ tests = \
test-fetestexceptflag \
test-fexcept \
test-fexcept-traps \
+ test-floor-except \
+ test-floor-except-2 \
test-flt-eval-method \
test-fp-ilogb-constants \
test-fp-llogb-constants \
@@ -993,6 +995,8 @@ CFLAGS-test-nan-const.c += -fno-builtin
CFLAGS-test-ceil-except.c += -fno-builtin
CFLAGS-test-ceil-except-2.c += -fno-builtin
+CFLAGS-test-floor-except.c += -fno-builtin
+CFLAGS-test-floor-except-2.c += -fno-builtin
include ../Rules
diff --git a/math/test-floor-except-2.c b/math/test-floor-except-2.c
new file mode 100644
index 0000000000..01b22f984b
--- /dev/null
+++ b/math/test-floor-except-2.c
@@ -0,0 +1,67 @@
+/* Test floor functions do not disable exception traps.
+ Copyright (C) 2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <fenv.h>
+#include <math.h>
+#include <stdio.h>
+
+#ifndef FE_INEXACT
+# define FE_INEXACT 0
+#endif
+
+#define TEST_FUNC(NAME, FLOAT, SUFFIX) \
+static int \
+NAME (void) \
+{ \
+ int result = 0; \
+ volatile FLOAT a, b __attribute__ ((unused)); \
+ a = 1.5; \
+ /* floor must work when traps on "inexact" are enabled. */ \
+ b = floor ## SUFFIX (a); \
+ /* And it must have left those traps enabled. */ \
+ if (fegetexcept () == FE_INEXACT) \
+ puts ("PASS: " #FLOAT); \
+ else \
+ { \
+ puts ("FAIL: " #FLOAT); \
+ result = 1; \
+ } \
+ return result; \
+}
+
+TEST_FUNC (float_test, float, f)
+TEST_FUNC (double_test, double, )
+TEST_FUNC (ldouble_test, long double, l)
+
+static int
+do_test (void)
+{
+ if (feenableexcept (FE_INEXACT) == -1)
+ {
+ puts ("enabling FE_INEXACT traps failed, cannot test");
+ return 77;
+ }
+ int result = float_test ();
+ feenableexcept (FE_INEXACT);
+ result |= double_test ();
+ feenableexcept (FE_INEXACT);
+ result |= ldouble_test ();
+ return result;
+}
+
+#include <support/test-driver.c>
diff --git a/math/test-floor-except.c b/math/test-floor-except.c
new file mode 100644
index 0000000000..fe77866ddc
--- /dev/null
+++ b/math/test-floor-except.c
@@ -0,0 +1,85 @@
+/* Test floor functions do not clear exceptions.
+ Copyright (C) 2015-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <fenv.h>
+#include <math.h>
+#include <stdbool.h>
+#include <stdio.h>
+
+#include <math-tests.h>
+
+#ifndef FE_INVALID
+# define FE_INVALID 0
+#endif
+
+static bool any_supported = false;
+
+#define TEST_FUNC(NAME, FLOAT, SUFFIX) \
+static int \
+NAME (void) \
+{ \
+ int result = 0; \
+ if (!EXCEPTION_TESTS (FLOAT)) \
+ return 0; \
+ any_supported = true; \
+ volatile FLOAT a, b __attribute__ ((unused)); \
+ a = 1.0; \
+ /* floor must not clear already-raised exceptions. */ \
+ feraiseexcept (FE_ALL_EXCEPT); \
+ b = floor ## SUFFIX (a); \
+ if (fetestexcept (FE_ALL_EXCEPT) == FE_ALL_EXCEPT) \
+ puts ("PASS: " #FLOAT); \
+ else \
+ { \
+ puts ("FAIL: " #FLOAT); \
+ result = 1; \
+ } \
+ /* But it mustn't lose exceptions from sNaN arguments. */ \
+ if (SNAN_TESTS (FLOAT)) \
+ { \
+ static volatile FLOAT snan = __builtin_nans ## SUFFIX (""); \
+ volatile FLOAT c __attribute__ ((unused)); \
+ feclearexcept (FE_ALL_EXCEPT); \
+ c = floor ## SUFFIX (snan); \
+ if (fetestexcept (FE_INVALID) == FE_INVALID) \
+ puts ("PASS: " #FLOAT " sNaN"); \
+ else \
+ { \
+ puts ("FAIL: " #FLOAT " sNaN"); \
+ result = 1; \
+ } \
+ } \
+ return result; \
+}
+
+TEST_FUNC (float_test, float, f)
+TEST_FUNC (double_test, double, )
+TEST_FUNC (ldouble_test, long double, l)
+
+static int
+do_test (void)
+{
+ int result = float_test ();
+ result |= double_test ();
+ result |= ldouble_test ();
+ if (!any_supported)
+ return 77;
+ return result;
+}
+
+#include <support/test-driver.c>
--
2.34.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 04/12] math: Add test to check if floor raise inexact floating-point exception
2023-12-28 17:20 ` [PATCH 04/12] math: Add test to check if floor " Adhemerval Zanella
@ 2024-04-01 14:02 ` H.J. Lu
0 siblings, 0 replies; 27+ messages in thread
From: H.J. Lu @ 2024-04-01 14:02 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: libc-alpha
On Thu, Dec 28, 2023 at 9:22 AM Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
>
> It is not allowed anymore on ISO C23.
> ---
> math/Makefile | 4 ++
> math/test-floor-except-2.c | 67 ++++++++++++++++++++++++++++++
> math/test-floor-except.c | 85 ++++++++++++++++++++++++++++++++++++++
> 3 files changed, 156 insertions(+)
> create mode 100644 math/test-floor-except-2.c
> create mode 100644 math/test-floor-except.c
>
> diff --git a/math/Makefile b/math/Makefile
> index 4fc7842313..19e234874a 100644
> --- a/math/Makefile
> +++ b/math/Makefile
> @@ -512,6 +512,8 @@ tests = \
> test-fetestexceptflag \
> test-fexcept \
> test-fexcept-traps \
> + test-floor-except \
> + test-floor-except-2 \
> test-flt-eval-method \
> test-fp-ilogb-constants \
> test-fp-llogb-constants \
> @@ -993,6 +995,8 @@ CFLAGS-test-nan-const.c += -fno-builtin
>
> CFLAGS-test-ceil-except.c += -fno-builtin
> CFLAGS-test-ceil-except-2.c += -fno-builtin
> +CFLAGS-test-floor-except.c += -fno-builtin
> +CFLAGS-test-floor-except-2.c += -fno-builtin
>
> include ../Rules
>
> diff --git a/math/test-floor-except-2.c b/math/test-floor-except-2.c
> new file mode 100644
> index 0000000000..01b22f984b
> --- /dev/null
> +++ b/math/test-floor-except-2.c
> @@ -0,0 +1,67 @@
> +/* Test floor functions do not disable exception traps.
> + Copyright (C) 2023 Free Software Foundation, Inc.
2024
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +#include <fenv.h>
> +#include <math.h>
> +#include <stdio.h>
> +
> +#ifndef FE_INEXACT
> +# define FE_INEXACT 0
> +#endif
> +
> +#define TEST_FUNC(NAME, FLOAT, SUFFIX) \
> +static int \
> +NAME (void) \
> +{ \
> + int result = 0; \
> + volatile FLOAT a, b __attribute__ ((unused)); \
> + a = 1.5; \
> + /* floor must work when traps on "inexact" are enabled. */ \
> + b = floor ## SUFFIX (a); \
> + /* And it must have left those traps enabled. */ \
> + if (fegetexcept () == FE_INEXACT) \
> + puts ("PASS: " #FLOAT); \
> + else \
> + { \
> + puts ("FAIL: " #FLOAT); \
> + result = 1; \
> + } \
> + return result; \
> +}
> +
> +TEST_FUNC (float_test, float, f)
> +TEST_FUNC (double_test, double, )
> +TEST_FUNC (ldouble_test, long double, l)
> +
> +static int
> +do_test (void)
> +{
> + if (feenableexcept (FE_INEXACT) == -1)
> + {
> + puts ("enabling FE_INEXACT traps failed, cannot test");
> + return 77;
> + }
> + int result = float_test ();
> + feenableexcept (FE_INEXACT);
> + result |= double_test ();
> + feenableexcept (FE_INEXACT);
> + result |= ldouble_test ();
> + return result;
> +}
> +
> +#include <support/test-driver.c>
> diff --git a/math/test-floor-except.c b/math/test-floor-except.c
> new file mode 100644
> index 0000000000..fe77866ddc
> --- /dev/null
> +++ b/math/test-floor-except.c
> @@ -0,0 +1,85 @@
> +/* Test floor functions do not clear exceptions.
> + Copyright (C) 2015-2023 Free Software Foundation, Inc.
Just 2024.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +#include <fenv.h>
> +#include <math.h>
> +#include <stdbool.h>
> +#include <stdio.h>
> +
> +#include <math-tests.h>
> +
> +#ifndef FE_INVALID
> +# define FE_INVALID 0
> +#endif
> +
> +static bool any_supported = false;
> +
> +#define TEST_FUNC(NAME, FLOAT, SUFFIX) \
> +static int \
> +NAME (void) \
> +{ \
> + int result = 0; \
> + if (!EXCEPTION_TESTS (FLOAT)) \
> + return 0; \
> + any_supported = true; \
> + volatile FLOAT a, b __attribute__ ((unused)); \
> + a = 1.0; \
> + /* floor must not clear already-raised exceptions. */ \
> + feraiseexcept (FE_ALL_EXCEPT); \
> + b = floor ## SUFFIX (a); \
> + if (fetestexcept (FE_ALL_EXCEPT) == FE_ALL_EXCEPT) \
> + puts ("PASS: " #FLOAT); \
> + else \
> + { \
> + puts ("FAIL: " #FLOAT); \
> + result = 1; \
> + } \
> + /* But it mustn't lose exceptions from sNaN arguments. */ \
> + if (SNAN_TESTS (FLOAT)) \
> + { \
> + static volatile FLOAT snan = __builtin_nans ## SUFFIX (""); \
> + volatile FLOAT c __attribute__ ((unused)); \
> + feclearexcept (FE_ALL_EXCEPT); \
> + c = floor ## SUFFIX (snan); \
> + if (fetestexcept (FE_INVALID) == FE_INVALID) \
> + puts ("PASS: " #FLOAT " sNaN"); \
> + else \
> + { \
> + puts ("FAIL: " #FLOAT " sNaN"); \
> + result = 1; \
> + } \
> + } \
> + return result; \
> +}
> +
> +TEST_FUNC (float_test, float, f)
> +TEST_FUNC (double_test, double, )
> +TEST_FUNC (ldouble_test, long double, l)
> +
> +static int
> +do_test (void)
> +{
> + int result = float_test ();
> + result |= double_test ();
> + result |= ldouble_test ();
> + if (!any_supported)
> + return 77;
> + return result;
> +}
> +
> +#include <support/test-driver.c>
> --
> 2.34.1
>
--
H.J.
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 05/12] math: Add test to check if trunc raise inexact floating-point exception
2023-12-28 17:20 [PATCH 00/12] Improve rounding to interger function for C23 Adhemerval Zanella
` (3 preceding siblings ...)
2023-12-28 17:20 ` [PATCH 04/12] math: Add test to check if floor " Adhemerval Zanella
@ 2023-12-28 17:20 ` Adhemerval Zanella
2024-04-01 14:03 ` H.J. Lu
2023-12-28 17:20 ` [PATCH 06/12] math: Add test to check if round " Adhemerval Zanella
` (7 subsequent siblings)
12 siblings, 1 reply; 27+ messages in thread
From: Adhemerval Zanella @ 2023-12-28 17:20 UTC (permalink / raw)
To: libc-alpha
It is not allowed anymore on ISO C23.
---
math/Makefile | 4 ++
math/test-trunc-except-2.c | 67 ++++++++++++++++++++++++++++++
math/test-trunc-except.c | 85 ++++++++++++++++++++++++++++++++++++++
3 files changed, 156 insertions(+)
create mode 100644 math/test-trunc-except-2.c
create mode 100644 math/test-trunc-except.c
diff --git a/math/Makefile b/math/Makefile
index 19e234874a..7ae107170c 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -541,6 +541,8 @@ tests = \
test-tgmath-int \
test-tgmath-ret \
test-tgmath2 \
+ test-trunc-except \
+ test-trunc-except-2 \
tst-CMPLX \
tst-CMPLX2 \
tst-definitions \
@@ -997,6 +999,8 @@ CFLAGS-test-ceil-except.c += -fno-builtin
CFLAGS-test-ceil-except-2.c += -fno-builtin
CFLAGS-test-floor-except.c += -fno-builtin
CFLAGS-test-floor-except-2.c += -fno-builtin
+CFLAGS-test-trunc-except.c += -fno-builtin
+CFLAGS-test-trunc-except-2.c += -fno-builtin
include ../Rules
diff --git a/math/test-trunc-except-2.c b/math/test-trunc-except-2.c
new file mode 100644
index 0000000000..29716efc0b
--- /dev/null
+++ b/math/test-trunc-except-2.c
@@ -0,0 +1,67 @@
+/* Test trunc functions do not disable exception traps.
+ Copyright (C) 2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <fenv.h>
+#include <math.h>
+#include <stdio.h>
+
+#ifndef FE_INEXACT
+# define FE_INEXACT 0
+#endif
+
+#define TEST_FUNC(NAME, FLOAT, SUFFIX) \
+static int \
+NAME (void) \
+{ \
+ int result = 0; \
+ volatile FLOAT a, b __attribute__ ((unused)); \
+ a = 1.5; \
+ /* trunc must work when traps on "inexact" are enabled. */ \
+ b = trunc ## SUFFIX (a); \
+ /* And it must have left those traps enabled. */ \
+ if (fegetexcept () == FE_INEXACT) \
+ puts ("PASS: " #FLOAT); \
+ else \
+ { \
+ puts ("FAIL: " #FLOAT); \
+ result = 1; \
+ } \
+ return result; \
+}
+
+TEST_FUNC (float_test, float, f)
+TEST_FUNC (double_test, double, )
+TEST_FUNC (ldouble_test, long double, l)
+
+static int
+do_test (void)
+{
+ if (feenableexcept (FE_INEXACT) == -1)
+ {
+ puts ("enabling FE_INEXACT traps failed, cannot test");
+ return 77;
+ }
+ int result = float_test ();
+ feenableexcept (FE_INEXACT);
+ result |= double_test ();
+ feenableexcept (FE_INEXACT);
+ result |= ldouble_test ();
+ return result;
+}
+
+#include <support/test-driver.c>
diff --git a/math/test-trunc-except.c b/math/test-trunc-except.c
new file mode 100644
index 0000000000..c9e341de0d
--- /dev/null
+++ b/math/test-trunc-except.c
@@ -0,0 +1,85 @@
+/* Test trunc functions do not clear exceptions.
+ Copyright (C) 2015-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <fenv.h>
+#include <math.h>
+#include <stdbool.h>
+#include <stdio.h>
+
+#include <math-tests.h>
+
+#ifndef FE_INVALID
+# define FE_INVALID 0
+#endif
+
+static bool any_supported = false;
+
+#define TEST_FUNC(NAME, FLOAT, SUFFIX) \
+static int \
+NAME (void) \
+{ \
+ int result = 0; \
+ if (!EXCEPTION_TESTS (FLOAT)) \
+ return 0; \
+ any_supported = true; \
+ volatile FLOAT a, b __attribute__ ((unused)); \
+ a = 1.0; \
+ /* trunc must not clear already-raised exceptions. */ \
+ feraiseexcept (FE_ALL_EXCEPT); \
+ b = trunc ## SUFFIX (a); \
+ if (fetestexcept (FE_ALL_EXCEPT) == FE_ALL_EXCEPT) \
+ puts ("PASS: " #FLOAT); \
+ else \
+ { \
+ puts ("FAIL: " #FLOAT); \
+ result = 1; \
+ } \
+ /* But it mustn't lose exceptions from sNaN arguments. */ \
+ if (SNAN_TESTS (FLOAT)) \
+ { \
+ static volatile FLOAT snan = __builtin_nans ## SUFFIX (""); \
+ volatile FLOAT c __attribute__ ((unused)); \
+ feclearexcept (FE_ALL_EXCEPT); \
+ c = trunc ## SUFFIX (snan); \
+ if (fetestexcept (FE_INVALID) == FE_INVALID) \
+ puts ("PASS: " #FLOAT " sNaN"); \
+ else \
+ { \
+ puts ("FAIL: " #FLOAT " sNaN"); \
+ result = 1; \
+ } \
+ } \
+ return result; \
+}
+
+TEST_FUNC (float_test, float, f)
+TEST_FUNC (double_test, double, )
+TEST_FUNC (ldouble_test, long double, l)
+
+static int
+do_test (void)
+{
+ int result = float_test ();
+ result |= double_test ();
+ result |= ldouble_test ();
+ if (!any_supported)
+ return 77;
+ return result;
+}
+
+#include <support/test-driver.c>
--
2.34.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 05/12] math: Add test to check if trunc raise inexact floating-point exception
2023-12-28 17:20 ` [PATCH 05/12] math: Add test to check if trunc " Adhemerval Zanella
@ 2024-04-01 14:03 ` H.J. Lu
0 siblings, 0 replies; 27+ messages in thread
From: H.J. Lu @ 2024-04-01 14:03 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: libc-alpha
On Thu, Dec 28, 2023 at 9:22 AM Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
>
> It is not allowed anymore on ISO C23.
> ---
> math/Makefile | 4 ++
> math/test-trunc-except-2.c | 67 ++++++++++++++++++++++++++++++
> math/test-trunc-except.c | 85 ++++++++++++++++++++++++++++++++++++++
> 3 files changed, 156 insertions(+)
> create mode 100644 math/test-trunc-except-2.c
> create mode 100644 math/test-trunc-except.c
>
> diff --git a/math/Makefile b/math/Makefile
> index 19e234874a..7ae107170c 100644
> --- a/math/Makefile
> +++ b/math/Makefile
> @@ -541,6 +541,8 @@ tests = \
> test-tgmath-int \
> test-tgmath-ret \
> test-tgmath2 \
> + test-trunc-except \
> + test-trunc-except-2 \
> tst-CMPLX \
> tst-CMPLX2 \
> tst-definitions \
> @@ -997,6 +999,8 @@ CFLAGS-test-ceil-except.c += -fno-builtin
> CFLAGS-test-ceil-except-2.c += -fno-builtin
> CFLAGS-test-floor-except.c += -fno-builtin
> CFLAGS-test-floor-except-2.c += -fno-builtin
> +CFLAGS-test-trunc-except.c += -fno-builtin
> +CFLAGS-test-trunc-except-2.c += -fno-builtin
>
> include ../Rules
>
> diff --git a/math/test-trunc-except-2.c b/math/test-trunc-except-2.c
> new file mode 100644
> index 0000000000..29716efc0b
> --- /dev/null
> +++ b/math/test-trunc-except-2.c
> @@ -0,0 +1,67 @@
> +/* Test trunc functions do not disable exception traps.
> + Copyright (C) 2023 Free Software Foundation, Inc.
2024
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +#include <fenv.h>
> +#include <math.h>
> +#include <stdio.h>
> +
> +#ifndef FE_INEXACT
> +# define FE_INEXACT 0
> +#endif
> +
> +#define TEST_FUNC(NAME, FLOAT, SUFFIX) \
> +static int \
> +NAME (void) \
> +{ \
> + int result = 0; \
> + volatile FLOAT a, b __attribute__ ((unused)); \
> + a = 1.5; \
> + /* trunc must work when traps on "inexact" are enabled. */ \
> + b = trunc ## SUFFIX (a); \
> + /* And it must have left those traps enabled. */ \
> + if (fegetexcept () == FE_INEXACT) \
> + puts ("PASS: " #FLOAT); \
> + else \
> + { \
> + puts ("FAIL: " #FLOAT); \
> + result = 1; \
> + } \
> + return result; \
> +}
> +
> +TEST_FUNC (float_test, float, f)
> +TEST_FUNC (double_test, double, )
> +TEST_FUNC (ldouble_test, long double, l)
> +
> +static int
> +do_test (void)
> +{
> + if (feenableexcept (FE_INEXACT) == -1)
> + {
> + puts ("enabling FE_INEXACT traps failed, cannot test");
> + return 77;
> + }
> + int result = float_test ();
> + feenableexcept (FE_INEXACT);
> + result |= double_test ();
> + feenableexcept (FE_INEXACT);
> + result |= ldouble_test ();
> + return result;
> +}
> +
> +#include <support/test-driver.c>
> diff --git a/math/test-trunc-except.c b/math/test-trunc-except.c
> new file mode 100644
> index 0000000000..c9e341de0d
> --- /dev/null
> +++ b/math/test-trunc-except.c
> @@ -0,0 +1,85 @@
> +/* Test trunc functions do not clear exceptions.
> + Copyright (C) 2015-2023 Free Software Foundation, Inc.
Just 2024.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +#include <fenv.h>
> +#include <math.h>
> +#include <stdbool.h>
> +#include <stdio.h>
> +
> +#include <math-tests.h>
> +
> +#ifndef FE_INVALID
> +# define FE_INVALID 0
> +#endif
> +
> +static bool any_supported = false;
> +
> +#define TEST_FUNC(NAME, FLOAT, SUFFIX) \
> +static int \
> +NAME (void) \
> +{ \
> + int result = 0; \
> + if (!EXCEPTION_TESTS (FLOAT)) \
> + return 0; \
> + any_supported = true; \
> + volatile FLOAT a, b __attribute__ ((unused)); \
> + a = 1.0; \
> + /* trunc must not clear already-raised exceptions. */ \
> + feraiseexcept (FE_ALL_EXCEPT); \
> + b = trunc ## SUFFIX (a); \
> + if (fetestexcept (FE_ALL_EXCEPT) == FE_ALL_EXCEPT) \
> + puts ("PASS: " #FLOAT); \
> + else \
> + { \
> + puts ("FAIL: " #FLOAT); \
> + result = 1; \
> + } \
> + /* But it mustn't lose exceptions from sNaN arguments. */ \
> + if (SNAN_TESTS (FLOAT)) \
> + { \
> + static volatile FLOAT snan = __builtin_nans ## SUFFIX (""); \
> + volatile FLOAT c __attribute__ ((unused)); \
> + feclearexcept (FE_ALL_EXCEPT); \
> + c = trunc ## SUFFIX (snan); \
> + if (fetestexcept (FE_INVALID) == FE_INVALID) \
> + puts ("PASS: " #FLOAT " sNaN"); \
> + else \
> + { \
> + puts ("FAIL: " #FLOAT " sNaN"); \
> + result = 1; \
> + } \
> + } \
> + return result; \
> +}
> +
> +TEST_FUNC (float_test, float, f)
> +TEST_FUNC (double_test, double, )
> +TEST_FUNC (ldouble_test, long double, l)
> +
> +static int
> +do_test (void)
> +{
> + int result = float_test ();
> + result |= double_test ();
> + result |= ldouble_test ();
> + if (!any_supported)
> + return 77;
> + return result;
> +}
> +
> +#include <support/test-driver.c>
> --
> 2.34.1
>
--
H.J.
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 06/12] math: Add test to check if round raise inexact floating-point exception
2023-12-28 17:20 [PATCH 00/12] Improve rounding to interger function for C23 Adhemerval Zanella
` (4 preceding siblings ...)
2023-12-28 17:20 ` [PATCH 05/12] math: Add test to check if trunc " Adhemerval Zanella
@ 2023-12-28 17:20 ` Adhemerval Zanella
2024-04-01 14:02 ` H.J. Lu
2023-12-28 17:20 ` [PATCH 07/12] x86: Do not raise inexact exception on ceill Adhemerval Zanella
` (6 subsequent siblings)
12 siblings, 1 reply; 27+ messages in thread
From: Adhemerval Zanella @ 2023-12-28 17:20 UTC (permalink / raw)
To: libc-alpha
It is not allowed anymore on ISO C23.
---
math/Makefile | 4 ++
math/test-round-except-2.c | 67 ++++++++++++++++++++++++++++++
math/test-round-except.c | 85 ++++++++++++++++++++++++++++++++++++++
3 files changed, 156 insertions(+)
create mode 100644 math/test-round-except-2.c
create mode 100644 math/test-round-except.c
diff --git a/math/Makefile b/math/Makefile
index 7ae107170c..dfe24a8c03 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -530,6 +530,8 @@ tests = \
test-nearbyint-except \
test-nearbyint-except-2 \
test-powl \
+ test-round-except \
+ test-round-except-2 \
test-signgam-uchar \
test-signgam-uchar-init \
test-signgam-uint \
@@ -1001,6 +1003,8 @@ CFLAGS-test-floor-except.c += -fno-builtin
CFLAGS-test-floor-except-2.c += -fno-builtin
CFLAGS-test-trunc-except.c += -fno-builtin
CFLAGS-test-trunc-except-2.c += -fno-builtin
+CFLAGS-test-round-except.c += -fno-builtin
+CFLAGS-test-round-except-2.c += -fno-builtin
include ../Rules
diff --git a/math/test-round-except-2.c b/math/test-round-except-2.c
new file mode 100644
index 0000000000..dffc02e91f
--- /dev/null
+++ b/math/test-round-except-2.c
@@ -0,0 +1,67 @@
+/* Test round functions do not disable exception traps.
+ Copyright (C) 2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <fenv.h>
+#include <math.h>
+#include <stdio.h>
+
+#ifndef FE_INEXACT
+# define FE_INEXACT 0
+#endif
+
+#define TEST_FUNC(NAME, FLOAT, SUFFIX) \
+static int \
+NAME (void) \
+{ \
+ int result = 0; \
+ volatile FLOAT a, b __attribute__ ((unused)); \
+ a = 1.5; \
+ /* round must work when traps on "inexact" are enabled. */ \
+ b = round ## SUFFIX (a); \
+ /* And it must have left those traps enabled. */ \
+ if (fegetexcept () == FE_INEXACT) \
+ puts ("PASS: " #FLOAT); \
+ else \
+ { \
+ puts ("FAIL: " #FLOAT); \
+ result = 1; \
+ } \
+ return result; \
+}
+
+TEST_FUNC (float_test, float, f)
+TEST_FUNC (double_test, double, )
+TEST_FUNC (ldouble_test, long double, l)
+
+static int
+do_test (void)
+{
+ if (feenableexcept (FE_INEXACT) == -1)
+ {
+ puts ("enabling FE_INEXACT traps failed, cannot test");
+ return 77;
+ }
+ int result = float_test ();
+ feenableexcept (FE_INEXACT);
+ result |= double_test ();
+ feenableexcept (FE_INEXACT);
+ result |= ldouble_test ();
+ return result;
+}
+
+#include <support/test-driver.c>
diff --git a/math/test-round-except.c b/math/test-round-except.c
new file mode 100644
index 0000000000..cd43c964ab
--- /dev/null
+++ b/math/test-round-except.c
@@ -0,0 +1,85 @@
+/* Test round functions do not clear exceptions.
+ Copyright (C) 2015-2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <fenv.h>
+#include <math.h>
+#include <stdbool.h>
+#include <stdio.h>
+
+#include <math-tests.h>
+
+#ifndef FE_INVALID
+# define FE_INVALID 0
+#endif
+
+static bool any_supported = false;
+
+#define TEST_FUNC(NAME, FLOAT, SUFFIX) \
+static int \
+NAME (void) \
+{ \
+ int result = 0; \
+ if (!EXCEPTION_TESTS (FLOAT)) \
+ return 0; \
+ any_supported = true; \
+ volatile FLOAT a, b __attribute__ ((unused)); \
+ a = 1.0; \
+ /* round must not clear already-raised exceptions. */ \
+ feraiseexcept (FE_ALL_EXCEPT); \
+ b = round ## SUFFIX (a); \
+ if (fetestexcept (FE_ALL_EXCEPT) == FE_ALL_EXCEPT) \
+ puts ("PASS: " #FLOAT); \
+ else \
+ { \
+ puts ("FAIL: " #FLOAT); \
+ result = 1; \
+ } \
+ /* But it mustn't lose exceptions from sNaN arguments. */ \
+ if (SNAN_TESTS (FLOAT)) \
+ { \
+ static volatile FLOAT snan = __builtin_nans ## SUFFIX (""); \
+ volatile FLOAT c __attribute__ ((unused)); \
+ feclearexcept (FE_ALL_EXCEPT); \
+ c = round ## SUFFIX (snan); \
+ if (fetestexcept (FE_INVALID) == FE_INVALID) \
+ puts ("PASS: " #FLOAT " sNaN"); \
+ else \
+ { \
+ puts ("FAIL: " #FLOAT " sNaN"); \
+ result = 1; \
+ } \
+ } \
+ return result; \
+}
+
+TEST_FUNC (float_test, float, f)
+TEST_FUNC (double_test, double, )
+TEST_FUNC (ldouble_test, long double, l)
+
+static int
+do_test (void)
+{
+ int result = float_test ();
+ result |= double_test ();
+ result |= ldouble_test ();
+ if (!any_supported)
+ return 77;
+ return result;
+}
+
+#include <support/test-driver.c>
--
2.34.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 06/12] math: Add test to check if round raise inexact floating-point exception
2023-12-28 17:20 ` [PATCH 06/12] math: Add test to check if round " Adhemerval Zanella
@ 2024-04-01 14:02 ` H.J. Lu
0 siblings, 0 replies; 27+ messages in thread
From: H.J. Lu @ 2024-04-01 14:02 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: libc-alpha
On Thu, Dec 28, 2023 at 9:22 AM Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
>
> It is not allowed anymore on ISO C23.
> ---
> math/Makefile | 4 ++
> math/test-round-except-2.c | 67 ++++++++++++++++++++++++++++++
> math/test-round-except.c | 85 ++++++++++++++++++++++++++++++++++++++
> 3 files changed, 156 insertions(+)
> create mode 100644 math/test-round-except-2.c
> create mode 100644 math/test-round-except.c
>
> diff --git a/math/Makefile b/math/Makefile
> index 7ae107170c..dfe24a8c03 100644
> --- a/math/Makefile
> +++ b/math/Makefile
> @@ -530,6 +530,8 @@ tests = \
> test-nearbyint-except \
> test-nearbyint-except-2 \
> test-powl \
> + test-round-except \
> + test-round-except-2 \
> test-signgam-uchar \
> test-signgam-uchar-init \
> test-signgam-uint \
> @@ -1001,6 +1003,8 @@ CFLAGS-test-floor-except.c += -fno-builtin
> CFLAGS-test-floor-except-2.c += -fno-builtin
> CFLAGS-test-trunc-except.c += -fno-builtin
> CFLAGS-test-trunc-except-2.c += -fno-builtin
> +CFLAGS-test-round-except.c += -fno-builtin
> +CFLAGS-test-round-except-2.c += -fno-builtin
>
> include ../Rules
>
> diff --git a/math/test-round-except-2.c b/math/test-round-except-2.c
> new file mode 100644
> index 0000000000..dffc02e91f
> --- /dev/null
> +++ b/math/test-round-except-2.c
> @@ -0,0 +1,67 @@
> +/* Test round functions do not disable exception traps.
> + Copyright (C) 2023 Free Software Foundation, Inc.
2024
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +#include <fenv.h>
> +#include <math.h>
> +#include <stdio.h>
> +
> +#ifndef FE_INEXACT
> +# define FE_INEXACT 0
> +#endif
> +
> +#define TEST_FUNC(NAME, FLOAT, SUFFIX) \
> +static int \
> +NAME (void) \
> +{ \
> + int result = 0; \
> + volatile FLOAT a, b __attribute__ ((unused)); \
> + a = 1.5; \
> + /* round must work when traps on "inexact" are enabled. */ \
> + b = round ## SUFFIX (a); \
> + /* And it must have left those traps enabled. */ \
> + if (fegetexcept () == FE_INEXACT) \
> + puts ("PASS: " #FLOAT); \
> + else \
> + { \
> + puts ("FAIL: " #FLOAT); \
> + result = 1; \
> + } \
> + return result; \
> +}
> +
> +TEST_FUNC (float_test, float, f)
> +TEST_FUNC (double_test, double, )
> +TEST_FUNC (ldouble_test, long double, l)
> +
> +static int
> +do_test (void)
> +{
> + if (feenableexcept (FE_INEXACT) == -1)
> + {
> + puts ("enabling FE_INEXACT traps failed, cannot test");
> + return 77;
> + }
> + int result = float_test ();
> + feenableexcept (FE_INEXACT);
> + result |= double_test ();
> + feenableexcept (FE_INEXACT);
> + result |= ldouble_test ();
> + return result;
> +}
> +
> +#include <support/test-driver.c>
> diff --git a/math/test-round-except.c b/math/test-round-except.c
> new file mode 100644
> index 0000000000..cd43c964ab
> --- /dev/null
> +++ b/math/test-round-except.c
> @@ -0,0 +1,85 @@
> +/* Test round functions do not clear exceptions.
> + Copyright (C) 2015-2023 Free Software Foundation, Inc.
Just 2024.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +#include <fenv.h>
> +#include <math.h>
> +#include <stdbool.h>
> +#include <stdio.h>
> +
> +#include <math-tests.h>
> +
> +#ifndef FE_INVALID
> +# define FE_INVALID 0
> +#endif
> +
> +static bool any_supported = false;
> +
> +#define TEST_FUNC(NAME, FLOAT, SUFFIX) \
> +static int \
> +NAME (void) \
> +{ \
> + int result = 0; \
> + if (!EXCEPTION_TESTS (FLOAT)) \
> + return 0; \
> + any_supported = true; \
> + volatile FLOAT a, b __attribute__ ((unused)); \
> + a = 1.0; \
> + /* round must not clear already-raised exceptions. */ \
> + feraiseexcept (FE_ALL_EXCEPT); \
> + b = round ## SUFFIX (a); \
> + if (fetestexcept (FE_ALL_EXCEPT) == FE_ALL_EXCEPT) \
> + puts ("PASS: " #FLOAT); \
> + else \
> + { \
> + puts ("FAIL: " #FLOAT); \
> + result = 1; \
> + } \
> + /* But it mustn't lose exceptions from sNaN arguments. */ \
> + if (SNAN_TESTS (FLOAT)) \
> + { \
> + static volatile FLOAT snan = __builtin_nans ## SUFFIX (""); \
> + volatile FLOAT c __attribute__ ((unused)); \
> + feclearexcept (FE_ALL_EXCEPT); \
> + c = round ## SUFFIX (snan); \
> + if (fetestexcept (FE_INVALID) == FE_INVALID) \
> + puts ("PASS: " #FLOAT " sNaN"); \
> + else \
> + { \
> + puts ("FAIL: " #FLOAT " sNaN"); \
> + result = 1; \
> + } \
> + } \
> + return result; \
> +}
> +
> +TEST_FUNC (float_test, float, f)
> +TEST_FUNC (double_test, double, )
> +TEST_FUNC (ldouble_test, long double, l)
> +
> +static int
> +do_test (void)
> +{
> + int result = float_test ();
> + result |= double_test ();
> + result |= ldouble_test ();
> + if (!any_supported)
> + return 77;
> + return result;
> +}
> +
> +#include <support/test-driver.c>
> --
> 2.34.1
>
--
H.J.
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 07/12] x86: Do not raise inexact exception on ceill
2023-12-28 17:20 [PATCH 00/12] Improve rounding to interger function for C23 Adhemerval Zanella
` (5 preceding siblings ...)
2023-12-28 17:20 ` [PATCH 06/12] math: Add test to check if round " Adhemerval Zanella
@ 2023-12-28 17:20 ` Adhemerval Zanella
2024-04-01 14:12 ` H.J. Lu
2023-12-28 17:20 ` [PATCH 08/12] x86: Do not raise inexact exception on floorl Adhemerval Zanella
` (5 subsequent siblings)
12 siblings, 1 reply; 27+ messages in thread
From: Adhemerval Zanella @ 2023-12-28 17:20 UTC (permalink / raw)
To: libc-alpha
It is not allowed anymore on ISO C23.
Checked on x86_64-linux-gnu and i686-linux-gnu.
---
sysdeps/i386/fpu/s_ceill.S | 39 ------------------------------------
sysdeps/x86/fpu/s_ceill.c | 38 +++++++++++++++++++++++++++++++++++
sysdeps/x86_64/fpu/s_ceill.S | 34 -------------------------------
3 files changed, 38 insertions(+), 73 deletions(-)
delete mode 100644 sysdeps/i386/fpu/s_ceill.S
create mode 100644 sysdeps/x86/fpu/s_ceill.c
delete mode 100644 sysdeps/x86_64/fpu/s_ceill.S
diff --git a/sysdeps/i386/fpu/s_ceill.S b/sysdeps/i386/fpu/s_ceill.S
deleted file mode 100644
index a551fce7f9..0000000000
--- a/sysdeps/i386/fpu/s_ceill.S
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Public domain.
- */
-
-#include <libm-alias-ldouble.h>
-#include <machine/asm.h>
-
-RCSID("$NetBSD: $")
-
-ENTRY(__ceill)
- fldt 4(%esp)
- subl $32,%esp
- cfi_adjust_cfa_offset (32)
-
- fnstenv 4(%esp) /* store fpu environment */
-
- /* We use here %edx although only the low 1 bits are defined.
- But none of the operations should care and they are faster
- than the 16 bit operations. */
- movl $0x0800,%edx /* round towards +oo */
- orl 4(%esp),%edx
- andl $0xfbff,%edx
- movl %edx,(%esp)
- fldcw (%esp) /* load modified control word */
-
- frndint /* round */
-
- /* Preserve "invalid" exceptions from sNaN input. */
- fnstsw
- andl $0x1, %eax
- orl %eax, 8(%esp)
-
- fldenv 4(%esp) /* restore original environment */
-
- addl $32,%esp
- cfi_adjust_cfa_offset (-32)
- ret
-END (__ceill)
-libm_alias_ldouble (__ceil, ceil)
diff --git a/sysdeps/x86/fpu/s_ceill.c b/sysdeps/x86/fpu/s_ceill.c
new file mode 100644
index 0000000000..96c901e383
--- /dev/null
+++ b/sysdeps/x86/fpu/s_ceill.c
@@ -0,0 +1,38 @@
+/* Return smallest integral value not less than argument. x86 version.
+ Copyright (C) 2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#define NO_MATH_REDIRECT
+#include <math.h>
+#include <fenv_private.h>
+#include <libm-alias-ldouble.h>
+
+long double
+__ceill (long double x)
+{
+ fenv_t fenv;
+ long double r;
+
+ libc_feholdexcept_setround_387 (&fenv, FE_UPWARD);
+ asm volatile ("frndint" : "=t" (r) : "0" (x));
+ /* Preserve "invalid" exceptions from sNaN input. */
+ fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID);
+ libc_fesetenv_387 (&fenv);
+
+ return r;
+}
+libm_alias_ldouble (__ceil, ceil)
diff --git a/sysdeps/x86_64/fpu/s_ceill.S b/sysdeps/x86_64/fpu/s_ceill.S
deleted file mode 100644
index 16dbecd56d..0000000000
--- a/sysdeps/x86_64/fpu/s_ceill.S
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Public domain.
- */
-
-#include <libm-alias-ldouble.h>
-#include <machine/asm.h>
-
-
-ENTRY(__ceill)
- fldt 8(%rsp)
-
- fnstenv -28(%rsp) /* store fpu environment */
-
- /* We use here %edx although only the low 1 bits are defined.
- But none of the operations should care and they are faster
- than the 16 bit operations. */
- movl $0x0800,%edx /* round towards +oo */
- orl -28(%rsp),%edx
- andl $0xfbff,%edx
- movl %edx,-32(%rsp)
- fldcw -32(%rsp) /* load modified control word */
-
- frndint /* round */
-
- /* Preserve "invalid" exceptions from sNaN input. */
- fnstsw
- andl $0x1, %eax
- orl %eax, -24(%rsp)
-
- fldenv -28(%rsp) /* restore original environment */
-
- ret
-END (__ceill)
-libm_alias_ldouble (__ceil, ceil)
--
2.34.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 07/12] x86: Do not raise inexact exception on ceill
2023-12-28 17:20 ` [PATCH 07/12] x86: Do not raise inexact exception on ceill Adhemerval Zanella
@ 2024-04-01 14:12 ` H.J. Lu
0 siblings, 0 replies; 27+ messages in thread
From: H.J. Lu @ 2024-04-01 14:12 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: libc-alpha
On Thu, Dec 28, 2023 at 9:23 AM Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
>
> It is not allowed anymore on ISO C23.
>
> Checked on x86_64-linux-gnu and i686-linux-gnu.
> ---
> sysdeps/i386/fpu/s_ceill.S | 39 ------------------------------------
> sysdeps/x86/fpu/s_ceill.c | 38 +++++++++++++++++++++++++++++++++++
> sysdeps/x86_64/fpu/s_ceill.S | 34 -------------------------------
> 3 files changed, 38 insertions(+), 73 deletions(-)
> delete mode 100644 sysdeps/i386/fpu/s_ceill.S
> create mode 100644 sysdeps/x86/fpu/s_ceill.c
> delete mode 100644 sysdeps/x86_64/fpu/s_ceill.S
>
> diff --git a/sysdeps/i386/fpu/s_ceill.S b/sysdeps/i386/fpu/s_ceill.S
> deleted file mode 100644
> index a551fce7f9..0000000000
> --- a/sysdeps/i386/fpu/s_ceill.S
> +++ /dev/null
> @@ -1,39 +0,0 @@
> -/*
> - * Public domain.
> - */
> -
> -#include <libm-alias-ldouble.h>
> -#include <machine/asm.h>
> -
> -RCSID("$NetBSD: $")
> -
> -ENTRY(__ceill)
> - fldt 4(%esp)
> - subl $32,%esp
> - cfi_adjust_cfa_offset (32)
> -
> - fnstenv 4(%esp) /* store fpu environment */
> -
> - /* We use here %edx although only the low 1 bits are defined.
> - But none of the operations should care and they are faster
> - than the 16 bit operations. */
> - movl $0x0800,%edx /* round towards +oo */
> - orl 4(%esp),%edx
> - andl $0xfbff,%edx
> - movl %edx,(%esp)
> - fldcw (%esp) /* load modified control word */
> -
> - frndint /* round */
> -
> - /* Preserve "invalid" exceptions from sNaN input. */
> - fnstsw
> - andl $0x1, %eax
> - orl %eax, 8(%esp)
> -
> - fldenv 4(%esp) /* restore original environment */
> -
> - addl $32,%esp
> - cfi_adjust_cfa_offset (-32)
> - ret
> -END (__ceill)
> -libm_alias_ldouble (__ceil, ceil)
> diff --git a/sysdeps/x86/fpu/s_ceill.c b/sysdeps/x86/fpu/s_ceill.c
> new file mode 100644
> index 0000000000..96c901e383
> --- /dev/null
> +++ b/sysdeps/x86/fpu/s_ceill.c
> @@ -0,0 +1,38 @@
> +/* Return smallest integral value not less than argument. x86 version.
> + Copyright (C) 2023 Free Software Foundation, Inc.
2024.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +#define NO_MATH_REDIRECT
> +#include <math.h>
> +#include <fenv_private.h>
> +#include <libm-alias-ldouble.h>
> +
> +long double
> +__ceill (long double x)
> +{
> + fenv_t fenv;
> + long double r;
> +
> + libc_feholdexcept_setround_387 (&fenv, FE_UPWARD);
> + asm volatile ("frndint" : "=t" (r) : "0" (x));
> + /* Preserve "invalid" exceptions from sNaN input. */
> + fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID);
> + libc_fesetenv_387 (&fenv);
> +
> + return r;
> +}
> +libm_alias_ldouble (__ceil, ceil)
> diff --git a/sysdeps/x86_64/fpu/s_ceill.S b/sysdeps/x86_64/fpu/s_ceill.S
> deleted file mode 100644
> index 16dbecd56d..0000000000
> --- a/sysdeps/x86_64/fpu/s_ceill.S
> +++ /dev/null
> @@ -1,34 +0,0 @@
> -/*
> - * Public domain.
> - */
> -
> -#include <libm-alias-ldouble.h>
> -#include <machine/asm.h>
> -
> -
> -ENTRY(__ceill)
> - fldt 8(%rsp)
> -
> - fnstenv -28(%rsp) /* store fpu environment */
> -
> - /* We use here %edx although only the low 1 bits are defined.
> - But none of the operations should care and they are faster
> - than the 16 bit operations. */
> - movl $0x0800,%edx /* round towards +oo */
> - orl -28(%rsp),%edx
> - andl $0xfbff,%edx
> - movl %edx,-32(%rsp)
> - fldcw -32(%rsp) /* load modified control word */
> -
> - frndint /* round */
> -
> - /* Preserve "invalid" exceptions from sNaN input. */
> - fnstsw
> - andl $0x1, %eax
> - orl %eax, -24(%rsp)
> -
> - fldenv -28(%rsp) /* restore original environment */
> -
> - ret
> -END (__ceill)
> -libm_alias_ldouble (__ceil, ceil)
> --
> 2.34.1
>
--
H.J.
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 08/12] x86: Do not raise inexact exception on floorl
2023-12-28 17:20 [PATCH 00/12] Improve rounding to interger function for C23 Adhemerval Zanella
` (6 preceding siblings ...)
2023-12-28 17:20 ` [PATCH 07/12] x86: Do not raise inexact exception on ceill Adhemerval Zanella
@ 2023-12-28 17:20 ` Adhemerval Zanella
2024-04-01 14:13 ` H.J. Lu
2023-12-28 17:20 ` [PATCH 09/12] x86: Do not raise inexact exception on truncl Adhemerval Zanella
` (4 subsequent siblings)
12 siblings, 1 reply; 27+ messages in thread
From: Adhemerval Zanella @ 2023-12-28 17:20 UTC (permalink / raw)
To: libc-alpha
It is not allowed anymore on ISO C23.
Checked on x86_64-linux-gnu and i686-linux-gnu.
---
sysdeps/i386/fpu/s_floorl.S | 39 -----------------------------------
sysdeps/x86/fpu/s_floorl.c | 38 ++++++++++++++++++++++++++++++++++
sysdeps/x86_64/fpu/s_floorl.S | 33 -----------------------------
3 files changed, 38 insertions(+), 72 deletions(-)
delete mode 100644 sysdeps/i386/fpu/s_floorl.S
create mode 100644 sysdeps/x86/fpu/s_floorl.c
delete mode 100644 sysdeps/x86_64/fpu/s_floorl.S
diff --git a/sysdeps/i386/fpu/s_floorl.S b/sysdeps/i386/fpu/s_floorl.S
deleted file mode 100644
index 3ec28b477b..0000000000
--- a/sysdeps/i386/fpu/s_floorl.S
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Public domain.
- */
-
-#include <libm-alias-ldouble.h>
-#include <machine/asm.h>
-
-RCSID("$NetBSD: $")
-
-ENTRY(__floorl)
- fldt 4(%esp)
- subl $32,%esp
- cfi_adjust_cfa_offset (32)
-
- fnstenv 4(%esp) /* store fpu environment */
-
- /* We use here %edx although only the low 1 bits are defined.
- But none of the operations should care and they are faster
- than the 16 bit operations. */
- movl $0x400,%edx /* round towards -oo */
- orl 4(%esp),%edx
- andl $0xf7ff,%edx
- movl %edx,(%esp)
- fldcw (%esp) /* load modified control word */
-
- frndint /* round */
-
- /* Preserve "invalid" exceptions from sNaN input. */
- fnstsw
- andl $0x1, %eax
- orl %eax, 8(%esp)
-
- fldenv 4(%esp) /* restore original environment */
-
- addl $32,%esp
- cfi_adjust_cfa_offset (-32)
- ret
-END (__floorl)
-libm_alias_ldouble (__floor, floor)
diff --git a/sysdeps/x86/fpu/s_floorl.c b/sysdeps/x86/fpu/s_floorl.c
new file mode 100644
index 0000000000..edaf5e954f
--- /dev/null
+++ b/sysdeps/x86/fpu/s_floorl.c
@@ -0,0 +1,38 @@
+/* Return largest integral value not less than argument. x86 version.
+ Copyright (C) 2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#define NO_MATH_REDIRECT
+#include <math.h>
+#include <fenv_private.h>
+#include <libm-alias-ldouble.h>
+
+long double
+__floorl (long double x)
+{
+ fenv_t fenv;
+ long double r;
+
+ libc_feholdexcept_setround_387 (&fenv, FE_DOWNWARD);
+ asm volatile ("frndint" : "=t" (r) : "0" (x));
+ /* Preserve "invalid" exceptions from sNaN input. */
+ fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID);
+ libc_fesetenv_387 (&fenv);
+
+ return r;
+}
+libm_alias_ldouble (__floor, floor)
diff --git a/sysdeps/x86_64/fpu/s_floorl.S b/sysdeps/x86_64/fpu/s_floorl.S
deleted file mode 100644
index b74d1a4d6b..0000000000
--- a/sysdeps/x86_64/fpu/s_floorl.S
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Public domain.
- */
-
-#include <libm-alias-ldouble.h>
-#include <machine/asm.h>
-
-ENTRY(__floorl)
- fldt 8(%rsp)
-
- fnstenv -28(%rsp) /* store fpu environment */
-
- /* We use here %edx although only the low 1 bits are defined.
- But none of the operations should care and they are faster
- than the 16 bit operations. */
- movl $0x400,%edx /* round towards -oo */
- orl -28(%rsp),%edx
- andl $0xf7ff,%edx
- movl %edx,-32(%rsp)
- fldcw -32(%rsp) /* load modified control word */
-
- frndint /* round */
-
- /* Preserve "invalid" exceptions from sNaN input. */
- fnstsw
- andl $0x1, %eax
- orl %eax, -24(%rsp)
-
- fldenv -28(%rsp) /* restore original environment */
-
- ret
-END (__floorl)
-libm_alias_ldouble (__floor, floor)
--
2.34.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 08/12] x86: Do not raise inexact exception on floorl
2023-12-28 17:20 ` [PATCH 08/12] x86: Do not raise inexact exception on floorl Adhemerval Zanella
@ 2024-04-01 14:13 ` H.J. Lu
0 siblings, 0 replies; 27+ messages in thread
From: H.J. Lu @ 2024-04-01 14:13 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: libc-alpha
On Thu, Dec 28, 2023 at 9:23 AM Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
>
> It is not allowed anymore on ISO C23.
>
> Checked on x86_64-linux-gnu and i686-linux-gnu.
> ---
> sysdeps/i386/fpu/s_floorl.S | 39 -----------------------------------
> sysdeps/x86/fpu/s_floorl.c | 38 ++++++++++++++++++++++++++++++++++
> sysdeps/x86_64/fpu/s_floorl.S | 33 -----------------------------
> 3 files changed, 38 insertions(+), 72 deletions(-)
> delete mode 100644 sysdeps/i386/fpu/s_floorl.S
> create mode 100644 sysdeps/x86/fpu/s_floorl.c
> delete mode 100644 sysdeps/x86_64/fpu/s_floorl.S
>
> diff --git a/sysdeps/i386/fpu/s_floorl.S b/sysdeps/i386/fpu/s_floorl.S
> deleted file mode 100644
> index 3ec28b477b..0000000000
> --- a/sysdeps/i386/fpu/s_floorl.S
> +++ /dev/null
> @@ -1,39 +0,0 @@
> -/*
> - * Public domain.
> - */
> -
> -#include <libm-alias-ldouble.h>
> -#include <machine/asm.h>
> -
> -RCSID("$NetBSD: $")
> -
> -ENTRY(__floorl)
> - fldt 4(%esp)
> - subl $32,%esp
> - cfi_adjust_cfa_offset (32)
> -
> - fnstenv 4(%esp) /* store fpu environment */
> -
> - /* We use here %edx although only the low 1 bits are defined.
> - But none of the operations should care and they are faster
> - than the 16 bit operations. */
> - movl $0x400,%edx /* round towards -oo */
> - orl 4(%esp),%edx
> - andl $0xf7ff,%edx
> - movl %edx,(%esp)
> - fldcw (%esp) /* load modified control word */
> -
> - frndint /* round */
> -
> - /* Preserve "invalid" exceptions from sNaN input. */
> - fnstsw
> - andl $0x1, %eax
> - orl %eax, 8(%esp)
> -
> - fldenv 4(%esp) /* restore original environment */
> -
> - addl $32,%esp
> - cfi_adjust_cfa_offset (-32)
> - ret
> -END (__floorl)
> -libm_alias_ldouble (__floor, floor)
> diff --git a/sysdeps/x86/fpu/s_floorl.c b/sysdeps/x86/fpu/s_floorl.c
> new file mode 100644
> index 0000000000..edaf5e954f
> --- /dev/null
> +++ b/sysdeps/x86/fpu/s_floorl.c
> @@ -0,0 +1,38 @@
> +/* Return largest integral value not less than argument. x86 version.
> + Copyright (C) 2023 Free Software Foundation, Inc.
2024.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +#define NO_MATH_REDIRECT
> +#include <math.h>
> +#include <fenv_private.h>
> +#include <libm-alias-ldouble.h>
> +
> +long double
> +__floorl (long double x)
> +{
> + fenv_t fenv;
> + long double r;
> +
> + libc_feholdexcept_setround_387 (&fenv, FE_DOWNWARD);
> + asm volatile ("frndint" : "=t" (r) : "0" (x));
> + /* Preserve "invalid" exceptions from sNaN input. */
> + fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID);
> + libc_fesetenv_387 (&fenv);
> +
> + return r;
> +}
> +libm_alias_ldouble (__floor, floor)
> diff --git a/sysdeps/x86_64/fpu/s_floorl.S b/sysdeps/x86_64/fpu/s_floorl.S
> deleted file mode 100644
> index b74d1a4d6b..0000000000
> --- a/sysdeps/x86_64/fpu/s_floorl.S
> +++ /dev/null
> @@ -1,33 +0,0 @@
> -/*
> - * Public domain.
> - */
> -
> -#include <libm-alias-ldouble.h>
> -#include <machine/asm.h>
> -
> -ENTRY(__floorl)
> - fldt 8(%rsp)
> -
> - fnstenv -28(%rsp) /* store fpu environment */
> -
> - /* We use here %edx although only the low 1 bits are defined.
> - But none of the operations should care and they are faster
> - than the 16 bit operations. */
> - movl $0x400,%edx /* round towards -oo */
> - orl -28(%rsp),%edx
> - andl $0xf7ff,%edx
> - movl %edx,-32(%rsp)
> - fldcw -32(%rsp) /* load modified control word */
> -
> - frndint /* round */
> -
> - /* Preserve "invalid" exceptions from sNaN input. */
> - fnstsw
> - andl $0x1, %eax
> - orl %eax, -24(%rsp)
> -
> - fldenv -28(%rsp) /* restore original environment */
> -
> - ret
> -END (__floorl)
> -libm_alias_ldouble (__floor, floor)
> --
> 2.34.1
>
--
H.J.
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 09/12] x86: Do not raise inexact exception on truncl
2023-12-28 17:20 [PATCH 00/12] Improve rounding to interger function for C23 Adhemerval Zanella
` (7 preceding siblings ...)
2023-12-28 17:20 ` [PATCH 08/12] x86: Do not raise inexact exception on floorl Adhemerval Zanella
@ 2023-12-28 17:20 ` Adhemerval Zanella
2024-04-01 14:14 ` H.J. Lu
2023-12-28 17:20 ` [PATCH 10/12] x86: Do not raise inexact exception on floor/floorf Adhemerval Zanella
` (3 subsequent siblings)
12 siblings, 1 reply; 27+ messages in thread
From: Adhemerval Zanella @ 2023-12-28 17:20 UTC (permalink / raw)
To: libc-alpha
It is not allowed anymore on ISO C23.
Checked on x86_64-linux-gnu and i686-linux-gnu.
---
.../fpu/s_truncl.S => x86/fpu/s_truncl.c} | 40 +++++++++----------
sysdeps/x86_64/fpu/s_truncl.S | 36 -----------------
2 files changed, 19 insertions(+), 57 deletions(-)
rename sysdeps/{i386/fpu/s_truncl.S => x86/fpu/s_truncl.c} (61%)
delete mode 100644 sysdeps/x86_64/fpu/s_truncl.S
diff --git a/sysdeps/i386/fpu/s_truncl.S b/sysdeps/x86/fpu/s_truncl.c
similarity index 61%
rename from sysdeps/i386/fpu/s_truncl.S
rename to sysdeps/x86/fpu/s_truncl.c
index cfd4e75252..249b307004 100644
--- a/sysdeps/i386/fpu/s_truncl.S
+++ b/sysdeps/x86/fpu/s_truncl.c
@@ -1,5 +1,5 @@
-/* Truncate long double value.
- Copyright (C) 1997-2023 Free Software Foundation, Inc.
+/* Round to integer, toward zero. x86 version.
+ Copyright (C) 2023 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -16,25 +16,23 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
+#define NO_MATH_REDIRECT
+#include <math.h>
+#include <fenv_private.h>
#include <libm-alias-ldouble.h>
-#include <machine/asm.h>
-ENTRY(__truncl)
- fldt 4(%esp)
- subl $32, %esp
- cfi_adjust_cfa_offset (32)
- fnstenv 4(%esp)
- movl $0xc00, %edx
- orl 4(%esp), %edx
- movl %edx, (%esp)
- fldcw (%esp)
- frndint
- fnstsw
- andl $0x1, %eax
- orl %eax, 8(%esp)
- fldenv 4(%esp)
- addl $32, %esp
- cfi_adjust_cfa_offset (-32)
- ret
-END(__truncl)
+long double
+__truncl (long double x)
+{
+ fenv_t fenv;
+ long double r;
+
+ libc_feholdexcept_setround_387 (&fenv, FE_TOWARDZERO);
+ asm volatile ("frndint" : "=t" (r) : "0" (x));
+ /* Preserve "invalid" exceptions from sNaN input. */
+ fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID);
+ libc_fesetenv_387 (&fenv);
+
+ return r;
+}
libm_alias_ldouble (__trunc, trunc)
diff --git a/sysdeps/x86_64/fpu/s_truncl.S b/sysdeps/x86_64/fpu/s_truncl.S
deleted file mode 100644
index 8d319e68b0..0000000000
--- a/sysdeps/x86_64/fpu/s_truncl.S
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Truncate long double value.
- Copyright (C) 1997-2023 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <https://www.gnu.org/licenses/>. */
-
-#include <libm-alias-ldouble.h>
-#include <machine/asm.h>
-
-ENTRY(__truncl)
- fldt 8(%rsp)
- fnstenv -28(%rsp)
- movl $0xc00, %edx
- orl -28(%rsp), %edx
- movl %edx, -32(%rsp)
- fldcw -32(%rsp)
- frndint
- fnstsw
- andl $0x1, %eax
- orl %eax, -24(%rsp)
- fldenv -28(%rsp)
- ret
-END(__truncl)
-libm_alias_ldouble (__trunc, trunc)
--
2.34.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 09/12] x86: Do not raise inexact exception on truncl
2023-12-28 17:20 ` [PATCH 09/12] x86: Do not raise inexact exception on truncl Adhemerval Zanella
@ 2024-04-01 14:14 ` H.J. Lu
0 siblings, 0 replies; 27+ messages in thread
From: H.J. Lu @ 2024-04-01 14:14 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: libc-alpha
On Thu, Dec 28, 2023 at 9:23 AM Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
>
> It is not allowed anymore on ISO C23.
>
> Checked on x86_64-linux-gnu and i686-linux-gnu.
> ---
> .../fpu/s_truncl.S => x86/fpu/s_truncl.c} | 40 +++++++++----------
> sysdeps/x86_64/fpu/s_truncl.S | 36 -----------------
> 2 files changed, 19 insertions(+), 57 deletions(-)
> rename sysdeps/{i386/fpu/s_truncl.S => x86/fpu/s_truncl.c} (61%)
> delete mode 100644 sysdeps/x86_64/fpu/s_truncl.S
>
> diff --git a/sysdeps/i386/fpu/s_truncl.S b/sysdeps/x86/fpu/s_truncl.c
> similarity index 61%
> rename from sysdeps/i386/fpu/s_truncl.S
> rename to sysdeps/x86/fpu/s_truncl.c
> index cfd4e75252..249b307004 100644
> --- a/sysdeps/i386/fpu/s_truncl.S
> +++ b/sysdeps/x86/fpu/s_truncl.c
> @@ -1,5 +1,5 @@
> -/* Truncate long double value.
> - Copyright (C) 1997-2023 Free Software Foundation, Inc.
> +/* Round to integer, toward zero. x86 version.
> + Copyright (C) 2023 Free Software Foundation, Inc.
2024.
> This file is part of the GNU C Library.
>
> The GNU C Library is free software; you can redistribute it and/or
> @@ -16,25 +16,23 @@
> License along with the GNU C Library; if not, see
> <https://www.gnu.org/licenses/>. */
>
> +#define NO_MATH_REDIRECT
> +#include <math.h>
> +#include <fenv_private.h>
> #include <libm-alias-ldouble.h>
> -#include <machine/asm.h>
>
> -ENTRY(__truncl)
> - fldt 4(%esp)
> - subl $32, %esp
> - cfi_adjust_cfa_offset (32)
> - fnstenv 4(%esp)
> - movl $0xc00, %edx
> - orl 4(%esp), %edx
> - movl %edx, (%esp)
> - fldcw (%esp)
> - frndint
> - fnstsw
> - andl $0x1, %eax
> - orl %eax, 8(%esp)
> - fldenv 4(%esp)
> - addl $32, %esp
> - cfi_adjust_cfa_offset (-32)
> - ret
> -END(__truncl)
> +long double
> +__truncl (long double x)
> +{
> + fenv_t fenv;
> + long double r;
> +
> + libc_feholdexcept_setround_387 (&fenv, FE_TOWARDZERO);
> + asm volatile ("frndint" : "=t" (r) : "0" (x));
> + /* Preserve "invalid" exceptions from sNaN input. */
> + fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID);
> + libc_fesetenv_387 (&fenv);
> +
> + return r;
> +}
> libm_alias_ldouble (__trunc, trunc)
> diff --git a/sysdeps/x86_64/fpu/s_truncl.S b/sysdeps/x86_64/fpu/s_truncl.S
> deleted file mode 100644
> index 8d319e68b0..0000000000
> --- a/sysdeps/x86_64/fpu/s_truncl.S
> +++ /dev/null
> @@ -1,36 +0,0 @@
> -/* Truncate long double value.
> - Copyright (C) 1997-2023 Free Software Foundation, Inc.
> - This file is part of the GNU C Library.
> -
> - The GNU C Library is free software; you can redistribute it and/or
> - modify it under the terms of the GNU Lesser General Public
> - License as published by the Free Software Foundation; either
> - version 2.1 of the License, or (at your option) any later version.
> -
> - The GNU C Library is distributed in the hope that it will be useful,
> - but WITHOUT ANY WARRANTY; without even the implied warranty of
> - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> - Lesser General Public License for more details.
> -
> - You should have received a copy of the GNU Lesser General Public
> - License along with the GNU C Library; if not, see
> - <https://www.gnu.org/licenses/>. */
> -
> -#include <libm-alias-ldouble.h>
> -#include <machine/asm.h>
> -
> -ENTRY(__truncl)
> - fldt 8(%rsp)
> - fnstenv -28(%rsp)
> - movl $0xc00, %edx
> - orl -28(%rsp), %edx
> - movl %edx, -32(%rsp)
> - fldcw -32(%rsp)
> - frndint
> - fnstsw
> - andl $0x1, %eax
> - orl %eax, -24(%rsp)
> - fldenv -28(%rsp)
> - ret
> -END(__truncl)
> -libm_alias_ldouble (__trunc, trunc)
> --
> 2.34.1
>
--
H.J.
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 10/12] x86: Do not raise inexact exception on floor/floorf
2023-12-28 17:20 [PATCH 00/12] Improve rounding to interger function for C23 Adhemerval Zanella
` (8 preceding siblings ...)
2023-12-28 17:20 ` [PATCH 09/12] x86: Do not raise inexact exception on truncl Adhemerval Zanella
@ 2023-12-28 17:20 ` Adhemerval Zanella
2024-04-01 14:15 ` H.J. Lu
2023-12-28 17:20 ` [PATCH 11/12] i386: Do not raise inexact exception on ceil/ceilf Adhemerval Zanella
` (2 subsequent siblings)
12 siblings, 1 reply; 27+ messages in thread
From: Adhemerval Zanella @ 2023-12-28 17:20 UTC (permalink / raw)
To: libc-alpha
It is not allowed anymore on ISO C23.
Checked on x86_64-linux-gnu and i686-linux-gnu.
---
sysdeps/i386/fpu/s_floor.S | 34 ---------------------------------
sysdeps/i386/fpu/s_floor.c | 38 +++++++++++++++++++++++++++++++++++++
sysdeps/i386/fpu/s_floorf.S | 34 ---------------------------------
sysdeps/i386/fpu/s_floorf.c | 38 +++++++++++++++++++++++++++++++++++++
4 files changed, 76 insertions(+), 68 deletions(-)
delete mode 100644 sysdeps/i386/fpu/s_floor.S
create mode 100644 sysdeps/i386/fpu/s_floor.c
delete mode 100644 sysdeps/i386/fpu/s_floorf.S
create mode 100644 sysdeps/i386/fpu/s_floorf.c
diff --git a/sysdeps/i386/fpu/s_floor.S b/sysdeps/i386/fpu/s_floor.S
deleted file mode 100644
index 7143fdcc9a..0000000000
--- a/sysdeps/i386/fpu/s_floor.S
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Public domain.
- */
-
-#include <machine/asm.h>
-#include <libm-alias-double.h>
-
-RCSID("$NetBSD: s_floor.S,v 1.4 1995/05/09 00:01:59 jtc Exp $")
-
-ENTRY(__floor)
- fldl 4(%esp)
- subl $32,%esp
- cfi_adjust_cfa_offset (32)
-
- fnstenv 4(%esp) /* store fpu environment */
-
- /* We use here %edx although only the low 1 bits are defined.
- But none of the operations should care and they are faster
- than the 16 bit operations. */
- movl $0x400,%edx /* round towards -oo */
- orl 4(%esp),%edx
- andl $0xf7ff,%edx
- movl %edx,(%esp)
- fldcw (%esp) /* load modified control word */
-
- frndint /* round */
-
- fldenv 4(%esp) /* restore original environment */
-
- addl $32,%esp
- cfi_adjust_cfa_offset (-32)
- ret
-END (__floor)
-libm_alias_double (__floor, floor)
diff --git a/sysdeps/i386/fpu/s_floor.c b/sysdeps/i386/fpu/s_floor.c
new file mode 100644
index 0000000000..90ba61da92
--- /dev/null
+++ b/sysdeps/i386/fpu/s_floor.c
@@ -0,0 +1,38 @@
+/* Return largest integral value not less than argument. i386 version.
+ Copyright (C) 2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#define NO_MATH_REDIRECT
+#include <math.h>
+#include <fenv_private.h>
+#include <libm-alias-double.h>
+
+double
+__floor (double x)
+{
+ fenv_t fenv;
+ double r;
+
+ libc_feholdexcept_setround_387 (&fenv, FE_DOWNWARD);
+ asm volatile ("frndint" : "=t" (r) : "0" (x));
+ /* Preserve "invalid" exceptions from sNaN input. */
+ fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID);
+ libc_fesetenv_387 (&fenv);
+
+ return r;
+}
+libm_alias_double (__floor, floor)
diff --git a/sysdeps/i386/fpu/s_floorf.S b/sysdeps/i386/fpu/s_floorf.S
deleted file mode 100644
index 8fad9c0698..0000000000
--- a/sysdeps/i386/fpu/s_floorf.S
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Public domain.
- */
-
-#include <machine/asm.h>
-#include <libm-alias-float.h>
-
-RCSID("$NetBSD: s_floorf.S,v 1.3 1995/05/09 00:04:32 jtc Exp $")
-
-ENTRY(__floorf)
- flds 4(%esp)
- subl $32,%esp
- cfi_adjust_cfa_offset (32)
-
- fnstenv 4(%esp) /* store fpu environment */
-
- /* We use here %edx although only the low 1 bits are defined.
- But none of the operations should care and they are faster
- than the 16 bit operations. */
- movl $0x400,%edx /* round towards -oo */
- orl 4(%esp),%edx
- andl $0xf7ff,%edx
- movl %edx,(%esp)
- fldcw (%esp) /* load modified control word */
-
- frndint /* round */
-
- fldenv 4(%esp) /* restore original environment */
-
- addl $32,%esp
- cfi_adjust_cfa_offset (-32)
- ret
-END (__floorf)
-libm_alias_float (__floor, floor)
diff --git a/sysdeps/i386/fpu/s_floorf.c b/sysdeps/i386/fpu/s_floorf.c
new file mode 100644
index 0000000000..0e7e8223a8
--- /dev/null
+++ b/sysdeps/i386/fpu/s_floorf.c
@@ -0,0 +1,38 @@
+/* Return largest integral value not less than argument. i386 version.
+ Copyright (C) 2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#define NO_MATH_REDIRECT
+#include <math.h>
+#include <fenv_private.h>
+#include <libm-alias-float.h>
+
+float
+__floorf (float x)
+{
+ fenv_t fenv;
+ float r;
+
+ libc_feholdexcept_setround_387 (&fenv, FE_DOWNWARD);
+ asm volatile ("frndint" : "=t" (r) : "0" (x));
+ /* Preserve "invalid" exceptions from sNaN input. */
+ fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID);
+ libc_fesetenv_387 (&fenv);
+
+ return r;
+}
+libm_alias_float (__floor, floor)
--
2.34.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 10/12] x86: Do not raise inexact exception on floor/floorf
2023-12-28 17:20 ` [PATCH 10/12] x86: Do not raise inexact exception on floor/floorf Adhemerval Zanella
@ 2024-04-01 14:15 ` H.J. Lu
0 siblings, 0 replies; 27+ messages in thread
From: H.J. Lu @ 2024-04-01 14:15 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: libc-alpha
On Thu, Dec 28, 2023 at 9:24 AM Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
>
> It is not allowed anymore on ISO C23.
>
> Checked on x86_64-linux-gnu and i686-linux-gnu.
> ---
> sysdeps/i386/fpu/s_floor.S | 34 ---------------------------------
> sysdeps/i386/fpu/s_floor.c | 38 +++++++++++++++++++++++++++++++++++++
> sysdeps/i386/fpu/s_floorf.S | 34 ---------------------------------
> sysdeps/i386/fpu/s_floorf.c | 38 +++++++++++++++++++++++++++++++++++++
> 4 files changed, 76 insertions(+), 68 deletions(-)
> delete mode 100644 sysdeps/i386/fpu/s_floor.S
> create mode 100644 sysdeps/i386/fpu/s_floor.c
> delete mode 100644 sysdeps/i386/fpu/s_floorf.S
> create mode 100644 sysdeps/i386/fpu/s_floorf.c
>
> diff --git a/sysdeps/i386/fpu/s_floor.S b/sysdeps/i386/fpu/s_floor.S
> deleted file mode 100644
> index 7143fdcc9a..0000000000
> --- a/sysdeps/i386/fpu/s_floor.S
> +++ /dev/null
> @@ -1,34 +0,0 @@
> -/*
> - * Public domain.
> - */
> -
> -#include <machine/asm.h>
> -#include <libm-alias-double.h>
> -
> -RCSID("$NetBSD: s_floor.S,v 1.4 1995/05/09 00:01:59 jtc Exp $")
> -
> -ENTRY(__floor)
> - fldl 4(%esp)
> - subl $32,%esp
> - cfi_adjust_cfa_offset (32)
> -
> - fnstenv 4(%esp) /* store fpu environment */
> -
> - /* We use here %edx although only the low 1 bits are defined.
> - But none of the operations should care and they are faster
> - than the 16 bit operations. */
> - movl $0x400,%edx /* round towards -oo */
> - orl 4(%esp),%edx
> - andl $0xf7ff,%edx
> - movl %edx,(%esp)
> - fldcw (%esp) /* load modified control word */
> -
> - frndint /* round */
> -
> - fldenv 4(%esp) /* restore original environment */
> -
> - addl $32,%esp
> - cfi_adjust_cfa_offset (-32)
> - ret
> -END (__floor)
> -libm_alias_double (__floor, floor)
> diff --git a/sysdeps/i386/fpu/s_floor.c b/sysdeps/i386/fpu/s_floor.c
> new file mode 100644
> index 0000000000..90ba61da92
> --- /dev/null
> +++ b/sysdeps/i386/fpu/s_floor.c
> @@ -0,0 +1,38 @@
> +/* Return largest integral value not less than argument. i386 version.
> + Copyright (C) 2023 Free Software Foundation, Inc.
2024.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +#define NO_MATH_REDIRECT
> +#include <math.h>
> +#include <fenv_private.h>
> +#include <libm-alias-double.h>
> +
> +double
> +__floor (double x)
> +{
> + fenv_t fenv;
> + double r;
> +
> + libc_feholdexcept_setround_387 (&fenv, FE_DOWNWARD);
> + asm volatile ("frndint" : "=t" (r) : "0" (x));
> + /* Preserve "invalid" exceptions from sNaN input. */
> + fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID);
> + libc_fesetenv_387 (&fenv);
> +
> + return r;
> +}
> +libm_alias_double (__floor, floor)
> diff --git a/sysdeps/i386/fpu/s_floorf.S b/sysdeps/i386/fpu/s_floorf.S
> deleted file mode 100644
> index 8fad9c0698..0000000000
> --- a/sysdeps/i386/fpu/s_floorf.S
> +++ /dev/null
> @@ -1,34 +0,0 @@
> -/*
> - * Public domain.
> - */
> -
> -#include <machine/asm.h>
> -#include <libm-alias-float.h>
> -
> -RCSID("$NetBSD: s_floorf.S,v 1.3 1995/05/09 00:04:32 jtc Exp $")
> -
> -ENTRY(__floorf)
> - flds 4(%esp)
> - subl $32,%esp
> - cfi_adjust_cfa_offset (32)
> -
> - fnstenv 4(%esp) /* store fpu environment */
> -
> - /* We use here %edx although only the low 1 bits are defined.
> - But none of the operations should care and they are faster
> - than the 16 bit operations. */
> - movl $0x400,%edx /* round towards -oo */
> - orl 4(%esp),%edx
> - andl $0xf7ff,%edx
> - movl %edx,(%esp)
> - fldcw (%esp) /* load modified control word */
> -
> - frndint /* round */
> -
> - fldenv 4(%esp) /* restore original environment */
> -
> - addl $32,%esp
> - cfi_adjust_cfa_offset (-32)
> - ret
> -END (__floorf)
> -libm_alias_float (__floor, floor)
> diff --git a/sysdeps/i386/fpu/s_floorf.c b/sysdeps/i386/fpu/s_floorf.c
> new file mode 100644
> index 0000000000..0e7e8223a8
> --- /dev/null
> +++ b/sysdeps/i386/fpu/s_floorf.c
> @@ -0,0 +1,38 @@
> +/* Return largest integral value not less than argument. i386 version.
> + Copyright (C) 2023 Free Software Foundation, Inc.
2024.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +#define NO_MATH_REDIRECT
> +#include <math.h>
> +#include <fenv_private.h>
> +#include <libm-alias-float.h>
> +
> +float
> +__floorf (float x)
> +{
> + fenv_t fenv;
> + float r;
> +
> + libc_feholdexcept_setround_387 (&fenv, FE_DOWNWARD);
> + asm volatile ("frndint" : "=t" (r) : "0" (x));
> + /* Preserve "invalid" exceptions from sNaN input. */
> + fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID);
> + libc_fesetenv_387 (&fenv);
> +
> + return r;
> +}
> +libm_alias_float (__floor, floor)
> --
> 2.34.1
>
--
H.J.
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 11/12] i386: Do not raise inexact exception on ceil/ceilf
2023-12-28 17:20 [PATCH 00/12] Improve rounding to interger function for C23 Adhemerval Zanella
` (9 preceding siblings ...)
2023-12-28 17:20 ` [PATCH 10/12] x86: Do not raise inexact exception on floor/floorf Adhemerval Zanella
@ 2023-12-28 17:20 ` Adhemerval Zanella
2024-04-01 14:16 ` H.J. Lu
2023-12-28 17:20 ` [PATCH 12/12] i386: Do not raise inexact exception on trunc/truncf Adhemerval Zanella
2024-02-16 17:47 ` [PATCH 00/12] Improve rounding to interger function for C23 Adhemerval Zanella Netto
12 siblings, 1 reply; 27+ messages in thread
From: Adhemerval Zanella @ 2023-12-28 17:20 UTC (permalink / raw)
To: libc-alpha
It is not allowed anymore on ISO C23.
Checked on x86_64-linux-gnu and i686-linux-gnu.
---
sysdeps/i386/fpu/s_ceil.S | 34 ----------------------------------
sysdeps/i386/fpu/s_ceil.c | 38 ++++++++++++++++++++++++++++++++++++++
sysdeps/i386/fpu/s_ceilf.S | 34 ----------------------------------
sysdeps/i386/fpu/s_ceilf.c | 38 ++++++++++++++++++++++++++++++++++++++
4 files changed, 76 insertions(+), 68 deletions(-)
delete mode 100644 sysdeps/i386/fpu/s_ceil.S
create mode 100644 sysdeps/i386/fpu/s_ceil.c
delete mode 100644 sysdeps/i386/fpu/s_ceilf.S
create mode 100644 sysdeps/i386/fpu/s_ceilf.c
diff --git a/sysdeps/i386/fpu/s_ceil.S b/sysdeps/i386/fpu/s_ceil.S
deleted file mode 100644
index 99984f9b8d..0000000000
--- a/sysdeps/i386/fpu/s_ceil.S
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Public domain.
- */
-
-#include <machine/asm.h>
-#include <libm-alias-double.h>
-
-RCSID("$NetBSD: s_ceil.S,v 1.4 1995/05/08 23:52:13 jtc Exp $")
-
-ENTRY(__ceil)
- fldl 4(%esp)
- subl $32,%esp
- cfi_adjust_cfa_offset (32)
-
- fnstenv 4(%esp) /* store fpu environment */
-
- /* We use here %edx although only the low 1 bits are defined.
- But none of the operations should care and they are faster
- than the 16 bit operations. */
- movl $0x0800,%edx /* round towards +oo */
- orl 4(%esp),%edx
- andl $0xfbff,%edx
- movl %edx,(%esp)
- fldcw (%esp) /* load modified control word */
-
- frndint /* round */
-
- fldenv 4(%esp) /* restore original environment */
-
- addl $32,%esp
- cfi_adjust_cfa_offset (-32)
- ret
-END (__ceil)
-libm_alias_double (__ceil, ceil)
diff --git a/sysdeps/i386/fpu/s_ceil.c b/sysdeps/i386/fpu/s_ceil.c
new file mode 100644
index 0000000000..ec948ef83f
--- /dev/null
+++ b/sysdeps/i386/fpu/s_ceil.c
@@ -0,0 +1,38 @@
+/* Return smallest integral value not less than argument. i386 version.
+ Copyright (C) 2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#define NO_MATH_REDIRECT
+#include <math.h>
+#include <fenv_private.h>
+#include <libm-alias-double.h>
+
+double
+__ceil (double x)
+{
+ fenv_t fenv;
+ double r;
+
+ libc_feholdexcept_setround_387 (&fenv, FE_UPWARD);
+ asm volatile ("frndint" : "=t" (r) : "0" (x));
+ /* Preserve "invalid" exceptions from sNaN input. */
+ fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID);
+ libc_fesetenv_387 (&fenv);
+
+ return r;
+}
+libm_alias_double (__ceil, ceil)
diff --git a/sysdeps/i386/fpu/s_ceilf.S b/sysdeps/i386/fpu/s_ceilf.S
deleted file mode 100644
index 03e8e22609..0000000000
--- a/sysdeps/i386/fpu/s_ceilf.S
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Public domain.
- */
-
-#include <machine/asm.h>
-#include <libm-alias-float.h>
-
-RCSID("$NetBSD: s_ceilf.S,v 1.3 1995/05/08 23:52:44 jtc Exp $")
-
-ENTRY(__ceilf)
- flds 4(%esp)
- subl $32,%esp
- cfi_adjust_cfa_offset (32)
-
- fnstenv 4(%esp) /* store fpu environment */
-
- /* We use here %edx although only the low 1 bits are defined.
- But none of the operations should care and they are faster
- than the 16 bit operations. */
- movl $0x0800,%edx /* round towards +oo */
- orl 4(%esp),%edx
- andl $0xfbff,%edx
- movl %edx,(%esp)
- fldcw (%esp) /* load modified control word */
-
- frndint /* round */
-
- fldenv 4(%esp) /* restore original environment */
-
- addl $32,%esp
- cfi_adjust_cfa_offset (-32)
- ret
-END (__ceilf)
-libm_alias_float (__ceil, ceil)
diff --git a/sysdeps/i386/fpu/s_ceilf.c b/sysdeps/i386/fpu/s_ceilf.c
new file mode 100644
index 0000000000..36159610b2
--- /dev/null
+++ b/sysdeps/i386/fpu/s_ceilf.c
@@ -0,0 +1,38 @@
+/* Return largest integral value not less than argument. i386 version.
+ Copyright (C) 2023 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#define NO_MATH_REDIRECT
+#include <math.h>
+#include <fenv_private.h>
+#include <libm-alias-float.h>
+
+float
+__ceilf (float x)
+{
+ fenv_t fenv;
+ float r;
+
+ libc_feholdexcept_setround_387 (&fenv, FE_UPWARD);
+ asm volatile ("frndint" : "=t" (r) : "0" (x));
+ /* Preserve "invalid" exceptions from sNaN input. */
+ fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID);
+ libc_fesetenv_387 (&fenv);
+
+ return r;
+}
+libm_alias_float (__ceil, ceil)
--
2.34.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 11/12] i386: Do not raise inexact exception on ceil/ceilf
2023-12-28 17:20 ` [PATCH 11/12] i386: Do not raise inexact exception on ceil/ceilf Adhemerval Zanella
@ 2024-04-01 14:16 ` H.J. Lu
0 siblings, 0 replies; 27+ messages in thread
From: H.J. Lu @ 2024-04-01 14:16 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: libc-alpha
On Thu, Dec 28, 2023 at 9:25 AM Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
>
> It is not allowed anymore on ISO C23.
>
> Checked on x86_64-linux-gnu and i686-linux-gnu.
> ---
> sysdeps/i386/fpu/s_ceil.S | 34 ----------------------------------
> sysdeps/i386/fpu/s_ceil.c | 38 ++++++++++++++++++++++++++++++++++++++
> sysdeps/i386/fpu/s_ceilf.S | 34 ----------------------------------
> sysdeps/i386/fpu/s_ceilf.c | 38 ++++++++++++++++++++++++++++++++++++++
> 4 files changed, 76 insertions(+), 68 deletions(-)
> delete mode 100644 sysdeps/i386/fpu/s_ceil.S
> create mode 100644 sysdeps/i386/fpu/s_ceil.c
> delete mode 100644 sysdeps/i386/fpu/s_ceilf.S
> create mode 100644 sysdeps/i386/fpu/s_ceilf.c
>
> diff --git a/sysdeps/i386/fpu/s_ceil.S b/sysdeps/i386/fpu/s_ceil.S
> deleted file mode 100644
> index 99984f9b8d..0000000000
> --- a/sysdeps/i386/fpu/s_ceil.S
> +++ /dev/null
> @@ -1,34 +0,0 @@
> -/*
> - * Public domain.
> - */
> -
> -#include <machine/asm.h>
> -#include <libm-alias-double.h>
> -
> -RCSID("$NetBSD: s_ceil.S,v 1.4 1995/05/08 23:52:13 jtc Exp $")
> -
> -ENTRY(__ceil)
> - fldl 4(%esp)
> - subl $32,%esp
> - cfi_adjust_cfa_offset (32)
> -
> - fnstenv 4(%esp) /* store fpu environment */
> -
> - /* We use here %edx although only the low 1 bits are defined.
> - But none of the operations should care and they are faster
> - than the 16 bit operations. */
> - movl $0x0800,%edx /* round towards +oo */
> - orl 4(%esp),%edx
> - andl $0xfbff,%edx
> - movl %edx,(%esp)
> - fldcw (%esp) /* load modified control word */
> -
> - frndint /* round */
> -
> - fldenv 4(%esp) /* restore original environment */
> -
> - addl $32,%esp
> - cfi_adjust_cfa_offset (-32)
> - ret
> -END (__ceil)
> -libm_alias_double (__ceil, ceil)
> diff --git a/sysdeps/i386/fpu/s_ceil.c b/sysdeps/i386/fpu/s_ceil.c
> new file mode 100644
> index 0000000000..ec948ef83f
> --- /dev/null
> +++ b/sysdeps/i386/fpu/s_ceil.c
> @@ -0,0 +1,38 @@
> +/* Return smallest integral value not less than argument. i386 version.
> + Copyright (C) 2023 Free Software Foundation, Inc.
2024.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +#define NO_MATH_REDIRECT
> +#include <math.h>
> +#include <fenv_private.h>
> +#include <libm-alias-double.h>
> +
> +double
> +__ceil (double x)
> +{
> + fenv_t fenv;
> + double r;
> +
> + libc_feholdexcept_setround_387 (&fenv, FE_UPWARD);
> + asm volatile ("frndint" : "=t" (r) : "0" (x));
> + /* Preserve "invalid" exceptions from sNaN input. */
> + fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID);
> + libc_fesetenv_387 (&fenv);
> +
> + return r;
> +}
> +libm_alias_double (__ceil, ceil)
> diff --git a/sysdeps/i386/fpu/s_ceilf.S b/sysdeps/i386/fpu/s_ceilf.S
> deleted file mode 100644
> index 03e8e22609..0000000000
> --- a/sysdeps/i386/fpu/s_ceilf.S
> +++ /dev/null
> @@ -1,34 +0,0 @@
> -/*
> - * Public domain.
> - */
> -
> -#include <machine/asm.h>
> -#include <libm-alias-float.h>
> -
> -RCSID("$NetBSD: s_ceilf.S,v 1.3 1995/05/08 23:52:44 jtc Exp $")
> -
> -ENTRY(__ceilf)
> - flds 4(%esp)
> - subl $32,%esp
> - cfi_adjust_cfa_offset (32)
> -
> - fnstenv 4(%esp) /* store fpu environment */
> -
> - /* We use here %edx although only the low 1 bits are defined.
> - But none of the operations should care and they are faster
> - than the 16 bit operations. */
> - movl $0x0800,%edx /* round towards +oo */
> - orl 4(%esp),%edx
> - andl $0xfbff,%edx
> - movl %edx,(%esp)
> - fldcw (%esp) /* load modified control word */
> -
> - frndint /* round */
> -
> - fldenv 4(%esp) /* restore original environment */
> -
> - addl $32,%esp
> - cfi_adjust_cfa_offset (-32)
> - ret
> -END (__ceilf)
> -libm_alias_float (__ceil, ceil)
> diff --git a/sysdeps/i386/fpu/s_ceilf.c b/sysdeps/i386/fpu/s_ceilf.c
> new file mode 100644
> index 0000000000..36159610b2
> --- /dev/null
> +++ b/sysdeps/i386/fpu/s_ceilf.c
> @@ -0,0 +1,38 @@
> +/* Return largest integral value not less than argument. i386 version.
> + Copyright (C) 2023 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +#define NO_MATH_REDIRECT
> +#include <math.h>
> +#include <fenv_private.h>
> +#include <libm-alias-float.h>
> +
> +float
> +__ceilf (float x)
> +{
> + fenv_t fenv;
> + float r;
> +
> + libc_feholdexcept_setround_387 (&fenv, FE_UPWARD);
> + asm volatile ("frndint" : "=t" (r) : "0" (x));
> + /* Preserve "invalid" exceptions from sNaN input. */
> + fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID);
> + libc_fesetenv_387 (&fenv);
> +
> + return r;
> +}
> +libm_alias_float (__ceil, ceil)
> --
> 2.34.1
>
--
H.J.
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 12/12] i386: Do not raise inexact exception on trunc/truncf
2023-12-28 17:20 [PATCH 00/12] Improve rounding to interger function for C23 Adhemerval Zanella
` (10 preceding siblings ...)
2023-12-28 17:20 ` [PATCH 11/12] i386: Do not raise inexact exception on ceil/ceilf Adhemerval Zanella
@ 2023-12-28 17:20 ` Adhemerval Zanella
2024-04-01 14:17 ` H.J. Lu
2024-02-16 17:47 ` [PATCH 00/12] Improve rounding to interger function for C23 Adhemerval Zanella Netto
12 siblings, 1 reply; 27+ messages in thread
From: Adhemerval Zanella @ 2023-12-28 17:20 UTC (permalink / raw)
To: libc-alpha
It is not allowed anymore on ISO C23.
Checked on x86_64-linux-gnu and i686-linux-gnu.
---
sysdeps/i386/fpu/{s_trunc.S => s_trunc.c} | 37 +++++++++++----------
sysdeps/i386/fpu/{s_truncf.S => s_truncf.c} | 37 +++++++++++----------
2 files changed, 38 insertions(+), 36 deletions(-)
rename sysdeps/i386/fpu/{s_trunc.S => s_trunc.c} (61%)
rename sysdeps/i386/fpu/{s_truncf.S => s_truncf.c} (61%)
diff --git a/sysdeps/i386/fpu/s_trunc.S b/sysdeps/i386/fpu/s_trunc.c
similarity index 61%
rename from sysdeps/i386/fpu/s_trunc.S
rename to sysdeps/i386/fpu/s_trunc.c
index 145288bc8e..b071ad9750 100644
--- a/sysdeps/i386/fpu/s_trunc.S
+++ b/sysdeps/i386/fpu/s_trunc.c
@@ -1,5 +1,5 @@
-/* Truncate double value.
- Copyright (C) 1997-2023 Free Software Foundation, Inc.
+/* Round to integer, toward zero. i386 version.
+ Copyright (C) 2023 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -16,22 +16,23 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-#include <machine/asm.h>
+#define NO_MATH_REDIRECT
+#include <math.h>
+#include <fenv_private.h>
#include <libm-alias-double.h>
-ENTRY(__trunc)
- fldl 4(%esp)
- subl $32, %esp
- cfi_adjust_cfa_offset (32)
- fnstenv 4(%esp)
- movl $0xc00, %edx
- orl 4(%esp), %edx
- movl %edx, (%esp)
- fldcw (%esp)
- frndint
- fldenv 4(%esp)
- addl $32, %esp
- cfi_adjust_cfa_offset (-32)
- ret
-END(__trunc)
+double
+__trunc (double x)
+{
+ fenv_t fenv;
+ double r;
+
+ libc_feholdexcept_setround_387 (&fenv, FE_TOWARDZERO);
+ asm volatile ("frndint" : "=t" (r) : "0" (x));
+ /* Preserve "invalid" exceptions from sNaN input. */
+ fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID);
+ libc_fesetenv_387 (&fenv);
+
+ return r;
+}
libm_alias_double (__trunc, trunc)
diff --git a/sysdeps/i386/fpu/s_truncf.S b/sysdeps/i386/fpu/s_truncf.c
similarity index 61%
rename from sysdeps/i386/fpu/s_truncf.S
rename to sysdeps/i386/fpu/s_truncf.c
index 7bdf0e5111..86d46ff660 100644
--- a/sysdeps/i386/fpu/s_truncf.S
+++ b/sysdeps/i386/fpu/s_truncf.c
@@ -1,5 +1,5 @@
-/* Truncate float value.
- Copyright (C) 1997-2023 Free Software Foundation, Inc.
+/* Round to integer, toward zero. i386 version.
+ Copyright (C) 2023 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -16,22 +16,23 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-#include <machine/asm.h>
+#define NO_MATH_REDIRECT
+#include <math.h>
+#include <fenv_private.h>
#include <libm-alias-float.h>
-ENTRY(__truncf)
- flds 4(%esp)
- subl $32, %esp
- cfi_adjust_cfa_offset (32)
- fnstenv 4(%esp)
- movl $0xc00, %edx
- orl 4(%esp), %edx
- movl %edx, (%esp)
- fldcw (%esp)
- frndint
- fldenv 4(%esp)
- addl $32, %esp
- cfi_adjust_cfa_offset (-32)
- ret
-END(__truncf)
+float
+__truncf (float x)
+{
+ fenv_t fenv;
+ float r;
+
+ libc_feholdexcept_setround_387 (&fenv, FE_TOWARDZERO);
+ asm volatile ("frndint" : "=t" (r) : "0" (x));
+ /* Preserve "invalid" exceptions from sNaN input. */
+ fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID);
+ libc_fesetenv_387 (&fenv);
+
+ return r;
+}
libm_alias_float (__trunc, trunc)
--
2.34.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 12/12] i386: Do not raise inexact exception on trunc/truncf
2023-12-28 17:20 ` [PATCH 12/12] i386: Do not raise inexact exception on trunc/truncf Adhemerval Zanella
@ 2024-04-01 14:17 ` H.J. Lu
0 siblings, 0 replies; 27+ messages in thread
From: H.J. Lu @ 2024-04-01 14:17 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: libc-alpha
On Thu, Dec 28, 2023 at 9:23 AM Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
>
> It is not allowed anymore on ISO C23.
>
> Checked on x86_64-linux-gnu and i686-linux-gnu.
> ---
> sysdeps/i386/fpu/{s_trunc.S => s_trunc.c} | 37 +++++++++++----------
> sysdeps/i386/fpu/{s_truncf.S => s_truncf.c} | 37 +++++++++++----------
> 2 files changed, 38 insertions(+), 36 deletions(-)
> rename sysdeps/i386/fpu/{s_trunc.S => s_trunc.c} (61%)
> rename sysdeps/i386/fpu/{s_truncf.S => s_truncf.c} (61%)
>
> diff --git a/sysdeps/i386/fpu/s_trunc.S b/sysdeps/i386/fpu/s_trunc.c
> similarity index 61%
> rename from sysdeps/i386/fpu/s_trunc.S
> rename to sysdeps/i386/fpu/s_trunc.c
> index 145288bc8e..b071ad9750 100644
> --- a/sysdeps/i386/fpu/s_trunc.S
> +++ b/sysdeps/i386/fpu/s_trunc.c
> @@ -1,5 +1,5 @@
> -/* Truncate double value.
> - Copyright (C) 1997-2023 Free Software Foundation, Inc.
> +/* Round to integer, toward zero. i386 version.
> + Copyright (C) 2023 Free Software Foundation, Inc.
2024.
> This file is part of the GNU C Library.
>
> The GNU C Library is free software; you can redistribute it and/or
> @@ -16,22 +16,23 @@
> License along with the GNU C Library; if not, see
> <https://www.gnu.org/licenses/>. */
>
> -#include <machine/asm.h>
> +#define NO_MATH_REDIRECT
> +#include <math.h>
> +#include <fenv_private.h>
> #include <libm-alias-double.h>
>
> -ENTRY(__trunc)
> - fldl 4(%esp)
> - subl $32, %esp
> - cfi_adjust_cfa_offset (32)
> - fnstenv 4(%esp)
> - movl $0xc00, %edx
> - orl 4(%esp), %edx
> - movl %edx, (%esp)
> - fldcw (%esp)
> - frndint
> - fldenv 4(%esp)
> - addl $32, %esp
> - cfi_adjust_cfa_offset (-32)
> - ret
> -END(__trunc)
> +double
> +__trunc (double x)
> +{
> + fenv_t fenv;
> + double r;
> +
> + libc_feholdexcept_setround_387 (&fenv, FE_TOWARDZERO);
> + asm volatile ("frndint" : "=t" (r) : "0" (x));
> + /* Preserve "invalid" exceptions from sNaN input. */
> + fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID);
> + libc_fesetenv_387 (&fenv);
> +
> + return r;
> +}
> libm_alias_double (__trunc, trunc)
> diff --git a/sysdeps/i386/fpu/s_truncf.S b/sysdeps/i386/fpu/s_truncf.c
> similarity index 61%
> rename from sysdeps/i386/fpu/s_truncf.S
> rename to sysdeps/i386/fpu/s_truncf.c
> index 7bdf0e5111..86d46ff660 100644
> --- a/sysdeps/i386/fpu/s_truncf.S
> +++ b/sysdeps/i386/fpu/s_truncf.c
> @@ -1,5 +1,5 @@
> -/* Truncate float value.
> - Copyright (C) 1997-2023 Free Software Foundation, Inc.
> +/* Round to integer, toward zero. i386 version.
> + Copyright (C) 2023 Free Software Foundation, Inc.
2024.
> This file is part of the GNU C Library.
>
> The GNU C Library is free software; you can redistribute it and/or
> @@ -16,22 +16,23 @@
> License along with the GNU C Library; if not, see
> <https://www.gnu.org/licenses/>. */
>
> -#include <machine/asm.h>
> +#define NO_MATH_REDIRECT
> +#include <math.h>
> +#include <fenv_private.h>
> #include <libm-alias-float.h>
>
> -ENTRY(__truncf)
> - flds 4(%esp)
> - subl $32, %esp
> - cfi_adjust_cfa_offset (32)
> - fnstenv 4(%esp)
> - movl $0xc00, %edx
> - orl 4(%esp), %edx
> - movl %edx, (%esp)
> - fldcw (%esp)
> - frndint
> - fldenv 4(%esp)
> - addl $32, %esp
> - cfi_adjust_cfa_offset (-32)
> - ret
> -END(__truncf)
> +float
> +__truncf (float x)
> +{
> + fenv_t fenv;
> + float r;
> +
> + libc_feholdexcept_setround_387 (&fenv, FE_TOWARDZERO);
> + asm volatile ("frndint" : "=t" (r) : "0" (x));
> + /* Preserve "invalid" exceptions from sNaN input. */
> + fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID);
> + libc_fesetenv_387 (&fenv);
> +
> + return r;
> +}
> libm_alias_float (__trunc, trunc)
> --
> 2.34.1
>
--
H.J.
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 00/12] Improve rounding to interger function for C23
2023-12-28 17:20 [PATCH 00/12] Improve rounding to interger function for C23 Adhemerval Zanella
` (11 preceding siblings ...)
2023-12-28 17:20 ` [PATCH 12/12] i386: Do not raise inexact exception on trunc/truncf Adhemerval Zanella
@ 2024-02-16 17:47 ` Adhemerval Zanella Netto
12 siblings, 0 replies; 27+ messages in thread
From: Adhemerval Zanella Netto @ 2024-02-16 17:47 UTC (permalink / raw)
To: libc-alpha
Ping.
On 28/12/23 14:20, Adhemerval Zanella wrote:
> As indicated by GCC documentation [1], ISO C23 does not allow that C
> bindings ceil, floor, round, and trunc (in all floating point formats)
> to raise
> inexact exceptions (different than ISO C99/C11 where this is allowed).
>
> A recent MIPS patch to used some arch-specific instructions raised this
> issue [1] and it was not caught because there was no proper testing. By
> adding the missing tests, some implementations do indeed raise inexact
> exceptions.
>
> The generic implementation all uses integer operation, so they are not
> subject to this issue. The powerpc (for power4 and lower) and the riscv
> avoid the inexact exception by disabling/enabling exceptions. The x86
> uses some arch-specific implementation for long double and on i386 (due
> to the use of x87 instruction).
>
> Instead of adding newer symbols depending on the required standard
> version, the patchset adapts the faulty ones to avoid raising the
> inexact exception. The x86 version already saves/restore the floating
> point status, so I think it is unlikely the patch would yield much
> performance difference (I did not do any performance analysis on whether
> a generic implementation would yield better performance).
>
> I checked on powerpc, powerpc64, aarch64, armhf, x86, and did some
> regression checks on riscv.
>
> [1] https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-fno-fp-int-builtin-inexact
> [2] https://sourceware.org/pipermail/libc-alpha/2023-December/153528.html
>
> Adhemerval Zanella (12):
> math: Reformat Makefile.
> powerpc: Add missing arch flags on rounding ifunc variants
> math: Add test to check if ceil raise inexact floating-point exception
> math: Add test to check if floor raise inexact floating-point
> exception
> math: Add test to check if trunc raise inexact floating-point
> exception
> math: Add test to check if round raise inexact floating-point
> exception
> x86: Do not raise inexact exception on ceill
> x86: Do not raise inexact exception on floorl
> x86: Do not raise inexact exception on truncl
> x86: Do not raise inexact exception on floor/floorf
> i386: Do not raise inexact exception on ceil/ceilf
> i386: Do not raise inexact exception on trunc/truncf
>
> math/Makefile | 861 ++++++++++++++----
> math/test-ceil-except-2.c | 67 ++
> math/test-ceil-except.c | 85 ++
> math/test-floor-except-2.c | 67 ++
> math/test-floor-except.c | 85 ++
> math/test-round-except-2.c | 67 ++
> math/test-round-except.c | 85 ++
> math/test-trunc-except-2.c | 67 ++
> math/test-trunc-except.c | 85 ++
> sysdeps/i386/fpu/s_ceil.S | 34 -
> sysdeps/i386/fpu/s_ceil.c | 38 +
> sysdeps/i386/fpu/s_ceilf.S | 34 -
> sysdeps/i386/fpu/s_ceilf.c | 38 +
> sysdeps/i386/fpu/s_ceill.S | 39 -
> sysdeps/i386/fpu/s_floor.S | 34 -
> sysdeps/i386/fpu/s_floor.c | 38 +
> sysdeps/i386/fpu/s_floorf.S | 34 -
> sysdeps/i386/fpu/s_floorf.c | 38 +
> sysdeps/i386/fpu/s_floorl.S | 39 -
> sysdeps/i386/fpu/{s_trunc.S => s_trunc.c} | 37 +-
> sysdeps/i386/fpu/{s_truncf.S => s_truncf.c} | 37 +-
> .../powerpc32/power4/fpu/multiarch/Makefile | 6 +
> .../fpu/s_truncl.S => x86/fpu/s_ceill.c} | 38 +-
> sysdeps/x86/fpu/s_floorl.c | 38 +
> .../fpu/s_truncl.S => x86/fpu/s_truncl.c} | 40 +-
> sysdeps/x86_64/fpu/s_ceill.S | 34 -
> sysdeps/x86_64/fpu/s_floorl.S | 33 -
> 27 files changed, 1583 insertions(+), 515 deletions(-)
> create mode 100644 math/test-ceil-except-2.c
> create mode 100644 math/test-ceil-except.c
> create mode 100644 math/test-floor-except-2.c
> create mode 100644 math/test-floor-except.c
> create mode 100644 math/test-round-except-2.c
> create mode 100644 math/test-round-except.c
> create mode 100644 math/test-trunc-except-2.c
> create mode 100644 math/test-trunc-except.c
> delete mode 100644 sysdeps/i386/fpu/s_ceil.S
> create mode 100644 sysdeps/i386/fpu/s_ceil.c
> delete mode 100644 sysdeps/i386/fpu/s_ceilf.S
> create mode 100644 sysdeps/i386/fpu/s_ceilf.c
> delete mode 100644 sysdeps/i386/fpu/s_ceill.S
> delete mode 100644 sysdeps/i386/fpu/s_floor.S
> create mode 100644 sysdeps/i386/fpu/s_floor.c
> delete mode 100644 sysdeps/i386/fpu/s_floorf.S
> create mode 100644 sysdeps/i386/fpu/s_floorf.c
> delete mode 100644 sysdeps/i386/fpu/s_floorl.S
> rename sysdeps/i386/fpu/{s_trunc.S => s_trunc.c} (61%)
> rename sysdeps/i386/fpu/{s_truncf.S => s_truncf.c} (61%)
> rename sysdeps/{x86_64/fpu/s_truncl.S => x86/fpu/s_ceill.c} (57%)
> create mode 100644 sysdeps/x86/fpu/s_floorl.c
> rename sysdeps/{i386/fpu/s_truncl.S => x86/fpu/s_truncl.c} (61%)
> delete mode 100644 sysdeps/x86_64/fpu/s_ceill.S
> delete mode 100644 sysdeps/x86_64/fpu/s_floorl.S
>
^ permalink raw reply [flat|nested] 27+ messages in thread