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 AC_CACHE_CHECK([whether ldexpl() can be used without linking with libm],
16 [gl_cv_func_ldexpl_no_libm],
18 AC_TRY_LINK([#include <math.h>
20 [return ldexpl (x, -1) > 0;],
21 [gl_cv_func_ldexpl_no_libm=yes],
22 [gl_cv_func_ldexpl_no_libm=no])
24 if test $gl_cv_func_ldexpl_no_libm = no; then
25 AC_CACHE_CHECK([whether ldexpl() can be used with libm],
26 [gl_cv_func_ldexpl_in_libm],
30 AC_TRY_LINK([#include <math.h>
32 [return ldexpl (x, -1) > 0;],
33 [gl_cv_func_ldexpl_in_libm=yes],
34 [gl_cv_func_ldexpl_in_libm=no])
37 if test $gl_cv_func_ldexpl_in_libm = yes; then
41 if test $gl_cv_func_ldexpl_no_libm = yes \
42 || test $gl_cv_func_ldexpl_in_libm = yes; then
44 LIBS="$LIBS $LDEXPL_LIBM"
47 case "$gl_cv_func_ldexpl_works" in
48 *yes) gl_func_ldexpl=yes ;;
49 *) gl_func_ldexpl=no; REPLACE_LDEXPL=1; LDEXPL_LIBM= ;;
54 if test $gl_func_ldexpl = yes; then
55 AC_DEFINE([HAVE_LDEXPL], [1],
56 [Define if the ldexpl() function is available.])
59 if test $HAVE_DECL_LDEXPL = 0 || test $gl_func_ldexpl = no; then
62 AC_SUBST([LDEXPL_LIBM])
65 dnl Test whether ldexpl() works on finite numbers (this fails on AIX 5.1
66 dnl and MacOS X 10.4/PowerPC).
67 AC_DEFUN([gl_FUNC_LDEXPL_WORKS],
69 AC_REQUIRE([AC_PROG_CC])
70 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
71 AC_CACHE_CHECK([whether ldexpl works], [gl_cv_func_ldexpl_works],
75 extern long double ldexpl (long double, int);
78 volatile long double x1 = 1.0;
79 volatile long double y1 = ldexpl (x1, -1);
80 volatile long double x2 = 1.73205L;
81 volatile long double y2 = ldexpl (x2, 0);
82 return (y1 != 0.5L) || (y2 != x2);
83 }], [gl_cv_func_ldexpl_works=yes], [gl_cv_func_ldexpl_works=no],
85 aix*) gl_cv_func_ldexpl_works="guessing no";;
86 *) gl_cv_func_ldexpl_works="guessing yes";;