+2007-03-29 Bruno Haible <bruno@clisp.org>
+
+ * modules/ldexpl: New file.
+ * m4/ldexpl.m4: New file.
+ * lib/math_.h (ldexpl): Define to a replacement if REPLACE_LDEXPL is
+ set.
+ * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize also GNULIB_LDEXPL,
+ REPLACE_LDEXPL.
+ * modules/math (Makefile.am): Substitute also GNULIB_LDEXPL,
+ REPLACE_LDEXPL.
+ * m4/printf-frexpl.m4 (gl_FUNC_PRINTF_FREXPL): Invoke
+ gl_FUNC_LDEXPL_WORKS.
+ * m4/mathl.m4 (gl_FUNC_LONG_DOUBLE_MATH): Remove test for ldexpl.
+ * modules/mathl (Files): Remove lib/ldexpl.c.
+ (Depends-on): Add ldexpl.
+
2007-03-29 Bruno Haible <bruno@clisp.org>
* m4/frexpl.m4 (gl_FUNC_FREXPL_WORKS): Declare frexpl.
frexpl (x, e))
#endif
-#if @GNULIB_MATHL@ || !@HAVE_DECL_LDEXPL@
+/* Return x * 2^exp. */
+#if @GNULIB_LDEXPL@ && @REPLACE_LDEXPL@
+# define ldexpl rpl_ldexpl
+#endif
+#if (@GNULIB_LDEXPL@ && @REPLACE_LDEXPL@) || !@HAVE_DECL_LDEXPL@
extern long double ldexpl (long double x, int exp);
#endif
-#if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
+#if !@GNULIB_LDEXPL@ && defined GNULIB_POSIXCHECK
# undef ldexpl
# define ldexpl(x,e) \
(GL_LINK_WARNING ("ldexpl is unportable - " \
- "use gnulib module mathl for portability"), \
+ "use gnulib module ldexpl for portability"), \
ldexpl (x, e))
#endif
--- /dev/null
+# ldexpl.m4 serial 2
+dnl Copyright (C) 2007 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_LDEXPL],
+[
+ AC_REQUIRE([gl_MATH_H_DEFAULTS])
+ LDEXPL_LIBM=
+ AC_CACHE_CHECK([whether ldexpl() can be used without linking with libm],
+ [gl_cv_func_ldexpl_no_libm],
+ [
+ AC_TRY_LINK([#include <math.h>
+ long double x;],
+ [return ldexpl (x, -1) > 0;],
+ [gl_cv_func_ldexpl_no_libm=yes],
+ [gl_cv_func_ldexpl_no_libm=no])
+ ])
+ if test $gl_cv_func_ldexpl_no_libm = no; then
+ AC_CACHE_CHECK([whether ldexpl() can be used with libm],
+ [gl_cv_func_ldexpl_in_libm],
+ [
+ save_LIBS="$LIBS"
+ LIBS="$LIBS -lm"
+ AC_TRY_LINK([#include <math.h>
+ long double x;],
+ [return ldexpl (x, -1) > 0;],
+ [gl_cv_func_ldexpl_in_libm=yes],
+ [gl_cv_func_ldexpl_in_libm=no])
+ LIBS="$save_LIBS"
+ ])
+ if test $gl_cv_func_ldexpl_in_libm = yes; then
+ LDEXPL_LIBM=-lm
+ fi
+ fi
+ if test $gl_cv_func_ldexpl_no_libm = yes \
+ || test $gl_cv_func_ldexpl_in_libm = yes; then
+ save_LIBS="$LIBS"
+ LIBS="$LIBS $LDEXPL_LIBM"
+ gl_FUNC_LDEXPL_WORKS
+ LIBS="$save_LIBS"
+ case "$gl_cv_func_ldexpl_works" in
+ *yes) gl_func_ldexpl=yes ;;
+ *) gl_func_ldexpl=no; REPLACE_LDEXPL=1; LDEXPL_LIBM= ;;
+ esac
+ else
+ gl_func_ldexpl=no
+ fi
+ if test $gl_func_ldexpl = yes; then
+ AC_DEFINE([HAVE_LDEXPL], 1,
+ [Define if the ldexpl() function is available.])
+ dnl Also check whether it's declared.
+ dnl MacOS X 10.3 has ldexpl() in libc but doesn't declare it in <math.h>.
+ AC_CHECK_DECL([ldexpl], , [HAVE_DECL_LDEXPL=0], [#include <math.h>])
+ else
+ AC_LIBOBJ([ldexpl])
+ fi
+])
+
+dnl Test whether ldexpl() works on finite numbers (this fails on AIX 5.1).
+AC_DEFUN([gl_FUNC_LDEXPL_WORKS],
+[
+ AC_REQUIRE([AC_PROG_CC])
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+ AC_CACHE_CHECK([whether ldexpl works], [gl_cv_func_ldexpl_works],
+ [
+ AC_TRY_RUN([
+#include <math.h>
+extern long double ldexpl (long double, int);
+int main()
+{
+ volatile long double x = 1.0;
+ volatile long double y = ldexpl (x, -1);
+ return (y != 0.5L);
+}], [gl_cv_func_ldexpl_works=yes], [gl_cv_func_ldexpl_works=no],
+ [case "$host_os" in
+ aix*) gl_cv_func_ldexpl_works="guessing no";;
+ *) gl_cv_func_ldexpl_works="guessing yes";;
+ esac
+ ])
+ ])
+])
-# math_h.m4 serial 3
+# math_h.m4 serial 4
dnl Copyright (C) 2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
[
GNULIB_FREXP=0; AC_SUBST([GNULIB_FREXP])
GNULIB_FREXPL=0; AC_SUBST([GNULIB_FREXPL])
+ GNULIB_LDEXPL=0; AC_SUBST([GNULIB_LDEXPL])
GNULIB_MATHL=0; AC_SUBST([GNULIB_MATHL])
dnl Assume proper GNU behavior unless another module says otherwise.
HAVE_DECL_ACOSL=1; AC_SUBST([HAVE_DECL_ACOSL])
HAVE_DECL_TANL=1; AC_SUBST([HAVE_DECL_TANL])
REPLACE_FREXP=0; AC_SUBST([REPLACE_FREXP])
REPLACE_FREXPL=0; AC_SUBST([REPLACE_FREXPL])
+ REPLACE_LDEXPL=0; AC_SUBST([REPLACE_LDEXPL])
])
-# mathl.m4 serial 3
+# mathl.m4 serial 4
dnl Copyright (c) 2003, 2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
AC_DEFUN([gl_FUNC_LONG_DOUBLE_MATH], [
AC_CHECK_LIB(m, atan)
-AC_REPLACE_FUNCS(floorl ceill sqrtl ldexpl asinl acosl atanl \
+AC_REPLACE_FUNCS(floorl ceill sqrtl asinl acosl atanl \
logl expl tanl sinl cosl)
])
[gl_cv_func_ldexpl_no_libm=no])
])
if test $gl_cv_func_ldexpl_no_libm = yes; then
- AC_DEFINE([HAVE_LDEXPL_IN_LIBC], 1,
- [Define if the ldexpl function is available in libc.])
- dnl Also check whether it's declared.
- dnl MacOS X 10.3 has ldexpl() in libc but doesn't declare it in <math.h>.
- AC_CHECK_DECL([ldexpl], , [HAVE_DECL_LDEXPL=0], [#include <math.h>])
+ gl_FUNC_LDEXPL_WORKS
+ case "$gl_cv_func_ldexpl_works" in
+ *yes)
+ AC_DEFINE([HAVE_LDEXPL_IN_LIBC], 1,
+ [Define if the ldexpl function is available in libc.])
+ dnl Also check whether it's declared.
+ dnl MacOS X 10.3 has ldexpl() in libc but doesn't declare it in <math.h>.
+ AC_CHECK_DECL([ldexpl], , [HAVE_DECL_LDEXPL=0], [#include <math.h>])
+ ;;
+ esac
fi
fi
])
--- /dev/null
+Description:
+ldexpl() function: multiply a 'long double' by a power of 2.
+
+Files:
+lib/ldexpl.c
+m4/ldexpl.m4
+
+Depends-on:
+math
+isnanl-nolibm
+
+configure.ac:
+gl_FUNC_LDEXPL
+gl_MATH_MODULE_INDICATOR([ldexpl])
+
+Makefile.am:
+
+Include:
+<math.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible, Paolo Bonzini
+
sed -e 's|@''ABSOLUTE_MATH_H''@|$(ABSOLUTE_MATH_H)|g' \
-e 's|@''GNULIB_FREXP''@|$(GNULIB_FREXP)|g' \
-e 's|@''GNULIB_FREXPL''@|$(GNULIB_FREXPL)|g' \
+ -e 's|@''GNULIB_LDEXPL''@|$(GNULIB_LDEXPL)|g' \
-e 's|@''GNULIB_MATHL''@|$(GNULIB_MATHL)|g' \
-e 's|@''HAVE_DECL_ACOSL''@|$(HAVE_DECL_ACOSL)|g' \
-e 's|@''HAVE_DECL_ASINL''@|$(HAVE_DECL_ASINL)|g' \
-e 's|@''HAVE_DECL_TANL''@|$(HAVE_DECL_TANL)|g' \
-e 's|@''REPLACE_FREXP''@|$(REPLACE_FREXP)|g' \
-e 's|@''REPLACE_FREXPL''@|$(REPLACE_FREXPL)|g' \
+ -e 's|@''REPLACE_LDEXPL''@|$(REPLACE_LDEXPL)|g' \
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
< $(srcdir)/math_.h; \
} > $@-t
lib/cosl.c
lib/expl.c
lib/floorl.c
-lib/ldexpl.c
lib/logl.c
lib/sincosl.c
lib/sinl.c
math
frexpl
isnanl
+ldexpl
configure.ac:
gl_FUNC_LONG_DOUBLE_MATH