changeset 15935:f964f4ef47e5

ldexpl: Simplify for platforms where 'long double' == 'double'. * lib/ldexpl.c (ldexpl) [HAVE_SAME_LONG_DOUBLE_AS_DOUBLE]: New alternative implementation. * m4/ldexpl.m4 (gl_FUNC_LDEXPL): Require gl_LONG_DOUBLE_VS_DOUBLE. Determine LDEXPL_LIBM according to HAVE_SAME_LONG_DOUBLE_AS_DOUBLE. * modules/ldexpl (Depends-on): Add ldexp. Update conditions.
author Bruno Haible <bruno@clisp.org>
date Mon, 10 Oct 2011 23:35:54 +0200
parents 7107ea7879b2
children be4d9abe9bd0
files ChangeLog lib/ldexpl.c m4/ldexpl.m4 modules/ldexpl
diffstat 4 files changed, 34 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2011-10-10  Bruno Haible  <bruno@clisp.org>
+
+	ldexpl: Simplify for platforms where 'long double' == 'double'.
+	* lib/ldexpl.c (ldexpl) [HAVE_SAME_LONG_DOUBLE_AS_DOUBLE]: New
+	alternative implementation.
+	* m4/ldexpl.m4 (gl_FUNC_LDEXPL): Require gl_LONG_DOUBLE_VS_DOUBLE.
+	Determine LDEXPL_LIBM according to HAVE_SAME_LONG_DOUBLE_AS_DOUBLE.
+	* modules/ldexpl (Depends-on): Add ldexp. Update conditions.
+
 2011-10-10  Tom G. Christensen  <tgc@jupiterrise.com>  (tiny change)
 
 	ffsll: set correct witness
--- a/lib/ldexpl.c
+++ b/lib/ldexpl.c
@@ -23,8 +23,18 @@
 /* Specification.  */
 #include <math.h>
 
-#include <float.h>
-#include "fpucw.h"
+#if HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
+
+long double
+ldexpl (long double x, int exp)
+{
+  return ldexp (x, exp);
+}
+
+#else
+
+# include <float.h>
+# include "fpucw.h"
 
 long double
 ldexpl (long double x, int exp)
@@ -65,6 +75,8 @@
   return x;
 }
 
+#endif
+
 #if 0
 int
 main (void)
--- a/m4/ldexpl.m4
+++ b/m4/ldexpl.m4
@@ -1,4 +1,4 @@
-# ldexpl.m4 serial 13
+# ldexpl.m4 serial 14
 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 @@
 AC_DEFUN([gl_FUNC_LDEXPL],
 [
   AC_REQUIRE([gl_MATH_H_DEFAULTS])
+  AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
   AC_REQUIRE([gl_FUNC_ISNANL]) dnl for ISNANL_LIBM
   dnl Check whether it's declared.
   dnl MacOS X 10.3 has ldexpl() in libc but doesn't declare it in <math.h>.
@@ -53,7 +54,12 @@
   fi
   if test $HAVE_DECL_LDEXPL = 0 || test $gl_func_ldexpl = no; then
     dnl Find libraries needed to link lib/ldexpl.c.
-    LDEXPL_LIBM="$ISNANL_LIBM"
+    if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
+      AC_REQUIRE([gl_FUNC_LDEXP])
+      LDEXPL_LIBM="$LDEXP_LIBM"
+    else
+      LDEXPL_LIBM="$ISNANL_LIBM"
+    fi
   fi
   AC_SUBST([LDEXPL_LIBM])
 ])
--- a/modules/ldexpl
+++ b/modules/ldexpl
@@ -7,8 +7,9 @@
 
 Depends-on:
 math
-isnanl          [test $HAVE_DECL_LDEXPL = 0 || test $gl_func_ldexpl = no]
-fpucw           [test $HAVE_DECL_LDEXPL = 0 || test $gl_func_ldexpl = no]
+ldexp           [{ test $HAVE_DECL_LDEXPL = 0 || test $gl_func_ldexpl = no; } && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1]
+isnanl          [{ test $HAVE_DECL_LDEXPL = 0 || test $gl_func_ldexpl = no; } && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0]
+fpucw           [{ test $HAVE_DECL_LDEXPL = 0 || test $gl_func_ldexpl = no; } && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0]
 
 configure.ac:
 gl_FUNC_LDEXPL