build-aux/ylwrap: restore x bit
[gnulib.git] / m4 / frexpf.m4
1 # frexpf.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_FREXPF],
8 [
9   AC_REQUIRE([gl_MATH_H_DEFAULTS])
10   AC_REQUIRE([gl_FUNC_FREXP])
11
12   dnl Test whether frexpf() exists. We cannot assume that frexpf(), if it
13   dnl exists, is defined in the same library as frexp(). This is not the case
14   dnl on NetBSD, OpenBSD.
15   gl_MATHFUNC([frexpf], [float], [(float, int *)])
16   if test $gl_cv_func_frexpf_no_libm = yes \
17      || test $gl_cv_func_frexpf_in_libm = yes; then
18     save_LIBS="$LIBS"
19     LIBS="$LIBS $FREXPF_LIBM"
20     gl_FUNC_FREXPF_WORKS
21     LIBS="$save_LIBS"
22     case "$gl_cv_func_frexpf_works" in
23       *yes) ;;
24       *)    REPLACE_FREXPF=1 ;;
25     esac
26   else
27     HAVE_FREXPF=0
28   fi
29   if test $HAVE_FREXPF = 0 || test $REPLACE_FREXPF = 1; then
30     FREXPF_LIBM="$FREXP_LIBM"
31   fi
32   AC_SUBST([FREXPF_LIBM])
33 ])
34
35 dnl Test whether frexpf() works also on infinite numbers (this fails e.g. on
36 dnl IRIX 6.5 and mingw) and on negative zero (this fails e.g. on mingw).
37 AC_DEFUN([gl_FUNC_FREXPF_WORKS],
38 [
39   AC_REQUIRE([AC_PROG_CC])
40   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
41   AC_CACHE_CHECK([whether frexpf works], [gl_cv_func_frexpf_works],
42     [
43       AC_RUN_IFELSE(
44         [AC_LANG_SOURCE([[
45 #include <float.h>
46 #include <math.h>
47 #include <string.h>
48 /* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0.
49    ICC 10.0 has a bug when optimizing the expression -zero.
50    The expression -FLT_MIN * FLT_MIN does not work when cross-compiling
51    to PowerPC on MacOS X 10.5.  */
52 #if defined __hpux || defined __sgi || defined __ICC
53 static float
54 compute_minus_zero (void)
55 {
56   return -FLT_MIN * FLT_MIN;
57 }
58 # define minus_zero compute_minus_zero ()
59 #else
60 float minus_zero = -0.0f;
61 #endif
62 int main()
63 {
64   int result = 0;
65   volatile float x;
66   float zero = 0.0f;
67   /* Test on infinite numbers.  */
68   x = 1.0f / zero;
69   {
70     int exp;
71     float y = frexpf (x, &exp);
72     if (y != x)
73       result |= 1;
74   }
75   /* Test on negative zero.  */
76   x = minus_zero;
77   {
78     int exp;
79     float y = frexpf (x, &exp);
80     if (memcmp (&y, &x, sizeof x))
81       result |= 2;
82   }
83   return result;
84 }]])],
85         [gl_cv_func_frexpf_works=yes],
86         [gl_cv_func_frexpf_works=no],
87         [case "$host_os" in
88            irix* | mingw*) gl_cv_func_frexpf_works="guessing no";;
89            *)              gl_cv_func_frexpf_works="guessing yes";;
90          esac
91         ])
92     ])
93 ])