[PATCH v4 05/21] m68k: Remove SVID error handling on fmod

Adhemerval Zanella adhemerval.zanella@linaro.org
Wed Oct 8 13:55:05 GMT 2025


The m68k provided an optimized version through __m81_u(fmod)
(mathimpl.h), and gcc does not implement it through a builtin
(different than i386).
---
 sysdeps/m68k/m680x0/fpu/Versions              |  2 +-
 sysdeps/m68k/m680x0/fpu/e_fmod.c              | 37 ++++++++++---------
 .../unix/sysv/linux/m68k/m680x0/libm.abilist  |  1 +
 3 files changed, 22 insertions(+), 18 deletions(-)

diff --git a/sysdeps/m68k/m680x0/fpu/Versions b/sysdeps/m68k/m680x0/fpu/Versions
index ee1dc6b6493..eb5eae05f89 100644
--- a/sysdeps/m68k/m680x0/fpu/Versions
+++ b/sysdeps/m68k/m680x0/fpu/Versions
@@ -1,6 +1,6 @@
 libm {
   GLIBC_2.43 {
     # No SVID compatible error handling.
-    fmodf;
+    fmodf; fmod;
   }
 }
diff --git a/sysdeps/m68k/m680x0/fpu/e_fmod.c b/sysdeps/m68k/m680x0/fpu/e_fmod.c
index 422ab725303..8a57349c135 100644
--- a/sysdeps/m68k/m680x0/fpu/e_fmod.c
+++ b/sysdeps/m68k/m680x0/fpu/e_fmod.c
@@ -15,24 +15,27 @@
    License along with the GNU C Library.  If not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <math.h>
-#include <math_private.h>
-#include "mathimpl.h"
+#include <libm-alias-double.h>
 #include <libm-alias-finite.h>
+#include <math.h>
+#include "mathimpl.h"
+#include "math_config.h"
 
-#ifndef FUNC
-# define FUNC __ieee754_fmod
-# define FUNC_FINITE __fmod
-#endif
-#ifndef float_type
-# define float_type double
-#endif
-
-float_type
-FUNC (float_type x, float_type y)
+double
+__fmod (double x, double y)
 {
-  return __m81_u(FUNC)(x, y);
+  uint64_t hx = asuint64 (x);
+  uint64_t hy = asuint64 (y);
+
+  /* fmod(+-Inf,y) or fmod(x,0) */
+  if (__glibc_unlikely ((is_inf (hx) || y == 0.0)
+			&& !is_nan (hy)
+			&& !is_nan (hx)))
+    return __math_invalid (x);
+
+  return __m81_u(fmod)(x, y);
 }
-#ifdef FUNC_FINITE
-libm_alias_finite (FUNC, FUNC_FINITE)
-#endif
+strong_alias (__fmod, __ieee754_fmod)
+libm_alias_finite (__ieee754_fmod, __fmod)
+versioned_symbol (libm, __fmod, fmod, GLIBC_2_43);
+libm_alias_double_other (__fmod, fmod)
diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist
index 9de0abca257..a9d615da745 100644
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist
@@ -986,4 +986,5 @@ GLIBC_2.42 rsqrtf32 F
 GLIBC_2.42 rsqrtf32x F
 GLIBC_2.42 rsqrtf64 F
 GLIBC_2.42 rsqrtl F
+GLIBC_2.43 fmod F
 GLIBC_2.43 fmodf F
-- 
2.43.0



More information about the Libc-alpha mailing list