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],
22 AC_TRY_LINK([#include <math.h>
24 [return ldexpl (x, -1) > 0;],
25 [gl_cv_func_ldexpl_in_libm=yes],
26 [gl_cv_func_ldexpl_in_libm=no])
29 if test $gl_cv_func_ldexpl_in_libm = yes; then
33 if test $gl_cv_func_ldexpl_no_libm = yes \
34 || test $gl_cv_func_ldexpl_in_libm = yes; then
36 LIBS="$LIBS $LDEXPL_LIBM"
39 case "$gl_cv_func_ldexpl_works" in
40 *yes) gl_func_ldexpl=yes ;;
41 *) gl_func_ldexpl=no; REPLACE_LDEXPL=1; LDEXPL_LIBM= ;;
46 if test $gl_func_ldexpl = yes; then
47 AC_DEFINE([HAVE_LDEXPL], [1],
48 [Define if the ldexpl() function is available.])
51 if test $HAVE_DECL_LDEXPL = 0 || test $gl_func_ldexpl = no; then
54 AC_SUBST([LDEXPL_LIBM])
57 dnl Test whether ldexpl() can be used without linking with libm.
58 dnl Set gl_cv_func_ldexpl_no_libm to 'yes' or 'no' accordingly.
59 AC_DEFUN([gl_CHECK_LDEXPL_NO_LIBM],
61 AC_CACHE_CHECK([whether ldexpl() can be used without linking with libm],
62 [gl_cv_func_ldexpl_no_libm],
64 AC_TRY_LINK([#include <math.h>
66 [return ldexpl (x, -1) > 0;],
67 [gl_cv_func_ldexpl_no_libm=yes],
68 [gl_cv_func_ldexpl_no_libm=no])
72 dnl Test whether ldexpl() works on finite numbers (this fails on AIX 5.1
73 dnl and MacOS X 10.4/PowerPC).
74 AC_DEFUN([gl_FUNC_LDEXPL_WORKS],
76 AC_REQUIRE([AC_PROG_CC])
77 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
78 AC_CACHE_CHECK([whether ldexpl works], [gl_cv_func_ldexpl_works],
82 extern long double ldexpl (long double, int);
85 volatile long double x1 = 1.0;
86 volatile long double y1 = ldexpl (x1, -1);
87 volatile long double x2 = 1.73205L;
88 volatile long double y2 = ldexpl (x2, 0);
89 return (y1 != 0.5L) || (y2 != x2);
90 }], [gl_cv_func_ldexpl_works=yes], [gl_cv_func_ldexpl_works=no],
92 aix*) gl_cv_func_ldexpl_works="guessing no";;
93 *) gl_cv_func_ldexpl_works="guessing yes";;