tests: avoid gcc warnings about argv vs. const initializers
[gnulib.git] / m4 / fmodf.m4
1 # fmodf.m4 serial 4
2 dnl Copyright (C) 2011-2012 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
6
7 AC_DEFUN([gl_FUNC_FMODF],
8 [
9   m4_divert_text([DEFAULTS], [gl_fmodf_required=plain])
10   AC_REQUIRE([gl_MATH_H_DEFAULTS])
11   AC_REQUIRE([gl_FUNC_FMOD])
12
13   dnl Persuade glibc <math.h> to declare fmodf().
14   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
15
16   dnl Test whether fmodf() exists. Assume that fmodf(), if it exists, is
17   dnl defined in the same library as fmod().
18   save_LIBS="$LIBS"
19   LIBS="$LIBS $FMOD_LIBM"
20   AC_CHECK_FUNCS([fmodf])
21   LIBS="$save_LIBS"
22   if test $ac_cv_func_fmodf = yes; then
23     FMODF_LIBM="$FMOD_LIBM"
24     m4_ifdef([gl_FUNC_FMODF_IEEE], [
25       if test $gl_fmodf_required = ieee && test $REPLACE_FMODF = 0; then
26         AC_CACHE_CHECK([whether fmodf works according to ISO C 99 with IEC 60559],
27           [gl_cv_func_fmodf_ieee],
28           [
29             save_LIBS="$LIBS"
30             LIBS="$LIBS $FMODF_LIBM"
31             AC_RUN_IFELSE(
32               [AC_LANG_SOURCE([[
33 #ifndef __NO_MATH_INLINES
34 # define __NO_MATH_INLINES 1 /* for glibc */
35 #endif
36 #include <math.h>
37 /* Compare two numbers with ==.
38    This is a separate function because IRIX 6.5 "cc -O" miscompiles an
39    'x == x' test.  */
40 static int
41 numeric_equal (float x, float y)
42 {
43   return x == y;
44 }
45 static float dummy (float x, float y) { return 0; }
46 int main (int argc, char *argv[])
47 {
48   float (*my_fmodf) (float, float) = argc ? fmodf : dummy;
49   float f;
50   /* Test fmodf(...,0.0f).
51      This test fails on OSF/1 5.1.  */
52   f = my_fmodf (2.0f, 0.0f);
53   if (numeric_equal (f, f))
54     return 1;
55   return 0;
56 }
57               ]])],
58               [gl_cv_func_fmodf_ieee=yes],
59               [gl_cv_func_fmodf_ieee=no],
60               [gl_cv_func_fmodf_ieee="guessing no"])
61             LIBS="$save_LIBS"
62           ])
63         case "$gl_cv_func_fmodf_ieee" in
64           *yes) ;;
65           *) REPLACE_FMODF=1 ;;
66         esac
67       fi
68     ])
69   else
70     HAVE_FMODF=0
71   fi
72   if test $HAVE_FMODF = 0 || test $REPLACE_FMODF = 1; then
73     dnl Find libraries needed to link lib/fmodf.c.
74     FMODF_LIBM="$FMOD_LIBM"
75   fi
76   AC_SUBST([FMODF_LIBM])
77 ])