deleted file mode 100644
@@ -1,41 +0,0 @@
-/* Get integer exponent of a floating-point value.
- Copyright (C) 1999-2025 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 <limits.h>
-#include <math.h>
-#include <stdbit.h>
-#include "math_config.h"
-
-int
-__ieee754_ilogb (double x)
-{
- uint64_t ux = asuint64 (x);
- int ex = (ux & ~SIGN_MASK) >> MANTISSA_WIDTH;
- if (ex == 0) /* zero or subnormal */
- {
- /* Clear sign and exponent */
- ux <<= 12;
- if (ux == 0)
- return FP_ILOGB0;
- /* subnormal */
- return -1023 - stdc_leading_zeros (ux);
- }
- if (ex == EXPONENT_MASK >> MANTISSA_WIDTH) /* NaN or Inf */
- return ux << 12 ? FP_ILOGBNAN : INT_MAX;
- return ex - 1023;
-}
deleted file mode 100644
@@ -1,41 +0,0 @@
-/* Get integer exponent of a floating-point value.
- Copyright (C) 1999-2025 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 <limits.h>
-#include <math.h>
-#include <stdbit.h>
-#include "sysdeps/ieee754/flt-32/math_config.h"
-
-int
-__ieee754_ilogbf (float x)
-{
- uint32_t ux = asuint (x);
- int ex = (ux & ~SIGN_MASK) >> MANTISSA_WIDTH;
- if (ex == 0) /* zero or subnormal */
- {
- /* Clear sign and exponent. */
- ux <<= 1 + EXPONENT_WIDTH;
- if (ux == 0)
- return FP_ILOGB0;
- /* sbunormal */
- return -127 - stdc_leading_zeros (ux);
- }
- if (ex == EXPONENT_MASK >> MANTISSA_WIDTH) /* NaN or Inf */
- return ux << (1 + EXPONENT_WIDTH) ? FP_ILOGBNAN : INT_MAX;
- return ex - 127;
-}
new file mode 100644
@@ -0,0 +1 @@
+/* Not needed, implemented at w_ilogbf128.c */
new file mode 100644
@@ -0,0 +1 @@
+/* Not needed, implemented at w_llogbf128.c */
@@ -90,7 +90,7 @@ gen-libm-f128-ifunc-routines = \
e_acosf128 e_acoshf128 e_asinf128 e_atan2f128 e_atanhf128 e_coshf128 \
e_expf128 e_fmodf128 e_hypotf128 e_j0f128 e_j1f128 e_jnf128 \
e_lgammaf128_r e_logf128 e_log10f128 e_powf128 e_remainderf128 \
- e_sinhf128 e_sqrtf128 e_gammaf128_r e_ilogbf128 k_tanf128 s_asinhf128 \
+ e_sinhf128 e_sqrtf128 e_gammaf128_r k_tanf128 s_asinhf128 \
s_atanf128 s_cbrtf128 s_ceilf128 s_cosf128 s_erff128 s_exp10m1f128 \
s_exp2m1f128 s_expm1f128 \
s_fabsf128 s_floorf128 s_log1pf128 s_logbf128 \
deleted file mode 100644
@@ -1,2 +0,0 @@
-#include <math-type-macros-double.h>
-#include <w_ilogb_template.c>
deleted file mode 100644
@@ -1,30 +0,0 @@
-#include <math.h>
-#include <errno.h>
-#include <limits.h>
-#include <math_private.h>
-#include <fenv.h>
-
-#if _GL_HAS_BUILTIN_ILOGB
-int
-M_DECL_FUNC (__ilogb) (FLOAT x)
-{
- int r;
- /* Check for exceptional cases. */
- if (! M_SUF(__builtin_test_dc_ilogb) (x, 0x7f))
- r = M_SUF (__builtin_ilogb) (x);
- else
- /* Fallback to the generic ilogb if x is NaN, Inf or subnormal. */
- r = M_SUF (__ieee754_ilogb) (x);
- if (__builtin_expect (r == FP_ILOGB0, 0)
- || __builtin_expect (r == FP_ILOGBNAN, 0)
- || __builtin_expect (r == INT_MAX, 0))
- {
- __set_errno (EDOM);
- __feraiseexcept (FE_INVALID);
- }
- return r;
-}
-declare_mgen_alias (__ilogb, ilogb)
-#else
-#include <math/w_ilogb_template.c>
-#endif
deleted file mode 100644
@@ -1,2 +0,0 @@
-#include <math-type-macros-float.h>
-#include <w_ilogb_template.c>
new file mode 100644
@@ -0,0 +1,57 @@
+/* Get integer exponent of a floating-point value.
+ Copyright (C) 2025 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/>. */
+
+/* Use the double version of EDOM/invalid operation handling. */
+#include "math_config.h"
+
+static RET_TYPE
+llogb_nan_inf_subnormal (uint64_t hx, uint64_t lx)
+{
+ if (hx <= 0x0001000000000000ULL)
+ {
+ /* Zero or subnormal. */
+ if ((hx | lx) == 0)
+ return RET_INVALID (RET_LOGB0);
+ /* Subnormal */
+ if (hx == 0)
+ return -16431L - stdc_leading_zeros (lx);
+ else
+ return -16382L - stdc_leading_zeros (hx << 15);
+ }
+ return RET_INVALID (RET_LOGBNAN);
+}
+
+static inline RET_TYPE
+IMPL_NAME (FLOAT x)
+{
+ uint64_t hx, lx;
+ GET_FLOAT128_WORDS64 (hx, lx, x);
+ hx &= 0x7fffffffffffffffULL;
+
+#if _GL_HAS_BUILTIN_ILOGB
+ /* Check for exceptional cases. */
+ if (__glibc_likely (! M_SUF(__builtin_test_dc_ilogb) (x, 0x7f)))
+ return M_SUF (__builtin_ilogb) (x);
+#else
+ if (__glibc_likely (hx < 0x7fff000000000000ULL
+ && hx > 0x0001000000000000ULL))
+ return (hx >> 48) - 0x3fff;
+#endif
+
+ return llogb_nan_inf_subnormal (hx, lx);
+}
new file mode 100644
@@ -0,0 +1 @@
+#include "w_ilogbf128.c"
new file mode 100644
@@ -0,0 +1,51 @@
+/* Get integer exponent of a floating-point value.
+ Copyright (C) 2025 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 <math-type-macros-float128.h>
+#include <math.h>
+#include <math_private.h>
+#include <stdbit.h>
+
+#ifdef DEF_AS_LLOGBF128
+# define DECL_NAME __llogb
+# define FUNC_NAME llogb
+# define RET_TYPE long int
+# define RET_LOGB0 FP_LLOGB0
+# define RET_LOGBNAN FP_LLOGBNAN
+# define RET_LOGMAX LONG_MAX
+# define RET_INVALID __math_invalid_li
+#else
+# define DECL_NAME __ilogb
+# define FUNC_NAME ilogb
+# define RET_TYPE int
+# define RET_LOGB0 FP_ILOGB0
+# define RET_LOGBNAN FP_ILOGBNAN
+# define RET_LOGMAX INT_MAX
+# define RET_INVALID __math_invalid_i
+#endif
+#define __IMPL_NAME(x,y) x ## _ ## y
+#define _IMPL_NAME(x,y) __IMPL_NAME(x,y)
+#define IMPL_NAME _IMPL_NAME(FUNC_NAME, impl)
+#include <w_ilogbf128-impl.h>
+
+RET_TYPE
+M_DECL_FUNC (DECL_NAME) (FLOAT x)
+{
+ return IMPL_NAME (x);
+}
+declare_mgen_alias (DECL_NAME, FUNC_NAME)
deleted file mode 100644
@@ -1,2 +0,0 @@
-#include <math-type-macros-double.h>
-#include <w_llogb_template.c>
deleted file mode 100644
@@ -1,2 +0,0 @@
-#include <math-type-macros-float.h>
-#include <w_llogb_template.c>
new file mode 100644
@@ -0,0 +1 @@
+#include "w_llogbf128.c"
new file mode 100644
@@ -0,0 +1,2 @@
+#define DEF_AS_LLOGBF128
+#include "w_ilogbf128.c"