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_MODFL],
9 m4_divert_text([DEFAULTS], [gl_modfl_required=plain])
10 AC_REQUIRE([gl_MATH_H_DEFAULTS])
11 AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
13 dnl Test whether modfl() exists. We cannot assume that modfl(), if it
14 dnl exists, is defined in the same library as modf(). This is not the case
15 dnl on FreeBSD, Solaris.
16 gl_MATHFUNC([modfl], [long double], [(long double, long double *)])
17 if test $gl_cv_func_modfl_no_libm = yes \
18 || test $gl_cv_func_modfl_in_libm = yes; then
20 m4_ifdef([gl_FUNC_MODFL_IEEE], [
21 if test $gl_modfl_required = ieee && test $REPLACE_MODFL = 0; then
22 AC_CACHE_CHECK([whether modfl works according to ISO C 99 with IEC 60559],
23 [gl_cv_func_modfl_ieee],
26 LIBS="$LIBS $MODFL_LIBM"
29 #ifndef __NO_MATH_INLINES
30 # define __NO_MATH_INLINES 1 /* for glibc */
33 ]gl_LONG_DOUBLE_MINUS_ZERO_CODE[
34 ]gl_LONG_DOUBLE_SIGNBIT_CODE[
35 /* Compare two numbers with ==.
36 This is a separate function because IRIX 6.5 "cc -O" miscompiles an
39 numeric_equal (long double x, long double y)
43 static long double dummy (long double x, long double *iptr) { return 0; }
45 long double minus_one = - 1.0L;
46 int main (int argc, char *argv[])
48 long double (*my_modfl) (long double, long double *) = argc ? modfl : dummy;
51 /* Test modfl(-Inf,...).
52 This test fails on IRIX 6.5, OSF/1 5.1, mingw. */
53 f = my_modfl (minus_one / zero, &i);
54 if (!(f == 0.0L) || (signbitl (minus_zerol) && !signbitl (f)))
59 [gl_cv_func_modfl_ieee=yes],
60 [gl_cv_func_modfl_ieee=no],
61 [gl_cv_func_modfl_ieee="guessing no"])
64 case "$gl_cv_func_modfl_ieee" in
73 if test $HAVE_MODFL = 0 || test $REPLACE_MODFL = 1; then
74 dnl Find libraries needed to link lib/modfl.c.
75 if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
76 AC_REQUIRE([gl_FUNC_MODF])
77 MODFL_LIBM="$MODF_LIBM"
79 AC_REQUIRE([gl_FUNC_TRUNCL])
80 MODFL_LIBM="$TRUNCL_LIBM"
83 AC_SUBST([MODFL_LIBM])