j1f;
jnf;
log10f;
+ remainder;
remainderf;
y0f;
y1f;
#include <math_private.h>
#include <math-svid-compat.h>
#include <libm-alias-double.h>
+#include <shlib-compat.h>
-#if LIBM_SVID_COMPAT
+#if LIBM_SVID_COMPAT && (SHLIB_COMPAT (libm, GLIBC_2_0, GLIBC_2_43) \
+ || defined NO_LONG_DOUBLE \
+ || defined LONG_DOUBLE_COMPAT)
/* wrapper remainder */
double
-__remainder (double x, double y)
+__remainder_compat (double x, double y)
{
if (((__builtin_expect (y == 0.0, 0) && ! isnan (x))
|| (__builtin_expect (isinf (x), 0) && ! isnan (y)))
&& _LIB_VERSION != _IEEE_)
return __kernel_standard (x, y, 28); /* remainder domain */
- return __ieee754_remainder (x, y);
+ return __remainder (x, y);
}
-libm_alias_double (__remainder, remainder)
-weak_alias (__remainder, drem)
+compat_symbol (libm, __remainder_compat, remainder, GLIBC_2_0);
+weak_alias (__remainder_compat, drem)
# ifdef NO_LONG_DOUBLE
-weak_alias (__remainder, dreml)
+weak_alias (__remainder_compat, dreml)
+weak_alias (__remainder_compat, remainderl)
+# endif
+# ifdef LONG_DOUBLE_COMPAT
+LONG_DOUBLE_COMPAT_CHOOSE_libm_remainderl (
+ compat_symbol (libm, __remainder_compat, remainderl, \
+ FIRST_VERSION_libm_remainderl), );
# endif
#endif
+++ /dev/null
-/*
- * Public domain.
- */
-
-#include <machine/asm.h>
-#include <libm-alias-finite.h>
-
-ENTRY(__ieee754_remainder)
- fldl 12(%esp)
- fldl 4(%esp)
-1: fprem1
- fstsw %ax
- sahf
- jp 1b
- fstp %st(1)
- ret
-END (__ieee754_remainder)
-libm_alias_finite (__ieee754_remainder, __remainder)
--- /dev/null
+/* Floating-point remainder function.
+ 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.h>
+#include <libm-alias-finite.h>
+#include <libm-alias-double.h>
+#include "math_config.h"
+
+double
+__remainder (double x, double 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 __builtin_remainder (x, y);
+}
+strong_alias (__remainder, __ieee754_remainder)
+versioned_symbol (libm, __remainder, remainder, GLIBC_2_43);
+libm_alias_double_other (__remainder, remainder)
+libm_alias_finite (__ieee754_remainder, __remainder)
#include <math.h>
#include <libm-alias-finite.h>
+#include <libm-alias-double.h>
+#include <math-svid-compat.h>
#include "math_config.h"
double
-__ieee754_remainder (double x, double y)
+__remainder (double x, double y)
{
uint64_t hx = asuint64 (x);
uint64_t hy = asuint64 (y);
y = fabs (y);
if (__glibc_likely (hy < UINT64_C (0x7fe0000000000000)))
{
- /* |x| not finite, |y| equal 0 is handled by fmod. */
- if (__glibc_unlikely (hx >= EXPONENT_MASK))
- return (x * y) / (x * y);
-
- x = fabs (__ieee754_fmod (x, y + y));
- if (x + x > y)
+ x = fabs (__fmod (x, y + y));
+ if (isgreater (x + x, y))
{
x -= y;
if (x + x >= y)
}
else
{
- /* |x| not finite or |y| is NaN or 0 */
- if ((hx >= EXPONENT_MASK || (hy - 1) >= EXPONENT_MASK))
- return (x * y) / (x * y);
+ /* |x| not finite or |y| is NaN */
+ if (__glibc_unlikely (hx >= EXPONENT_MASK || hy > EXPONENT_MASK))
+ return __math_invalid (x * y);
x = fabs (x);
double y_half = y * 0.5;
return sx ? -x : x;
}
-libm_alias_finite (__ieee754_remainder, __remainder)
+libm_alias_finite (__remainder, __remainder)
+#if LIBM_SVID_COMPAT
+versioned_symbol (libm, __remainder, remainder, GLIBC_2_43);
+libm_alias_double_other (__remainder, remainder)
+#else
+libm_alias_double (__remainder, remainder)
+weak_alias (__remainder, drem)
+# ifdef NO_LONG_DOUBLE
+weak_alias (__remainder, dreml)
+# endif
+#endif
--- /dev/null
+/* Not needed */
#include <math_ldbl_opt.h>
#include <math/w_remainder_compat.c>
#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_0)
-strong_alias (__remainder, __drem)
+strong_alias (__remainder_compat, __drem)
compat_symbol (libm, __drem, dreml, GLIBC_2_0);
#endif
<https://www.gnu.org/licenses/>. */
#include <math.h>
+#include <libm-alias-double.h>
#include <libm-alias-finite.h>
#include "mathimpl.h"
+#include "math_config.h"
double
-__ieee754_remainder (double x, double y)
+__remainder (double x, double 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.0f)
+ && !is_nan (hy)
+ && !is_nan (hx)))
+ return __math_invalid (x);
+
return __m81_u(__ieee754_remainder)(x, y);
}
+strong_alias (__remainder, __ieee754_remainder)
+versioned_symbol (libm, __remainder, remainder, GLIBC_2_43);
+libm_alias_double_other (__remainder, remainder)
libm_alias_finite (__ieee754_remainder, __remainder)
GLIBC_2.43 j1f F
GLIBC_2.43 jnf F
GLIBC_2.43 log10f F
+GLIBC_2.43 remainder F
GLIBC_2.43 remainderf F
GLIBC_2.43 y0f F
GLIBC_2.43 y1f F
GLIBC_2.43 j1f F
GLIBC_2.43 jnf F
GLIBC_2.43 log10f F
+GLIBC_2.43 remainder F
GLIBC_2.43 remainderf F
GLIBC_2.43 y0f F
GLIBC_2.43 y1f F
GLIBC_2.43 j1f F
GLIBC_2.43 jnf F
GLIBC_2.43 log10f F
+GLIBC_2.43 remainder F
GLIBC_2.43 remainderf F
GLIBC_2.43 y0f F
GLIBC_2.43 y1f F
GLIBC_2.43 j1f F
GLIBC_2.43 jnf F
GLIBC_2.43 log10f F
+GLIBC_2.43 remainder F
GLIBC_2.43 remainderf F
GLIBC_2.43 y0f F
GLIBC_2.43 y1f F
GLIBC_2.43 j1f F
GLIBC_2.43 jnf F
GLIBC_2.43 log10f F
+GLIBC_2.43 remainder F
GLIBC_2.43 remainderf F
GLIBC_2.43 y0f F
GLIBC_2.43 y1f F
GLIBC_2.43 j1f F
GLIBC_2.43 jnf F
GLIBC_2.43 log10f F
+GLIBC_2.43 remainder F
GLIBC_2.43 remainderf F
GLIBC_2.43 y0f F
GLIBC_2.43 y1f F
GLIBC_2.43 j1f F
GLIBC_2.43 jnf F
GLIBC_2.43 log10f F
+GLIBC_2.43 remainder F
GLIBC_2.43 remainderf F
GLIBC_2.43 y0f F
GLIBC_2.43 y1f F
GLIBC_2.43 j1f F
GLIBC_2.43 jnf F
GLIBC_2.43 log10f F
+GLIBC_2.43 remainder F
GLIBC_2.43 remainderf F
GLIBC_2.43 y0f F
GLIBC_2.43 y1f F
GLIBC_2.43 j0f F
GLIBC_2.43 j1f F
GLIBC_2.43 jnf F
+GLIBC_2.43 remainder F
GLIBC_2.43 remainderf F
GLIBC_2.43 y0f F
GLIBC_2.43 y1f F
GLIBC_2.43 j1f F
GLIBC_2.43 jnf F
GLIBC_2.43 log10f F
+GLIBC_2.43 remainder F
GLIBC_2.43 remainderf F
GLIBC_2.43 y0f F
GLIBC_2.43 y1f F
GLIBC_2.43 j1f F
GLIBC_2.43 jnf F
GLIBC_2.43 log10f F
+GLIBC_2.43 remainder F
GLIBC_2.43 remainderf F
GLIBC_2.43 y0f F
GLIBC_2.43 y1f F
GLIBC_2.43 j1f F
GLIBC_2.43 jnf F
GLIBC_2.43 log10f F
+GLIBC_2.43 remainder F
GLIBC_2.43 remainderf F
GLIBC_2.43 y0f F
GLIBC_2.43 y1f F
GLIBC_2.43 j1f F
GLIBC_2.43 jnf F
GLIBC_2.43 log10f F
+GLIBC_2.43 remainder F
GLIBC_2.43 remainderf F
GLIBC_2.43 y0f F
GLIBC_2.43 y1f F
GLIBC_2.43 j1f F
GLIBC_2.43 jnf F
GLIBC_2.43 log10f F
+GLIBC_2.43 remainder F
GLIBC_2.43 remainderf F
GLIBC_2.43 y0f F
GLIBC_2.43 y1f F
GLIBC_2.43 j1f F
GLIBC_2.43 jnf F
GLIBC_2.43 log10f F
+GLIBC_2.43 remainder F
GLIBC_2.43 remainderf F
GLIBC_2.43 y0f F
GLIBC_2.43 y1f F
GLIBC_2.43 j1f F
GLIBC_2.43 jnf F
GLIBC_2.43 log10f F
+GLIBC_2.43 remainder F
GLIBC_2.43 remainderf F
GLIBC_2.43 y0f F
GLIBC_2.43 y1f F
GLIBC_2.43 j1f F
GLIBC_2.43 jnf F
GLIBC_2.43 log10f F
+GLIBC_2.43 remainder F
GLIBC_2.43 remainderf F
GLIBC_2.43 y0f F
GLIBC_2.43 y1f F
GLIBC_2.43 j1f F
GLIBC_2.43 jnf F
GLIBC_2.43 log10f F
+GLIBC_2.43 remainder F
GLIBC_2.43 remainderf F
GLIBC_2.43 y0f F
GLIBC_2.43 y1f F
GLIBC_2.43 j1f F
GLIBC_2.43 jnf F
GLIBC_2.43 log10f F
+GLIBC_2.43 remainder F
GLIBC_2.43 remainderf F
GLIBC_2.43 y0f F
GLIBC_2.43 y1f F
GLIBC_2.43 j1f F
GLIBC_2.43 jnf F
GLIBC_2.43 log10f F
+GLIBC_2.43 remainder F
GLIBC_2.43 remainderf F
GLIBC_2.43 y0f F
GLIBC_2.43 y1f F
GLIBC_2.43 j1f F
GLIBC_2.43 jnf F
GLIBC_2.43 log10f F
+GLIBC_2.43 remainder F
GLIBC_2.43 remainderf F
GLIBC_2.43 y0f F
GLIBC_2.43 y1f F
GLIBC_2.43 j1f F
GLIBC_2.43 jnf F
GLIBC_2.43 log10f F
+GLIBC_2.43 remainder F
GLIBC_2.43 remainderf F
GLIBC_2.43 y0f F
GLIBC_2.43 y1f F
GLIBC_2.43 j1f F
GLIBC_2.43 jnf F
GLIBC_2.43 log10f F
+GLIBC_2.43 remainder F
GLIBC_2.43 remainderf F
GLIBC_2.43 y0f F
GLIBC_2.43 y1f F
GLIBC_2.43 j1f F
GLIBC_2.43 jnf F
GLIBC_2.43 log10f F
+GLIBC_2.43 remainder F
GLIBC_2.43 remainderf F
GLIBC_2.43 y0f F
GLIBC_2.43 y1f F
GLIBC_2.43 j1f F
GLIBC_2.43 jnf F
GLIBC_2.43 log10f F
+GLIBC_2.43 remainder F
GLIBC_2.43 remainderf F
GLIBC_2.43 y0f F
GLIBC_2.43 y1f F