3 dnl Copyright (C) 2011-2024 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
8 AC_DEFUN([gl_FUNC_FMODF],
10 m4_divert_text([DEFAULTS], [gl_fmodf_required=plain])
11 AC_REQUIRE([gl_MATH_H_DEFAULTS])
12 AC_REQUIRE([gl_FUNC_FMOD])
14 dnl Persuade glibc <math.h> to declare fmodf().
15 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
17 dnl Test whether fmodf() exists. Assume that fmodf(), if it exists, is
18 dnl defined in the same library as fmod().
20 LIBS="$LIBS $FMOD_LIBM"
21 AC_CHECK_FUNCS([fmodf])
23 if test $ac_cv_func_fmodf = yes; then
24 FMODF_LIBM="$FMOD_LIBM"
25 m4_ifdef([gl_FUNC_FMODF_IEEE], [
26 if test $gl_fmodf_required = ieee && test $REPLACE_FMODF = 0; then
27 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
28 AC_CACHE_CHECK([whether fmodf works according to ISO C 99 with IEC 60559],
29 [gl_cv_func_fmodf_ieee],
32 LIBS="$LIBS $FMODF_LIBM"
35 #ifndef __NO_MATH_INLINES
36 # define __NO_MATH_INLINES 1 /* for glibc */
39 /* Compare two numbers with ==.
40 This is a separate function because IRIX 6.5 "cc -O" miscompiles an
43 numeric_equal (float x, float y)
47 static float dummy (float x, float y) { return 0; }
48 int main (int argc, char *argv[])
50 float (* volatile my_fmodf) (float, float) = argc ? fmodf : dummy;
52 /* Test fmodf(...,0.0f).
53 This test fails on OSF/1 5.1. */
54 f = my_fmodf (2.0f, 0.0f);
55 if (numeric_equal (f, f))
60 [gl_cv_func_fmodf_ieee=yes],
61 [gl_cv_func_fmodf_ieee=no],
63 # Guess yes on glibc systems.
64 *-gnu* | gnu*) gl_cv_func_fmodf_ieee="guessing yes" ;;
65 # Guess yes on musl systems.
66 *-musl* | midipix*) gl_cv_func_fmodf_ieee="guessing yes" ;;
67 # Guess yes on native Windows.
68 mingw* | windows*) gl_cv_func_fmodf_ieee="guessing yes" ;;
69 # If we don't know, obey --enable-cross-guesses.
70 *) gl_cv_func_fmodf_ieee="$gl_cross_guess_normal" ;;
75 case "$gl_cv_func_fmodf_ieee" in
83 dnl If the function is declared but does not appear to exist, it may be
84 dnl defined as an inline function. In order to avoid a conflict, we have
85 dnl to define rpl_fmodf, not fmodf.
86 AC_CHECK_DECLS([fmodf], [REPLACE_FMODF=1], , [[#include <math.h>]])
88 if test $HAVE_FMODF = 0 || test $REPLACE_FMODF = 1; then
89 dnl Find libraries needed to link lib/fmodf.c.
90 FMODF_LIBM="$FMOD_LIBM"
92 AC_SUBST([FMODF_LIBM])