frexpl: Simplify for platforms where 'long double' == 'double'.
authorBruno Haible <bruno@clisp.org>
Mon, 10 Oct 2011 14:17:38 +0000 (16:17 +0200)
committerBruno Haible <bruno@clisp.org>
Mon, 10 Oct 2011 14:17:38 +0000 (16:17 +0200)
* 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.

ChangeLog
lib/frexp.c
lib/frexpl.c
m4/frexpl.m4
modules/frexpl
modules/frexpl-nolibm

index 69ed191..465f6ae 100644 (file)
--- 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
index 0f0d41a..26bdec9 100644 (file)
@@ -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>
index ea635a4..c468937 100644 (file)
    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
index e9f9964..91f2a35 100644 (file)
@@ -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>]])
index 9902aff..a06edc5 100644 (file)
@@ -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
index ec1acd2..a9614bb 100644 (file)
@@ -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