New module 'frexpl'.
authorBruno Haible <bruno@clisp.org>
Fri, 23 Mar 2007 01:26:24 +0000 (01:26 +0000)
committerBruno Haible <bruno@clisp.org>
Fri, 23 Mar 2007 01:26:24 +0000 (01:26 +0000)
ChangeLog
lib/math_.h
m4/frexpl.m4 [new file with mode: 0644]
m4/math_h.m4
m4/mathl.m4
modules/frexpl [new file with mode: 0644]
modules/math
modules/mathl

index 0cd2fab77568b37782ed65413a658efd752380d5..31bf564da9e5860b0ccb58852546be71ea53b263 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2007-03-22  Bruno Haible  <bruno@clisp.org>
+
+       * modules/frexpl: New file.
+       * m4/frexpl.m4: New file.
+       * modules/math (Makefile.am): Also substitute GNULIB_FREXPL into math.h.
+       * lib/math_.h (frexpl): Test GNULIB_FREXPL instead of GNULIB_MATHL.
+       * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize GNULIB_FREXPL.
+       * modules/mathl (Files): Remove lib/frexpl.c, lib/frexp.c.
+       (Depends-on): Add frexpl. Remove isnanl-nolibm.
+       * m4/mathl.m4 (gl_FUNC_LONG_DOUBLE_MATH): Don't test for frexpl.
+
 2007-03-22  Bruno Haible  <bruno@clisp.org>
 
        * lib/frexpl.c: Share code with lib/frexp.c.
index 18f3807b120d61577060cef3ecde9cddc0b97cb4..48e622ec8f0c78b7d5772bed8e23dd6e3bfd6998 100644 (file)
@@ -128,14 +128,21 @@ extern long double floorl (long double x);
      floorl (x))
 #endif
 
-#if @GNULIB_MATHL@ || !@HAVE_DECL_FREXPL@
+/* Write x as
+     x = mantissa * 2^exp
+   where
+     If x finite and nonzero: 0.5 <= |mantissa| < 1.0.
+     If x is zero: mantissa = x, exp = 0.
+     If x is infinite or NaN: mantissa = x, exp unspecified.
+   Store exp and return mantissa.  */
+#if @GNULIB_FREXPL@ || !@HAVE_DECL_FREXPL@
 extern long double frexpl (long double x, int *exp);
 #endif
-#if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
+#if !@GNULIB_FREXPL@ || defined GNULIB_POSIXCHECK
 # undef frexpl
 # define frexpl(x,e) \
     (GL_LINK_WARNING ("frexpl is unportable - " \
-                      "use gnulib module mathl for portability"), \
+                      "use gnulib module frexpl for portability"), \
      frexpl (x, e))
 #endif
 
