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_MODFF],
9 m4_divert_text([DEFAULTS], [gl_modff_required=plain])
10 AC_REQUIRE([gl_MATH_H_DEFAULTS])
11 AC_REQUIRE([gl_FUNC_MODF])
13 dnl Test whether modff() exists. We cannot assume that modff(), if it
14 dnl exists, is defined in the same library as modf(). This is not the case
15 dnl on FreeBSD, NetBSD, OpenBSD.
16 gl_MATHFUNC([modff], [float], [(float, float *)])
17 if test $gl_cv_func_modff_no_libm = yes \
18 || test $gl_cv_func_modff_in_libm = yes; then
20 m4_ifdef([gl_FUNC_MODFF_IEEE], [
21 if test $gl_modff_required = ieee && test $REPLACE_MODFF = 0; then
22 AC_CACHE_CHECK([whether modff works according to ISO C 99 with IEC 60559],
23 [gl_cv_func_modff_ieee],
26 LIBS="$LIBS $MODFF_LIBM"
29 #ifndef __NO_MATH_INLINES
30 # define __NO_MATH_INLINES 1 /* for glibc */
33 ]gl_FLOAT_MINUS_ZERO_CODE[
34 ]gl_FLOAT_SIGNBIT_CODE[
35 /* Compare two numbers with ==.
36 This is a separate function because IRIX 6.5 "cc -O" miscompiles an
39 numeric_equal (float x, float y)
43 static float dummy (float x, float *iptr) { return 0; }
45 float minus_one = - 1.0f;
46 int main (int argc, char *argv[])
48 float (*my_modff) (float, float *) = argc ? modff : dummy;
52 /* Test modff(NaN,...).
53 This test fails on NetBSD 5.1, OpenBSD 4.9, Solaris 9, Cygwin. */
54 f = my_modff (zero / zero, &i);
55 if (numeric_equal (f, f))
57 /* Test modff(-Inf,...).
58 This test fails on IRIX 6.5, OSF/1 5.1, mingw. */
59 f = my_modff (minus_one / zero, &i);
60 if (!(f == 0.0f) || (signbitf (minus_zerof) && !signbitf (f)))
65 [gl_cv_func_modff_ieee=yes],
66 [gl_cv_func_modff_ieee=no],
67 [gl_cv_func_modff_ieee="guessing no"])
70 case "$gl_cv_func_modff_ieee" in
79 if test $HAVE_MODFF = 0 || test $REPLACE_MODFF = 1; then
80 dnl Find libraries needed to link lib/modff.c.
81 MODFF_LIBM="$MODF_LIBM"
83 AC_SUBST([MODFF_LIBM])