summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2011-10-10 16:17:38 +0200
committerBruno Haible <bruno@clisp.org>2011-10-10 16:17:38 +0200
commitd48d7d9132b633a3a31a2f6f131ce7033f1faf8d (patch)
treeb51ff2b251278aabd787ea61aea7b1d226d5e8e1
parent775119f83d459107178933d4baa8886e91b19a9c (diff)
downloadgnulib-d48d7d9132b633a3a31a2f6f131ce7033f1faf8d.tar.gz
frexpl: Simplify for platforms where 'long double' == 'double'.
* lib/frexpl.c: Include <config.h>. (frexpl) [HAVE_SAME_LONG_DOUBLE_AS_DOUBLE]: New function. * lib/frexp.c [!USE_LONG_DOUBLE]: Don't include <config.h> a second time. * m4/frexpl.m4 (gl_FUNC_FREXPL): Require gl_LONG_DOUBLE_VS_DOUBLE. Determine FREXPL_LIBM according to HAVE_SAME_LONG_DOUBLE_AS_DOUBLE. (gl_FUNC_FREXPL_NO_LIBM): Require gl_LONG_DOUBLE_VS_DOUBLE. * modules/frexpl (Depends-on): Add frexp. Update conditions. * modules/frexpl-nolibm (Depends-on): Add frexp-nolibm. Update conditions.
-rw-r--r--ChangeLog14
-rw-r--r--lib/frexp.c4
-rw-r--r--lib/frexpl.c21
-rw-r--r--m4/frexpl.m415
-rw-r--r--modules/frexpl5
-rw-r--r--modules/frexpl-nolibm5
6 files changed, 55 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 69ed191eb5..465f6ae0e9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2011-10-10 Bruno Haible <bruno@clisp.org>
+
+ frexpl: Simplify for platforms where 'long double' == 'double'.
+ * lib/frexpl.c: Include <config.h>.
+ (frexpl) [HAVE_SAME_LONG_DOUBLE_AS_DOUBLE]: New function.
+ * lib/frexp.c [!USE_LONG_DOUBLE]: Don't include <config.h> a second
+ time.
+ * m4/frexpl.m4 (gl_FUNC_FREXPL): Require gl_LONG_DOUBLE_VS_DOUBLE.
+ Determine FREXPL_LIBM according to HAVE_SAME_LONG_DOUBLE_AS_DOUBLE.
+ (gl_FUNC_FREXPL_NO_LIBM): Require gl_LONG_DOUBLE_VS_DOUBLE.
+ * modules/frexpl (Depends-on): Add frexp. Update conditions.
+ * modules/frexpl-nolibm (Depends-on): Add frexp-nolibm. Update
+ conditions.
+
2011-10-10 Jim Meyering <meyering@redhat.com>
test-renameat: don't leave behind a temporary file
diff --git a/lib/frexp.c b/lib/frexp.c
index 0f0d41ad8b..26bdec9a71 100644
--- a/lib/frexp.c
+++ b/lib/frexp.c
@@ -17,7 +17,9 @@
/* Written by Paolo Bonzini <bonzini@gnu.org>, 2003, and
Bruno Haible <bruno@clisp.org>, 2007. */
-#include <config.h>
+#if ! defined USE_LONG_DOUBLE
+# include <config.h>
+#endif
/* Specification. */
#include <math.h>
diff --git a/lib/frexpl.c b/lib/frexpl.c
index ea635a46b3..c468937ae2 100644
--- a/lib/frexpl.c
+++ b/lib/frexpl.c
@@ -14,5 +14,22 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#define USE_LONG_DOUBLE
-#include "frexp.c"
+#include <config.h>
+
+#if HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
+
+/* Specification. */
+# include <math.h>
+
+long double
+frexpl (long double x, int *expptr)
+{
+ return frexp (x, expptr);
+}
+
+#else
+
+# define USE_LONG_DOUBLE
+# include "frexp.c"
+
+#endif
diff --git a/m4/frexpl.m4 b/m4/frexpl.m4
index e9f9964dc8..91f2a357b6 100644
--- a/m4/frexpl.m4
+++ b/m4/frexpl.m4
@@ -1,4 +1,4 @@
-# frexpl.m4 serial 17
+# frexpl.m4 serial 18
dnl Copyright (C) 2007-2011 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,6 +7,7 @@ dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_FUNC_FREXPL],
[
AC_REQUIRE([gl_MATH_H_DEFAULTS])
+ AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
dnl Check whether it's declared.
dnl MacOS X 10.3 has frexpl() in libc but doesn't declare it in <math.h>.
AC_CHECK_DECL([frexpl], , [HAVE_DECL_FREXPL=0], [[#include <math.h>]])
@@ -40,7 +41,7 @@ AC_DEFUN([gl_FUNC_FREXPL],
LIBS="$save_LIBS"
case "$gl_cv_func_frexpl_works" in
*yes) gl_func_frexpl=yes ;;
- *) gl_func_frexpl=no; REPLACE_FREXPL=1; FREXPL_LIBM= ;;
+ *) gl_func_frexpl=no; REPLACE_FREXPL=1 ;;
esac
else
gl_func_frexpl=no
@@ -50,12 +51,22 @@ AC_DEFUN([gl_FUNC_FREXPL],
[Define if the frexpl() function is available.])
fi
fi
+ if test $HAVE_DECL_FREXPL = 0 || test $gl_func_frexpl = no; then
+ dnl Find libraries needed to link lib/frexpl.c.
+ if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
+ AC_REQUIRE([gl_FUNC_FREXP])
+ FREXPL_LIBM="$FREXP_LIBM"
+ else
+ FREXPL_LIBM=
+ fi
+ fi
AC_SUBST([FREXPL_LIBM])
])
AC_DEFUN([gl_FUNC_FREXPL_NO_LIBM],
[
AC_REQUIRE([gl_MATH_H_DEFAULTS])
+ AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
dnl Check whether it's declared.
dnl MacOS X 10.3 has frexpl() in libc but doesn't declare it in <math.h>.
AC_CHECK_DECL([frexpl], , [HAVE_DECL_FREXPL=0], [[#include <math.h>]])
diff --git a/modules/frexpl b/modules/frexpl
index 9902aff0e0..a06edc5661 100644
--- a/modules/frexpl
+++ b/modules/frexpl
@@ -8,8 +8,9 @@ m4/frexpl.m4
Depends-on:
math
-isnanl-nolibm [test $HAVE_DECL_FREXPL = 0 || test $gl_func_frexpl = no]
-fpucw [test $HAVE_DECL_FREXPL = 0 || test $gl_func_frexpl = no]
+frexp [{ test $HAVE_DECL_FREXPL = 0 || test $gl_func_frexpl = no; } && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1]
+isnanl-nolibm [{ test $HAVE_DECL_FREXPL = 0 || test $gl_func_frexpl = no; } && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0]
+fpucw [{ test $HAVE_DECL_FREXPL = 0 || test $gl_func_frexpl = no; } && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0]
configure.ac:
gl_FUNC_FREXPL
diff --git a/modules/frexpl-nolibm b/modules/frexpl-nolibm
index ec1acd2f09..a9614bb474 100644
--- a/modules/frexpl-nolibm
+++ b/modules/frexpl-nolibm
@@ -9,8 +9,9 @@ m4/frexpl.m4
Depends-on:
math
-isnanl-nolibm [test $HAVE_DECL_FREXPL = 0 || test $gl_func_frexpl_no_libm = no]
-fpucw [test $HAVE_DECL_FREXPL = 0 || test $gl_func_frexpl_no_libm = no]
+frexp-nolibm [{ test $HAVE_DECL_FREXPL = 0 || test $gl_func_frexpl_no_libm = no; } && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1]
+isnanl-nolibm [{ test $HAVE_DECL_FREXPL = 0 || test $gl_func_frexpl_no_libm = no; } && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0]
+fpucw [{ test $HAVE_DECL_FREXPL = 0 || test $gl_func_frexpl_no_libm = no; } && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0]
configure.ac:
gl_FUNC_FREXPL_NO_LIBM