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 Persuade glibc <math.h> to declare modff().
14 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
16 dnl Test whether modff() exists. We cannot assume that modff(), if it
17 dnl exists, is defined in the same library as modf(). This is not the case
18 dnl on FreeBSD, NetBSD, OpenBSD.
19 gl_MATHFUNC([modff], [float], [(float, float *)])
20 if test $gl_cv_func_modff_no_libm = yes \
21 || test $gl_cv_func_modff_in_libm = yes; then
23 m4_ifdef([gl_FUNC_MODFF_IEEE], [
24 if test $gl_modff_required = ieee && test $REPLACE_MODFF = 0; then
25 AC_CACHE_CHECK([whether modff works according to ISO C 99 with IEC 60559],
26 [gl_cv_func_modff_ieee],
29 LIBS="$LIBS $MODFF_LIBM"
32 #ifndef __NO_MATH_INLINES
33 # define __NO_MATH_INLINES 1 /* for glibc */
36 ]gl_FLOAT_MINUS_ZERO_CODE[
37 ]gl_FLOAT_SIGNBIT_CODE[
38 /* Compare two numbers with ==.
39 This is a separate function because IRIX 6.5 "cc -O" miscompiles an
42 numeric_equal (float x, float y)
46 static float dummy (float x, float *iptr) { return 0; }
48 float minus_one = - 1.0f;
49 int main (int argc, char *argv[])
51 float (*my_modff) (float, float *) = argc ? modff : dummy;
55 /* Test modff(NaN,...).
56 This test fails on NetBSD 5.1, OpenBSD 4.9, Solaris 9, Cygwin. */
57 f = my_modff (zero / zero, &i);
58 if (numeric_equal (f, f))
60 /* Test modff(-Inf,...).
61 This test fails on IRIX 6.5, OSF/1 5.1, mingw. */
62 f = my_modff (minus_one / zero, &i);
63 if (!(f == 0.0f) || (signbitf (minus_zerof) && !signbitf (f)))
68 [gl_cv_func_modff_ieee=yes],
69 [gl_cv_func_modff_ieee=no],
70 [gl_cv_func_modff_ieee="guessing no"])
73 case "$gl_cv_func_modff_ieee" in
82 if test $HAVE_MODFF = 0 || test $REPLACE_MODFF = 1; then
83 dnl Find libraries needed to link lib/modff.c.
84 MODFF_LIBM="$MODF_LIBM"
86 AC_SUBST([MODFF_LIBM])