2 dnl Copyright (C) 2011-2020 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 Persuade glibc <math.h> to declare frexpf().
13 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
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
22 LIBS="$LIBS $FREXPF_LIBM"
25 case "$gl_cv_func_frexpf_works" in
27 *) REPLACE_FREXPF=1 ;;
32 if test $HAVE_FREXPF = 0 || test $REPLACE_FREXPF = 1; then
33 FREXPF_LIBM="$FREXP_LIBM"
35 AC_SUBST([FREXPF_LIBM])
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],
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],
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
57 compute_minus_zero (void)
59 return -FLT_MIN * FLT_MIN;
61 # define minus_zero compute_minus_zero ()
63 float minus_zero = -0.0f;
70 /* Test on infinite numbers. */
74 float y = frexpf (x, &exp);
78 /* Test on negative zero. */
82 float y = frexpf (x, &exp);
83 if (memcmp (&y, &x, sizeof x))
88 [gl_cv_func_frexpf_works=yes],
89 [gl_cv_func_frexpf_works=no],
91 irix*) gl_cv_func_frexpf_works="guessing no" ;;
92 mingw*) # Guess yes with MSVC, no with mingw.
93 AC_EGREP_CPP([Good], [
98 [gl_cv_func_frexpf_works="guessing yes"],
99 [gl_cv_func_frexpf_works="guessing no"])
101 *) gl_cv_func_frexpf_works="guessing yes" ;;