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.
7 AC_DEFUN([gl_FUNC_FMOD],
9 m4_divert_text([DEFAULTS], [gl_fmod_required=plain])
10 AC_REQUIRE([gl_MATH_H_DEFAULTS])
12 dnl Determine FMOD_LIBM.
13 gl_COMMON_DOUBLE_MATHFUNC([fmod])
15 m4_ifdef([gl_FUNC_FMOD_IEEE], [
16 if test $gl_fmod_required = ieee && test $REPLACE_FMOD = 0; then
17 AC_CACHE_CHECK([whether fmod works according to ISO C 99 with IEC 60559],
18 [gl_cv_func_fmod_ieee],
21 LIBS="$LIBS $FMOD_LIBM"
24 #ifndef __NO_MATH_INLINES
25 # define __NO_MATH_INLINES 1 /* for glibc */
28 ]gl_DOUBLE_MINUS_ZERO_CODE[
29 ]gl_DOUBLE_SIGNBIT_CODE[
30 /* Compare two numbers with ==.
31 This is a separate function because IRIX 6.5 "cc -O" miscompiles an
34 numeric_equal (double x, double y)
38 static double dummy (double x, double y) { return 0; }
39 int main (int argc, char *argv[])
41 double (*my_fmod) (double, double) = argc ? fmod : dummy;
45 /* Test fmod(...,0.0).
46 This test fails on OSF/1 5.1. */
47 f = my_fmod (2.0, 0.0);
48 if (numeric_equal (f, f))
50 /* Test fmod(-0.0,...).
51 This test fails on native Windows. */
52 f = my_fmod (minus_zerod, 2.0);
53 if (!(f == 0.0) || (signbitd (minus_zerod) && !signbitd (f)))
58 [gl_cv_func_fmod_ieee=yes],
59 [gl_cv_func_fmod_ieee=no],
60 [gl_cv_func_fmod_ieee="guessing no"])
63 case "$gl_cv_func_fmod_ieee" in
69 if test $REPLACE_FMOD = 1; then
70 dnl Find libraries needed to link lib/fmod.c.
71 AC_REQUIRE([gl_FUNC_TRUNC])
72 AC_REQUIRE([gl_FUNC_FMA])
74 dnl Append $TRUNC_LIBM to FMOD_LIBM, avoiding gratuitous duplicates.
75 case " $FMOD_LIBM " in
77 *) FMOD_LIBM="$FMOD_LIBM $TRUNC_LIBM" ;;
79 dnl Append $FMA_LIBM to FMOD_LIBM, avoiding gratuitous duplicates.
80 case " $FMOD_LIBM " in
82 *) FMOD_LIBM="$FMOD_LIBM $FMA_LIBM" ;;