[COMMITTED] math: Use stdbit.h for remaining builtins in math_config.h

Adhemerval Zanella adhemerval.zanella@linaro.org
Thu Nov 5 18:38:14 GMT 2026


Follow-up to commit 6610a293b3a1, which did not handle the dbl-64
roundeven_finite and the flt-32 make_float.

It also fixes the dbl-64 roundeven_finite for x = +/-0.5, where
y - copysign (1.0, x) is +0.0 and __builtin_ctzll (0) is undefined
(the generic implementation is only used on powerpc).
---
 sysdeps/ieee754/dbl-64/math_config.h | 2 +-
 sysdeps/ieee754/flt-32/math_config.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/sysdeps/ieee754/dbl-64/math_config.h b/sysdeps/ieee754/dbl-64/math_config.h
index 6a1f3062f8..d8eafd169a 100644
--- a/sysdeps/ieee754/dbl-64/math_config.h
+++ b/sysdeps/ieee754/dbl-64/math_config.h
@@ -58,7 +58,7 @@ roundeven_finite (double x)
     {
       union { double f; uint64_t i; } u = {y};
       union { double f; uint64_t i; } v = {y - copysign (1.0, x)};
-      if (__builtin_ctzll (v.i) > __builtin_ctzll (u.i))
+      if (stdc_trailing_zeros (v.i) > stdc_trailing_zeros (u.i))
         y = v.f;
     }
   return y;
diff --git a/sysdeps/ieee754/flt-32/math_config.h b/sysdeps/ieee754/flt-32/math_config.h
index 1509c2ef62..d76bd1bbae 100644
--- a/sysdeps/ieee754/flt-32/math_config.h
+++ b/sysdeps/ieee754/flt-32/math_config.h
@@ -196,7 +196,7 @@ get_exponent (uint32_t x)
 static inline double
 make_float (uint32_t x, int ep, uint32_t s)
 {
-  int lz = __builtin_clz (x) - EXPONENT_WIDTH;
+  int lz = stdc_leading_zeros (x) - EXPONENT_WIDTH;
   x <<= lz;
   ep -= lz;
 
-- 
2.47.3



More information about the Libc-alpha mailing list