2 dnl Copyright (C) 2007-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_LDEXPL],
9 AC_REQUIRE([gl_MATH_H_DEFAULTS])
10 AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
11 AC_REQUIRE([gl_FUNC_ISNANL]) dnl for ISNANL_LIBM
13 dnl Persuade glibc <math.h> to declare ldexpl().
14 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
16 dnl Check whether it's declared.
17 dnl Mac OS X 10.3 has ldexpl() in libc but doesn't declare it in <math.h>.
18 AC_CHECK_DECL([ldexpl], , [HAVE_DECL_LDEXPL=0], [[#include <math.h>]])
21 if test $HAVE_DECL_LDEXPL = 1; then
22 gl_CHECK_LDEXPL_NO_LIBM
23 if test $gl_cv_func_ldexpl_no_libm = no; then
24 AC_CACHE_CHECK([whether ldexpl() can be used with libm],
25 [gl_cv_func_ldexpl_in_libm],
33 [[return ldexpl (x, -1) > 0;]])],
34 [gl_cv_func_ldexpl_in_libm=yes],
35 [gl_cv_func_ldexpl_in_libm=no])
38 if test $gl_cv_func_ldexpl_in_libm = yes; then
42 if test $gl_cv_func_ldexpl_no_libm = yes \
43 || test $gl_cv_func_ldexpl_in_libm = yes; then
45 LIBS="$LIBS $LDEXPL_LIBM"
48 case "$gl_cv_func_ldexpl_works" in
49 *yes) gl_func_ldexpl=yes ;;
50 *) gl_func_ldexpl=no; REPLACE_LDEXPL=1 ;;
55 if test $gl_func_ldexpl = yes; then
56 AC_DEFINE([HAVE_LDEXPL], [1],
57 [Define if the ldexpl() function is available.])
60 if test $HAVE_DECL_LDEXPL = 0 || test $gl_func_ldexpl = no; then
61 dnl Find libraries needed to link lib/ldexpl.c.
62 if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
63 AC_REQUIRE([gl_FUNC_LDEXP])
64 LDEXPL_LIBM="$LDEXP_LIBM"
66 LDEXPL_LIBM="$ISNANL_LIBM"
69 AC_SUBST([LDEXPL_LIBM])
72 dnl Test whether ldexpl() can be used without linking with libm.
73 dnl Set gl_cv_func_ldexpl_no_libm to 'yes' or 'no' accordingly.
74 AC_DEFUN([gl_CHECK_LDEXPL_NO_LIBM],
76 AC_CACHE_CHECK([whether ldexpl() can be used without linking with libm],
77 [gl_cv_func_ldexpl_no_libm],
83 [[return ldexpl (x, -1) > 0;]])],
84 [gl_cv_func_ldexpl_no_libm=yes],
85 [gl_cv_func_ldexpl_no_libm=no])
89 dnl Test whether ldexpl() works on finite numbers (this fails on AIX 5.1
90 dnl and Mac OS X 10.4/PowerPC).
91 AC_DEFUN([gl_FUNC_LDEXPL_WORKS],
93 AC_REQUIRE([AC_PROG_CC])
94 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
95 AC_CACHE_CHECK([whether ldexpl works], [gl_cv_func_ldexpl_works],
104 long double ldexpl (long double, int);
109 volatile long double x = 1.0;
110 volatile long double y = ldexpl (x, -1);
115 volatile long double x = 1.73205L;
116 volatile long double y = ldexpl (x, 0);
122 [gl_cv_func_ldexpl_works=yes],
123 [gl_cv_func_ldexpl_works=no],
127 aix | aix[3-6]*) gl_cv_func_ldexpl_works="guessing no" ;;
128 # Guess yes on native Windows.
129 mingw*) gl_cv_func_ldexpl_works="guessing yes" ;;
130 *) gl_cv_func_ldexpl_works="guessing yes" ;;