Make the serial numbers in *.m4 files effective.
[gnulib.git] / m4 / frexpf.m4
blobee55042cc347a6e5f2d67e2e801747824349bc7b
1 # frexpf.m4
2 # serial 10
3 dnl Copyright (C) 2011-2024 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
8 AC_DEFUN([gl_FUNC_FREXPF],
10   AC_REQUIRE([gl_MATH_H_DEFAULTS])
11   AC_REQUIRE([gl_FUNC_FREXP])
13   dnl Persuade glibc <math.h> to declare frexpf().
14   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
16   dnl Test whether frexpf() exists. We cannot assume that frexpf(), if it
17   dnl exists, is defined in the same library as frexp(). This is not the case
18   dnl on NetBSD, OpenBSD.
19   gl_MATHFUNC([frexpf], [float], [(float, int *)])
20   if test $gl_cv_func_frexpf_no_libm = yes \
21      || test $gl_cv_func_frexpf_in_libm = yes; then
22     saved_LIBS="$LIBS"
23     LIBS="$LIBS $FREXPF_LIBM"
24     gl_FUNC_FREXPF_WORKS
25     LIBS="$saved_LIBS"
26     case "$gl_cv_func_frexpf_works" in
27       *yes) ;;
28       *)    REPLACE_FREXPF=1 ;;
29     esac
30   else
31     HAVE_FREXPF=0
32   fi
33   if test $HAVE_FREXPF = 0 || test $REPLACE_FREXPF = 1; then
34     FREXPF_LIBM="$FREXP_LIBM"
35   fi
36   AC_SUBST([FREXPF_LIBM])
39 dnl Test whether frexpf() works also on infinite numbers (this fails e.g. on
40 dnl IRIX 6.5 and mingw) and on negative zero (this fails e.g. on mingw).
41 AC_DEFUN([gl_FUNC_FREXPF_WORKS],
43   AC_REQUIRE([AC_PROG_CC])
44   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
45   AC_CACHE_CHECK([whether frexpf works], [gl_cv_func_frexpf_works],
46     [
47       AC_RUN_IFELSE(
48         [AC_LANG_SOURCE([[
49 #include <float.h>
50 #include <math.h>
51 #include <string.h>
52 /* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0.
53    ICC 10.0 has a bug when optimizing the expression -zero.
54    The expression -FLT_MIN * FLT_MIN does not work when cross-compiling
55    to PowerPC on Mac OS X 10.5.  */
56 #if defined __hpux || defined __sgi || defined __ICC
57 static float
58 compute_minus_zero (void)
60   return -FLT_MIN * FLT_MIN;
62 # define minus_zero compute_minus_zero ()
63 #else
64 float minus_zero = -0.0f;
65 #endif
66 int main()
68   int result = 0;
69   volatile float x;
70   float zero = 0.0f;
71   /* Test on infinite numbers.  */
72   x = 1.0f / zero;
73   {
74     int exp;
75     float y = frexpf (x, &exp);
76     if (y != x)
77       result |= 1;
78   }
79   /* Test on negative zero.  */
80   x = minus_zero;
81   {
82     int exp;
83     float y = frexpf (x, &exp);
84     float x1 = x;
85     if (memcmp (&y, &x1, sizeof x1))
86       result |= 2;
87   }
88   return result;
89 }]])],
90         [gl_cv_func_frexpf_works=yes],
91         [gl_cv_func_frexpf_works=no],
92         [case "$host_os" in
93            irix*) gl_cv_func_frexpf_works="guessing no" ;;
94            # Guess yes with MSVC, no with mingw.
95            windows*-msvc*)
96              gl_cv_func_frexpf_works="guessing yes"
97              ;;
98            mingw* | windows*)
99              AC_EGREP_CPP([Good], [
100 #ifdef _MSC_VER
101  Good
102 #endif
103                ],
104                [gl_cv_func_frexpf_works="guessing yes"],
105                [gl_cv_func_frexpf_works="guessing no"])
106              ;;
107            *) gl_cv_func_frexpf_works="guessing yes" ;;
108          esac
109         ])
110     ])