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