|
Packit Service |
c30d13 |
# ldexpl.m4 serial 17
|
|
Packit Service |
c30d13 |
dnl Copyright (C) 2007-2018 Free Software Foundation, Inc.
|
|
Packit Service |
c30d13 |
dnl This file is free software; the Free Software Foundation
|
|
Packit Service |
c30d13 |
dnl gives unlimited permission to copy and/or distribute it,
|
|
Packit Service |
c30d13 |
dnl with or without modifications, as long as this notice is preserved.
|
|
Packit Service |
c30d13 |
|
|
Packit Service |
c30d13 |
AC_DEFUN([gl_FUNC_LDEXPL],
|
|
Packit Service |
c30d13 |
[
|
|
Packit Service |
c30d13 |
AC_REQUIRE([gl_MATH_H_DEFAULTS])
|
|
Packit Service |
c30d13 |
AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
|
|
Packit Service |
c30d13 |
AC_REQUIRE([gl_FUNC_ISNANL]) dnl for ISNANL_LIBM
|
|
Packit Service |
c30d13 |
|
|
Packit Service |
c30d13 |
dnl Persuade glibc <math.h> to declare ldexpl().
|
|
Packit Service |
c30d13 |
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
|
|
Packit Service |
c30d13 |
|
|
Packit Service |
c30d13 |
dnl Check whether it's declared.
|
|
Packit Service |
c30d13 |
dnl Mac OS X 10.3 has ldexpl() in libc but doesn't declare it in <math.h>.
|
|
Packit Service |
c30d13 |
AC_CHECK_DECL([ldexpl], , [HAVE_DECL_LDEXPL=0], [[#include <math.h>]])
|
|
Packit Service |
c30d13 |
|
|
Packit Service |
c30d13 |
LDEXPL_LIBM=
|
|
Packit Service |
c30d13 |
if test $HAVE_DECL_LDEXPL = 1; then
|
|
Packit Service |
c30d13 |
gl_CHECK_LDEXPL_NO_LIBM
|
|
Packit Service |
c30d13 |
if test $gl_cv_func_ldexpl_no_libm = no; then
|
|
Packit Service |
c30d13 |
AC_CACHE_CHECK([whether ldexpl() can be used with libm],
|
|
Packit Service |
c30d13 |
[gl_cv_func_ldexpl_in_libm],
|
|
Packit Service |
c30d13 |
[
|
|
Packit Service |
c30d13 |
save_LIBS="$LIBS"
|
|
Packit Service |
c30d13 |
LIBS="$LIBS -lm"
|
|
Packit Service |
c30d13 |
AC_LINK_IFELSE(
|
|
Packit Service |
c30d13 |
[AC_LANG_PROGRAM(
|
|
Packit Service |
c30d13 |
[[#include <math.h>
|
|
Packit Service |
c30d13 |
long double x;]],
|
|
Packit Service |
c30d13 |
[[return ldexpl (x, -1) > 0;]])],
|
|
Packit Service |
c30d13 |
[gl_cv_func_ldexpl_in_libm=yes],
|
|
Packit Service |
c30d13 |
[gl_cv_func_ldexpl_in_libm=no])
|
|
Packit Service |
c30d13 |
LIBS="$save_LIBS"
|
|
Packit Service |
c30d13 |
])
|
|
Packit Service |
c30d13 |
if test $gl_cv_func_ldexpl_in_libm = yes; then
|
|
Packit Service |
c30d13 |
LDEXPL_LIBM=-lm
|
|
Packit Service |
c30d13 |
fi
|
|
Packit Service |
c30d13 |
fi
|
|
Packit Service |
c30d13 |
if test $gl_cv_func_ldexpl_no_libm = yes \
|
|
Packit Service |
c30d13 |
|| test $gl_cv_func_ldexpl_in_libm = yes; then
|
|
Packit Service |
c30d13 |
save_LIBS="$LIBS"
|
|
Packit Service |
c30d13 |
LIBS="$LIBS $LDEXPL_LIBM"
|
|
Packit Service |
c30d13 |
gl_FUNC_LDEXPL_WORKS
|
|
Packit Service |
c30d13 |
LIBS="$save_LIBS"
|
|
Packit Service |
c30d13 |
case "$gl_cv_func_ldexpl_works" in
|
|
Packit Service |
c30d13 |
*yes) gl_func_ldexpl=yes ;;
|
|
Packit Service |
c30d13 |
*) gl_func_ldexpl=no; REPLACE_LDEXPL=1 ;;
|
|
Packit Service |
c30d13 |
esac
|
|
Packit Service |
c30d13 |
else
|
|
Packit Service |
c30d13 |
gl_func_ldexpl=no
|
|
Packit Service |
c30d13 |
fi
|
|
Packit Service |
c30d13 |
if test $gl_func_ldexpl = yes; then
|
|
Packit Service |
c30d13 |
AC_DEFINE([HAVE_LDEXPL], [1],
|
|
Packit Service |
c30d13 |
[Define if the ldexpl() function is available.])
|
|
Packit Service |
c30d13 |
fi
|
|
Packit Service |
c30d13 |
fi
|
|
Packit Service |
c30d13 |
if test $HAVE_DECL_LDEXPL = 0 || test $gl_func_ldexpl = no; then
|
|
Packit Service |
c30d13 |
dnl Find libraries needed to link lib/ldexpl.c.
|
|
Packit Service |
c30d13 |
if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
|
|
Packit Service |
c30d13 |
AC_REQUIRE([gl_FUNC_LDEXP])
|
|
Packit Service |
c30d13 |
LDEXPL_LIBM="$LDEXP_LIBM"
|
|
Packit Service |
c30d13 |
else
|
|
Packit Service |
c30d13 |
LDEXPL_LIBM="$ISNANL_LIBM"
|
|
Packit Service |
c30d13 |
fi
|
|
Packit Service |
c30d13 |
fi
|
|
Packit Service |
c30d13 |
AC_SUBST([LDEXPL_LIBM])
|
|
Packit Service |
c30d13 |
])
|
|
Packit Service |
c30d13 |
|
|
Packit Service |
c30d13 |
dnl Test whether ldexpl() can be used without linking with libm.
|
|
Packit Service |
c30d13 |
dnl Set gl_cv_func_ldexpl_no_libm to 'yes' or 'no' accordingly.
|
|
Packit Service |
c30d13 |
AC_DEFUN([gl_CHECK_LDEXPL_NO_LIBM],
|
|
Packit Service |
c30d13 |
[
|
|
Packit Service |
c30d13 |
AC_CACHE_CHECK([whether ldexpl() can be used without linking with libm],
|
|
Packit Service |
c30d13 |
[gl_cv_func_ldexpl_no_libm],
|
|
Packit Service |
c30d13 |
[
|
|
Packit Service |
c30d13 |
AC_LINK_IFELSE(
|
|
Packit Service |
c30d13 |
[AC_LANG_PROGRAM(
|
|
Packit Service |
c30d13 |
[[#include <math.h>
|
|
Packit Service |
c30d13 |
long double x;]],
|
|
Packit Service |
c30d13 |
[[return ldexpl (x, -1) > 0;]])],
|
|
Packit Service |
c30d13 |
[gl_cv_func_ldexpl_no_libm=yes],
|
|
Packit Service |
c30d13 |
[gl_cv_func_ldexpl_no_libm=no])
|
|
Packit Service |
c30d13 |
])
|
|
Packit Service |
c30d13 |
])
|
|
Packit Service |
c30d13 |
|
|
Packit Service |
c30d13 |
dnl Test whether ldexpl() works on finite numbers (this fails on AIX 5.1
|
|
Packit Service |
c30d13 |
dnl and Mac OS X 10.4/PowerPC).
|
|
Packit Service |
c30d13 |
AC_DEFUN([gl_FUNC_LDEXPL_WORKS],
|
|
Packit Service |
c30d13 |
[
|
|
Packit Service |
c30d13 |
AC_REQUIRE([AC_PROG_CC])
|
|
Packit Service |
c30d13 |
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
|
|
Packit Service |
c30d13 |
AC_CACHE_CHECK([whether ldexpl works], [gl_cv_func_ldexpl_works],
|
|
Packit Service |
c30d13 |
[
|
|
Packit Service |
c30d13 |
AC_RUN_IFELSE(
|
|
Packit Service |
c30d13 |
[AC_LANG_SOURCE([[
|
|
Packit Service |
c30d13 |
#include <math.h>
|
|
Packit Service |
c30d13 |
extern
|
|
Packit Service |
c30d13 |
#ifdef __cplusplus
|
|
Packit Service |
c30d13 |
"C"
|
|
Packit Service |
c30d13 |
#endif
|
|
Packit Service |
c30d13 |
long double ldexpl (long double, int);
|
|
Packit Service |
c30d13 |
int main()
|
|
Packit Service |
c30d13 |
{
|
|
Packit Service |
c30d13 |
int result = 0;
|
|
Packit Service |
c30d13 |
{
|
|
Packit Service |
c30d13 |
volatile long double x = 1.0;
|
|
Packit Service |
c30d13 |
volatile long double y = ldexpl (x, -1);
|
|
Packit Service |
c30d13 |
if (y != 0.5L)
|
|
Packit Service |
c30d13 |
result |= 1;
|
|
Packit Service |
c30d13 |
}
|
|
Packit Service |
c30d13 |
{
|
|
Packit Service |
c30d13 |
volatile long double x = 1.73205L;
|
|
Packit Service |
c30d13 |
volatile long double y = ldexpl (x, 0);
|
|
Packit Service |
c30d13 |
if (y != x)
|
|
Packit Service |
c30d13 |
result |= 2;
|
|
Packit Service |
c30d13 |
}
|
|
Packit Service |
c30d13 |
return result;
|
|
Packit Service |
c30d13 |
}]])],
|
|
Packit Service |
c30d13 |
[gl_cv_func_ldexpl_works=yes],
|
|
Packit Service |
c30d13 |
[gl_cv_func_ldexpl_works=no],
|
|
Packit Service |
c30d13 |
[
|
|
Packit Service |
c30d13 |
changequote(,)dnl
|
|
Packit Service |
c30d13 |
case "$host_os" in
|
|
Packit Service |
c30d13 |
aix | aix[3-6]*) gl_cv_func_ldexpl_works="guessing no" ;;
|
|
Packit Service |
c30d13 |
# Guess yes on native Windows.
|
|
Packit Service |
c30d13 |
mingw*) gl_cv_func_ldexpl_works="guessing yes" ;;
|
|
Packit Service |
c30d13 |
*) gl_cv_func_ldexpl_works="guessing yes" ;;
|
|
Packit Service |
c30d13 |
esac
|
|
Packit Service |
c30d13 |
changequote([,])dnl
|
|
Packit Service |
c30d13 |
])
|
|
Packit Service |
c30d13 |
])
|
|
Packit Service |
c30d13 |
])
|