summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2007-03-30 00:13:24 +0000
committerBruno Haible <bruno@clisp.org>2007-03-30 00:13:24 +0000
commitd6687687c7f3b86ba712ab98533a8094e9de58f5 (patch)
tree8d44ad3c1e76a2a5715d4dee7f8850374cc06c04
parentbb6439f137116226069b1f9c546fb563eb41565e (diff)
downloadgnulib-d6687687c7f3b86ba712ab98533a8094e9de58f5.tar.gz
New module 'ldexpl'.
-rw-r--r--ChangeLog16
-rw-r--r--lib/math_.h10
-rw-r--r--m4/ldexpl.m483
-rw-r--r--m4/math_h.m44
-rw-r--r--m4/mathl.m44
-rw-r--r--m4/printf-frexpl.m415
-rw-r--r--modules/ldexpl26
-rw-r--r--modules/math2
-rw-r--r--modules/mathl2
9 files changed, 150 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index a5c2534d02..7c42d3bbe5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
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.
2007-03-29 Bruno Haible <bruno@clisp.org>
diff --git a/lib/math_.h b/lib/math_.h
index 0fa81d71fc..e8dfb2a7d5 100644
--- a/lib/math_.h
+++ b/lib/math_.h
@@ -149,14 +149,18 @@ extern long double frexpl (long double x, int *exp);
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
diff --git a/m4/ldexpl.m4 b/m4/ldexpl.m4
new file mode 100644
index 0000000000..b7ef5807c0
--- /dev/null
+++ b/m4/ldexpl.m4
@@ -0,0 +1,83 @@
+# 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
+ ])
+ ])
+])
diff --git a/m4/math_h.m4 b/m4/math_h.m4
index cc906f6431..1202dc8781 100644
--- a/m4/math_h.m4
+++ b/m4/math_h.m4
@@ -1,4 +1,4 @@
-# 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,
@@ -23,6 +23,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
[
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])
@@ -40,4 +41,5 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
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])
])
diff --git a/m4/mathl.m4 b/m4/mathl.m4
index 57d70a5a7a..5d82466203 100644
--- a/m4/mathl.m4
+++ b/m4/mathl.m4
@@ -1,4 +1,4 @@
-# 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,
@@ -7,7 +7,7 @@ dnl with or without modifications, as long as this notice is preserved.
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)
])
diff --git a/m4/printf-frexpl.m4 b/m4/printf-frexpl.m4
index d522d0e3b8..14acc35469 100644
--- a/m4/printf-frexpl.m4
+++ b/m4/printf-frexpl.m4
@@ -40,11 +40,16 @@ AC_DEFUN([gl_FUNC_PRINTF_FREXPL],
[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
])
diff --git a/modules/ldexpl b/modules/ldexpl
new file mode 100644
index 0000000000..c89187a50e
--- /dev/null
+++ b/modules/ldexpl
@@ -0,0 +1,26 @@
+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
+
diff --git a/modules/math b/modules/math
index 5c28af7d17..eb72003beb 100644
--- a/modules/math
+++ b/modules/math
@@ -23,6 +23,7 @@ math.h: math_.h
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' \
@@ -39,6 +40,7 @@ math.h: math_.h
-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
diff --git a/modules/mathl b/modules/mathl
index 709f21efce..d9c1b13b3b 100644
--- a/modules/mathl
+++ b/modules/mathl
@@ -9,7 +9,6 @@ lib/ceill.c
lib/cosl.c
lib/expl.c
lib/floorl.c
-lib/ldexpl.c
lib/logl.c
lib/sincosl.c
lib/sinl.c
@@ -23,6 +22,7 @@ Depends-on:
math
frexpl
isnanl
+ldexpl
configure.ac:
gl_FUNC_LONG_DOUBLE_MATH