2 dnl Copyright (C) 2011 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_FREXPF],
9 AC_REQUIRE([gl_MATH_H_DEFAULTS])
10 AC_REQUIRE([gl_FUNC_FREXP])
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
19 LIBS="$LIBS $FREXPF_LIBM"
22 case "$gl_cv_func_frexpf_works" in
24 *) REPLACE_FREXPF=1 ;;
29 if test $HAVE_FREXPF = 0 || test $REPLACE_FREXPF = 1; then
30 FREXPF_LIBM="$FREXP_LIBM"
32 AC_SUBST([FREXPF_LIBM])
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],
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],
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
54 compute_minus_zero (void)
56 return -FLT_MIN * FLT_MIN;
58 # define minus_zero compute_minus_zero ()
60 float minus_zero = -0.0f;
67 /* Test on infinite numbers. */
71 float y = frexpf (x, &exp);
75 /* Test on negative zero. */
79 float y = frexpf (x, &exp);
80 if (memcmp (&y, &x, sizeof x))
85 [gl_cv_func_frexpf_works=yes],
86 [gl_cv_func_frexpf_works=no],
88 irix* | mingw*) gl_cv_func_frexpf_works="guessing no";;
89 *) gl_cv_func_frexpf_works="guessing yes";;