logb: Provide missing declaration for Cygwin.
authorBruno Haible <bruno@clisp.org>
Sun, 7 Mar 2010 23:04:47 +0000 (00:04 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 7 Mar 2010 23:04:47 +0000 (00:04 +0100)
ChangeLog
doc/posix-functions/logb.texi
lib/math.in.h
m4/logb.m4 [new file with mode: 0644]
m4/math_h.m4
modules/logb
modules/math

index 2f0189e..6be2551 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
 2010-03-07  Bruno Haible  <bruno@clisp.org>
 
+       logb: Provide missing declaration for Cygwin.
+       * lib/math.in.h (logb): New declaration.
+       * m4/logb.m4: New file.
+       * modules/logb (Files): Add m4/logb.m4.
+       (Depends-on): Add math.
+       (configure.ac): Invoke gl_FUNC_LOGB, gl_MATH_MODULE_INDICATOR.
+       * m4/math_h.m4 (gl_MATH_H): Check also for logb declaration.
+       (gl_MATH_H_DEFAULTS): Initialize GNULIB_LOGB, HAVE_DECL_LOGB.
+       * modules/math (Makefile.am): Substitute GNULIB_LOGB, HAVE_DECL_LOGB.
+       * doc/posix-functions/logb.texi: Mention the Cygwin bug.
+
+2010-03-07  Bruno Haible  <bruno@clisp.org>
+
        Fix test-cond link error.
        * tests/test-cond.c: Include <stdio.h>.
 
index 7cbd998..ef4f833 100644 (file)
@@ -12,4 +12,7 @@ Portability problems fixed by Gnulib:
 
 Portability problems not fixed by Gnulib:
 @itemize
+@item
+This function is missing a declaration on some platforms:
+Cygwin 1.5.x.
 @end itemize
index 70e7988..6f0723f 100644 (file)
@@ -97,6 +97,7 @@ _NaN ()
 # define HUGE_VAL (1.0 / 0.0)
 #endif
 
+
 /* Write x as
      x = mantissa * 2^exp
    where
@@ -117,6 +118,19 @@ _GL_WARN_ON_USE (frexp, "frexp is unportable - "
 #endif
 
 
+#if @GNULIB_LOGB@
+# if !@HAVE_DECL_LOGB@
+extern double logb (double x);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef logb
+# if HAVE_RAW_DECL_LOGB
+_GL_WARN_ON_USE (logb, "logb is unportable - "
+                 "use gnulib module logb for portability");
+# endif
+#endif
+
+
 #if @GNULIB_ACOSL@
 # if !@HAVE_ACOSL@ || !@HAVE_DECL_ACOSL@
 extern long double acosl (long double x);
diff --git a/m4/logb.m4 b/m4/logb.m4
new file mode 100644 (file)
index 0000000..c5b6803
--- /dev/null
@@ -0,0 +1,44 @@
+# logb.m4 serial 1
+dnl Copyright (C) 2010 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_LOGB],
+[
+  AC_REQUIRE([gl_MATH_H_DEFAULTS])
+  dnl Test whether logb() is declared.
+  AC_CHECK_DECLS([logb], , , [#include <math.h>])
+  if test "$ac_cv_have_decl_logb" != yes; then
+    HAVE_DECL_LOGB=0
+  fi
+  dnl Test whether logb() can be used without libm.
+  LOGB_LIBM=?
+  AC_TRY_LINK([
+     #ifndef __NO_MATH_INLINES
+     # define __NO_MATH_INLINES 1 /* for glibc */
+     #endif
+     #include <math.h>
+     extern double logb (double x);
+     double x;],
+    [x = logb(x);],
+    [LOGB_LIBM=])
+  if test "$LOGB_LIBM" = "?"; then
+    save_LIBS="$LIBS"
+    LIBS="$LIBS -lm"
+    AC_TRY_LINK([
+       #ifndef __NO_MATH_INLINES
+       # define __NO_MATH_INLINES 1 /* for glibc */
+       #endif
+       #include <math.h>
+       extern double logb (double x);
+       double x;],
+      [x = logb(x);],
+      [LOGB_LIBM="-lm"])
+    LIBS="$save_LIBS"
+  fi
+  if test "$LOGB_LIBM" = "?"; then
+    LOGB_LIBM=
+  fi
+  AC_SUBST([LOGB_LIBM])
+])
index e3b499e..e4ad02e 100644 (file)
@@ -1,4 +1,4 @@
-# math_h.m4 serial 17
+# math_h.m4 serial 18
 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -40,7 +40,7 @@ AC_DEFUN([gl_MATH_H],
   dnl corresponding gnulib module is not in use.
   gl_WARN_ON_USE_PREPARE([[#include <math.h>
     ]], [acosl asinl atanl ceilf ceill cosl expl floorf floorl frexpl
-    ldexpl logl round roundf roundl sinl sqrtl tanl trunc truncf truncl])
+    ldexpl logb logl round roundf roundl sinl sqrtl tanl trunc truncf truncl])
 ])
 
 AC_DEFUN([gl_MATH_MODULE_INDICATOR],
@@ -70,6 +70,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
   GNULIB_ISNAND=0;   AC_SUBST([GNULIB_ISNAND])
   GNULIB_ISNANL=0;   AC_SUBST([GNULIB_ISNANL])
   GNULIB_LDEXPL=0;   AC_SUBST([GNULIB_LDEXPL])
+  GNULIB_LOGB=0;     AC_SUBST([GNULIB_LOGB])
   GNULIB_LOGL=0;     AC_SUBST([GNULIB_LOGL])
   GNULIB_ROUND=0;    AC_SUBST([GNULIB_ROUND])
   GNULIB_ROUNDF=0;   AC_SUBST([GNULIB_ROUNDF])
@@ -101,6 +102,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
   HAVE_DECL_EXPL=1;            AC_SUBST([HAVE_DECL_EXPL])
   HAVE_DECL_FREXPL=1;          AC_SUBST([HAVE_DECL_FREXPL])
   HAVE_DECL_LDEXPL=1;          AC_SUBST([HAVE_DECL_LDEXPL])
+  HAVE_DECL_LOGB=1;            AC_SUBST([HAVE_DECL_LOGB])
   HAVE_DECL_LOGL=1;            AC_SUBST([HAVE_DECL_LOGL])
   HAVE_DECL_SINL=1;            AC_SUBST([HAVE_DECL_SINL])
   HAVE_DECL_SQRTL=1;           AC_SUBST([HAVE_DECL_SQRTL])
index 8816840..7c93afb 100644 (file)
@@ -2,12 +2,15 @@ Description:
 logb() function: get exponent.
 
 Files:
+m4/logb.m4
 m4/mathfunc.m4
 
 Depends-on:
+math
 
 configure.ac:
-gl_MATHFUNC([logb], [double], [(double)])
+gl_FUNC_LOGB
+gl_MATH_MODULE_INDICATOR([logb])
 
 Makefile.am:
 
index 0ffeff4..5921faf 100644 (file)
@@ -42,6 +42,7 @@ math.h: math.in.h $(WARN_ON_USE_H) $(ARG_NONNULL_H)
              -e 's|@''GNULIB_ISNAND''@|$(GNULIB_ISNAND)|g' \
              -e 's|@''GNULIB_ISNANL''@|$(GNULIB_ISNANL)|g' \
              -e 's|@''GNULIB_LDEXPL''@|$(GNULIB_LDEXPL)|g' \
+             -e 's|@''GNULIB_LOGB''@|$(GNULIB_LOGB)|g' \
              -e 's|@''GNULIB_LOGL''@|$(GNULIB_LOGL)|g' \
              -e 's|@''GNULIB_ROUND''@|$(GNULIB_ROUND)|g' \
              -e 's|@''GNULIB_ROUNDF''@|$(GNULIB_ROUNDF)|g' \
@@ -72,6 +73,7 @@ math.h: math.in.h $(WARN_ON_USE_H) $(ARG_NONNULL_H)
              -e 's|@''HAVE_DECL_EXPL''@|$(HAVE_DECL_EXPL)|g' \
              -e 's|@''HAVE_DECL_FREXPL''@|$(HAVE_DECL_FREXPL)|g' \
              -e 's|@''HAVE_DECL_LDEXPL''@|$(HAVE_DECL_LDEXPL)|g' \
+             -e 's|@''HAVE_DECL_LOGB''@|$(HAVE_DECL_LOGB)|g' \
              -e 's|@''HAVE_DECL_LOGL''@|$(HAVE_DECL_LOGL)|g' \
              -e 's|@''HAVE_DECL_SINL''@|$(HAVE_DECL_SINL)|g' \
              -e 's|@''HAVE_DECL_SQRTL''@|$(HAVE_DECL_SQRTL)|g' \