* ChangeLog: Fix misspelling
[gnulib.git] / m4 / fmodf.m4
blob65fdb8e6f5042ad7d3e80873c64344d3eaf41cf5
1 # fmodf.m4
2 # serial 14
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().
19   saved_LIBS="$LIBS"
20   LIBS="$LIBS $FMOD_LIBM"
21   AC_CHECK_FUNCS([fmodf])
22   LIBS="$saved_LIBS"
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],
30           [
31             saved_LIBS="$LIBS"
32             LIBS="$LIBS $FMODF_LIBM"
33             AC_RUN_IFELSE(
34               [AC_LANG_SOURCE([[
35 #ifndef __NO_MATH_INLINES
36 # define __NO_MATH_INLINES 1 /* for glibc */
37 #endif
38 #include <math.h>
39 /* Compare two numbers with ==.
40    This is a separate function because IRIX 6.5 "cc -O" miscompiles an
41    'x == x' test.  */
42 static int
43 numeric_equal (float x, float y)
45   return x == 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;
51   float f;
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))
56     return 1;
57   return 0;
59               ]])],
60               [gl_cv_func_fmodf_ieee=yes],
61               [gl_cv_func_fmodf_ieee=no],
62               [case "$host_os" in
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" ;;
71                esac
72               ])
73             LIBS="$saved_LIBS"
74           ])
75         case "$gl_cv_func_fmodf_ieee" in
76           *yes) ;;
77           *) REPLACE_FMODF=1 ;;
78         esac
79       fi
80     ])
81   else
82     HAVE_FMODF=0
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>]])
87   fi
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"
91   fi
92   AC_SUBST([FMODF_LIBM])