diff --git a/m4/frexpl.m4 b/m4/frexpl.m4
new file mode 100644 (file)
index 0000000..361fd2d
--- /dev/null
@@ -0,0 +1,47 @@
+# frexpl.m4 serial 1
+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_FREXPL],
+[
+  AC_REQUIRE([gl_MATH_H_DEFAULTS])
+  FREXPL_LIBM=
+  AC_CACHE_CHECK([whether frexpl() can be used without linking with libm],
+    [gl_cv_func_frexpl_no_libm],
+    [
+      AC_TRY_LINK([#include <math.h>
+                   long double x;],
+                  [int e; return frexpl (x, &e) > 0;],
+        [gl_cv_func_frexpl_no_libm=yes],
+        [gl_cv_func_frexpl_no_libm=no])
+    ])
+  if test $gl_cv_func_frexpl_no_libm = no; then
+    AC_CACHE_CHECK([whether frexpl() can be used with libm],
+      [gl_cv_func_frexpl_in_libm],
+      [
+        save_LIBS="$LIBS"
+        LIBS="$LIBS -lm"
+        AC_TRY_LINK([#include <math.h>
+                     long double x;],
+                    [int e; return frexpl (x, &e) > 0;],
+          [gl_cv_func_frexpl_in_libm=yes],
+          [gl_cv_func_frexpl_in_libm=no])
+        LIBS="$save_LIBS"
+      ])
+    if test $gl_cv_func_frexpl_in_libm = yes; then
+      FREXPL_LIBM=-lm
+    fi
+  fi
+  if test $gl_cv_func_frexpl_no_libm = yes \
+     || test $gl_cv_func_frexpl_in_libm = yes; then
+    AC_DEFINE([HAVE_FREXPL], 1,
+      [Define if the frexpl() function is available.])
+    dnl Also 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>])
+  else
+    AC_LIBOBJ([frexpl])
+  fi
+])
index 5b393f4b84d8035fb7f8cbf519549e07373c0ab0..fb3ea09f2b4f898087bf50ebdeea134c8b7978f1 100644 (file)
@@ -21,8 +21,9 @@ AC_DEFUN([gl_MATH_MODULE_INDICATOR],
 
 AC_DEFUN([gl_MATH_H_DEFAULTS],
 [
-  GNULIB_FREXP=0; AC_SUBST([GNULIB_FREXP])
-  GNULIB_MATHL=0; AC_SUBST([GNULIB_MATHL])
+  GNULIB_FREXP=0;  AC_SUBST([GNULIB_FREXP])
+  GNULIB_FREXPL=0; AC_SUBST([GNULIB_FREXPL])
+  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_ASINL=1;  AC_SUBST([HAVE_DECL_ASINL])
index c875203d41ad439048d5613836092066bc6e5de2..57d70a5a7adb71afc91280c374829a2de6ef87fa 100644 (file)
@@ -1,5 +1,5 @@
-# mathl.m4 serial 2
-dnl Copyright (c) 2003 Free Software Foundation, Inc.
+# mathl.m4 serial 3
+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,
 dnl with or without modifications, as long as this notice is preserved.
@@ -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 frexpl ldexpl asinl acosl atanl \
+AC_REPLACE_FUNCS(floorl ceill sqrtl ldexpl asinl acosl atanl \
         logl expl tanl sinl cosl)
 
 ])
diff --git a/modules/frexpl b/modules/frexpl
new file mode 100644 (file)
index 0000000..0bb8f58
--- /dev/null
@@ -0,0 +1,27 @@
+Description:
+frexpl() function: split a 'long double' into its constituents.
+
+Files:
+lib/frexpl.c
+lib/frexp.c
+m4/frexpl.m4
+
+Depends-on:
+math
+isnanl-nolibm
+
+configure.ac:
+gl_FUNC_FREXPL
+gl_MATH_MODULE_INDICATOR([frexpl])
+
+Makefile.am:
+
+Include:
+<math.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible, Paolo Bonzini
+
index 7d265bdae71bdb06d7f9f1e516121f20e4442ffb..288ab92a0d3c8f90a81c2a8bc1bd4aee76c1fbc4 100644 (file)
@@ -22,6 +22,7 @@ math.h: math_.h
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
          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_MATHL''@|$(GNULIB_MATHL)|g' \
              -e 's|@''HAVE_DECL_ACOSL''@|$(HAVE_DECL_ACOSL)|g' \
              -e 's|@''HAVE_DECL_ASINL''@|$(HAVE_DECL_ASINL)|g' \
index 4a7c5953df31c54e5d063a433307cd81d371c81d..b8767b0f997fe2f07482decf10d2f71b6912814a 100644 (file)
@@ -9,8 +9,6 @@ lib/ceill.c
 lib/cosl.c
 lib/expl.c
 lib/floorl.c
-lib/frexpl.c
-lib/frexp.c
 lib/ldexpl.c
 lib/logl.c
 lib/sincosl.c
@@ -23,7 +21,7 @@ m4/mathl.m4
 
 Depends-on:
 math
-isnanl-nolibm
+frexpl
 
 configure.ac:
 gl_FUNC_LONG_DOUBLE_MATH