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
23 LIBS="$LIBS $FREXPF_LIBM"
26 case "$gl_cv_func_frexpf_works" in
28 *) REPLACE_FREXPF=1 ;;
33 if test $HAVE_FREXPF = 0 || test $REPLACE_FREXPF = 1; then
34 FREXPF_LIBM="$FREXP_LIBM"
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],
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
58 compute_minus_zero (void)
60 return -FLT_MIN * FLT_MIN;
62 # define minus_zero compute_minus_zero ()
64 float minus_zero = -0.0f;
71 /* Test on infinite numbers. */
75 float y = frexpf (x, &exp);
79 /* Test on negative zero. */
83 float y = frexpf (x, &exp);
85 if (memcmp (&y, &x1, sizeof x1))
90 [gl_cv_func_frexpf_works=yes],
91 [gl_cv_func_frexpf_works=no],
93 irix*) gl_cv_func_frexpf_works="guessing no" ;;
94 # Guess yes with MSVC, no with mingw.
96 gl_cv_func_frexpf_works="guessing yes"
99 AC_EGREP_CPP([Good], [
104 [gl_cv_func_frexpf_works="guessing yes"],
105 [gl_cv_func_frexpf_works="guessing no"])
107 *) gl_cv_func_frexpf_works="guessing yes" ;;