maint: don't specify XZ_OPT=-9ev in dist-related rule
[gnulib.git] / m4 / modff.m4
1 # modff.m4 serial 3
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_MODFF],
8 [
9   m4_divert_text([DEFAULTS], [gl_modff_required=plain])
10   AC_REQUIRE([gl_MATH_H_DEFAULTS])
11   AC_REQUIRE([gl_FUNC_MODF])
12
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
19     :
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],
24           [
25             save_LIBS="$LIBS"
26             LIBS="$LIBS $MODFF_LIBM"
27             AC_RUN_IFELSE(
28               [AC_LANG_SOURCE([[
29 #ifndef __NO_MATH_INLINES
30 # define __NO_MATH_INLINES 1 /* for glibc */
31 #endif
32 #include <math.h>
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
37    'x == x' test.  */
38 static int
39 numeric_equal (float x, float y)
40 {
41   return x == y;
42 }
43 static float dummy (float x, float *iptr) { return 0; }
44 float zero;
45 float minus_one = - 1.0f;
46 int main (int argc, char *argv[])
47 {
48   float (*my_modff) (float, float *) = argc ? modff : dummy;
49   int result = 0;
50   float i;
51   float f;
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))
56     result |= 1;
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)))
61     result |= 2;
62   return result;
63 }
64               ]])],
65               [gl_cv_func_modff_ieee=yes],
66               [gl_cv_func_modff_ieee=no],
67               [gl_cv_func_modff_ieee="guessing no"])
68             LIBS="$save_LIBS"
69           ])
70         case "$gl_cv_func_modff_ieee" in
71           *yes) ;;
72           *) REPLACE_MODFF=1 ;;
73         esac
74       fi
75     ])
76   else
77     HAVE_MODFF=0
78   fi
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"
82   fi
83   AC_SUBST([MODFF_LIBM])
84 ])