2 dnl Copyright (C) 2007-2010 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 dnl Check whether it's declared.
11 dnl MacOS X 10.3 has ldexpl() in libc but doesn't declare it in <math.h>.
12 AC_CHECK_DECL([ldexpl], , [HAVE_DECL_LDEXPL=0], [#include <math.h>])
14 if test $HAVE_DECL_LDEXPL = 1; then
15 gl_CHECK_LDEXPL_NO_LIBM
16 if test $gl_cv_func_ldexpl_no_libm = no; then
17 AC_CACHE_CHECK([whether ldexpl() can be used with libm],
18 [gl_cv_func_ldexpl_in_libm],
26 [[return ldexpl (x, -1) > 0;]])],
27 [gl_cv_func_ldexpl_in_libm=yes],
28 [gl_cv_func_ldexpl_in_libm=no])
31 if test $gl_cv_func_ldexpl_in_libm = yes; then
35 if test $gl_cv_func_ldexpl_no_libm = yes \
36 || test $gl_cv_func_ldexpl_in_libm = yes; then
38 LIBS="$LIBS $LDEXPL_LIBM"
41 case "$gl_cv_func_ldexpl_works" in
42 *yes) gl_func_ldexpl=yes ;;
43 *) gl_func_ldexpl=no; REPLACE_LDEXPL=1; LDEXPL_LIBM= ;;
48 if test $gl_func_ldexpl = yes; then
49 AC_DEFINE([HAVE_LDEXPL], [1],
50 [Define if the ldexpl() function is available.])
53 if test $HAVE_DECL_LDEXPL = 0 || test $gl_func_ldexpl = no; then
56 AC_SUBST([LDEXPL_LIBM])
59 dnl Test whether ldexpl() can be used without linking with libm.
60 dnl Set gl_cv_func_ldexpl_no_libm to 'yes' or 'no' accordingly.
61 AC_DEFUN([gl_CHECK_LDEXPL_NO_LIBM],
63 AC_CACHE_CHECK([whether ldexpl() can be used without linking with libm],
64 [gl_cv_func_ldexpl_no_libm],
70 [[return ldexpl (x, -1) > 0;]])],
71 [gl_cv_func_ldexpl_no_libm=yes],
72 [gl_cv_func_ldexpl_no_libm=no])
76 dnl Test whether ldexpl() works on finite numbers (this fails on AIX 5.1
77 dnl and MacOS X 10.4/PowerPC).
78 AC_DEFUN([gl_FUNC_LDEXPL_WORKS],
80 AC_REQUIRE([AC_PROG_CC])
81 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
82 AC_CACHE_CHECK([whether ldexpl works], [gl_cv_func_ldexpl_works],
87 extern long double ldexpl (long double, int);
92 volatile long double x = 1.0;
93 volatile long double y = ldexpl (x, -1);
98 volatile long double x = 1.73205L;
99 volatile long double y = ldexpl (x, 0);
105 [gl_cv_func_ldexpl_works=yes],
106 [gl_cv_func_ldexpl_works=no],
110 aix | aix[3-6]*) gl_cv_func_ldexpl_works="guessing no";;
111 *) gl_cv_func_ldexpl_works="guessing yes";;