New module 'log10l'.
authorBruno Haible <bruno@clisp.org>
Sat, 25 Feb 2012 23:42:25 +0000 (00:42 +0100)
committerBruno Haible <bruno@clisp.org>
Sat, 25 Feb 2012 23:42:25 +0000 (00:42 +0100)
* lib/math.in.h (log10l): New declaration.
* lib/log10l.c: New file.
* m4/log10l.m4: New file.
* modules/log10l: New file.
* m4/math_h.m4 (gl_MATH_H): Test whether log10l is declared.
(gl_MATH_H_DEFAULTS): Initialize GNULIB_LOG10L, HAVE_LOG10L,
HAVE_DECL_LOG10L.
* modules/math (Makefile.am): Substitute GNULIB_LOG10L, HAVE_LOG10L,
HAVE_DECL_LOG10L.
* doc/posix-functions/log10l.texi: Mention the new module.

ChangeLog
doc/posix-functions/log10l.texi
lib/log10l.c [new file with mode: 0644]
lib/math.in.h
m4/log10l.m4 [new file with mode: 0644]
m4/math_h.m4
modules/log10l [new file with mode: 0644]
modules/math

index 1b6f2dd..f15d433 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
 2012-02-25  Bruno Haible  <bruno@clisp.org>
 
+       New module 'log10l'.
+       * lib/math.in.h (log10l): New declaration.
+       * lib/log10l.c: New file.
+       * m4/log10l.m4: New file.
+       * modules/log10l: New file.
+       * m4/math_h.m4 (gl_MATH_H): Test whether log10l is declared.
+       (gl_MATH_H_DEFAULTS): Initialize GNULIB_LOG10L, HAVE_LOG10L,
+       HAVE_DECL_LOG10L.
+       * modules/math (Makefile.am): Substitute GNULIB_LOG10L, HAVE_LOG10L,
+       HAVE_DECL_LOG10L.
+       * doc/posix-functions/log10l.texi: Mention the new module.
+
+2012-02-25  Bruno Haible  <bruno@clisp.org>
+
        fmodl, remainder*: Avoid wrong results due to rounding errors.
        * lib/fmodl.c (fmodl): Correct the result if it is not within the
        expected bounds.
index bce2722..1f29c1b 100644 (file)
@@ -4,15 +4,18 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/log10l.html}
 
-Gnulib module: ---
+Gnulib module: log10l
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This function is missing on some platforms:
+FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, HP-UX 11, IRIX 6.5, Solaris 9, Cygwin, Interix 3.5, BeOS.
+@item
+This function is not declared on some platforms:
+AIX 5.1.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
-@item
-This function is missing on some platforms:
-FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, HP-UX 11, IRIX 6.5, Solaris 9, Cygwin, Interix 3.5, BeOS.
 @end itemize
diff --git a/lib/log10l.c b/lib/log10l.c
new file mode 100644 (file)
index 0000000..ecaacb2
--- /dev/null
@@ -0,0 +1,42 @@
+/* Base 10 logarithmic function.
+   Copyright (C) 2012 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <math.h>
+
+#if HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
+
+long double
+log10l (long double x)
+{
+  return log10 (x);
+}
+
+#else
+
+/* 1 / log(10) */
+static const long double inv_log10 =
+  0.43429448190325182765112891891660508229439700580366656611445378316586464920887L;
+
+long double
+log10l (long double x)
+{
+  return logl (x) * inv_log10;
+}
+
+#endif
index 852cead..553d5d4 100644 (file)
@@ -849,6 +849,21 @@ _GL_WARN_ON_USE (log10f, "log10f is unportable - "
 # endif
 #endif
 
+#if @GNULIB_LOG10L@
+# if !@HAVE_LOG10L@ || !@HAVE_DECL_LOG10L@
+#  undef log10l
+_GL_FUNCDECL_SYS (log10l, long double, (long double x));
+# endif
+_GL_CXXALIAS_SYS (log10l, long double, (long double x));
+_GL_CXXALIASWARN (log10l);
+#elif defined GNULIB_POSIXCHECK
+# undef log10l
+# if HAVE_RAW_DECL_LOG10L
+_GL_WARN_ON_USE (log10l, "log10l is unportable - "
+                 "use gnulib module log10l for portability");
+# endif
+#endif
+
 
 #if @GNULIB_MODFF@
 # if !@HAVE_MODFF@
diff --git a/m4/log10l.m4 b/m4/log10l.m4
new file mode 100644 (file)
index 0000000..6d72b6a
--- /dev/null
@@ -0,0 +1,34 @@
+# log10l.m4 serial 1
+dnl Copyright (C) 2011-2012 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_LOG10L],
+[
+  AC_REQUIRE([gl_MATH_H_DEFAULTS])
+  AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
+  AC_REQUIRE([gl_FUNC_LOG10])
+
+  dnl Test whether log10l() is declared. On AIX 5.1 it is not declared.
+  AC_CHECK_DECL([log10l], , [HAVE_DECL_LOG10L=0], [[#include <math.h>]])
+
+  dnl Test whether log10l() exists. Assume that log10l(), if it exists, is
+  dnl defined in the same library as log10().
+  save_LIBS="$LIBS"
+  LIBS="$LIBS $LOG10_LIBM"
+  AC_CHECK_FUNCS([log10l])
+  LIBS="$save_LIBS"
+  if test $ac_cv_func_log10l = yes; then
+    LOG10L_LIBM="$LOG10_LIBM"
+  else
+    HAVE_LOG10L=0
+    if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
+      LOG10L_LIBM="$LOG10_LIBM"
+    else
+      AC_REQUIRE([gl_FUNC_LOGL])
+      LOG10L_LIBM="$LOGL_LIBM"
+    fi
+  fi
+  AC_SUBST([LOG10L_LIBM])
+])
index c3c5196..5fe792c 100644 (file)
@@ -1,4 +1,4 @@
-# math_h.m4 serial 62
+# math_h.m4 serial 63
 dnl Copyright (C) 2007-2012 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -42,7 +42,7 @@ AC_DEFUN([gl_MATH_H],
     [acosf acosl asinf asinl atanf atanl
      ceilf ceill copysign copysignf copysignl cosf cosl coshf
      expf expl fabsf fabsl floorf floorl fma fmaf fmal fmodf fmodl frexpf frexpl
-     ldexpf ldexpl logb logf logl log10f modff modfl powf
+     ldexpf ldexpl logb logf logl log10f log10l modff modfl powf
      remainder remainderf remainderl
      rint rintf rintl round roundf roundl sinf sinl sinhf sqrtf sqrtl
      tanf tanl tanhf trunc truncf truncl])
@@ -102,6 +102,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
   GNULIB_LOGF=0;       AC_SUBST([GNULIB_LOGF])
   GNULIB_LOGL=0;       AC_SUBST([GNULIB_LOGL])
   GNULIB_LOG10F=0;     AC_SUBST([GNULIB_LOG10F])
+  GNULIB_LOG10L=0;     AC_SUBST([GNULIB_LOG10L])
   GNULIB_MODFF=0;      AC_SUBST([GNULIB_MODFF])
   GNULIB_MODFL=0;      AC_SUBST([GNULIB_MODFL])
   GNULIB_POWF=0;       AC_SUBST([GNULIB_POWF])
@@ -157,6 +158,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
   HAVE_LOGF=1;                 AC_SUBST([HAVE_LOGF])
   HAVE_LOGL=1;                 AC_SUBST([HAVE_LOGL])
   HAVE_LOG10F=1;               AC_SUBST([HAVE_LOG10F])
+  HAVE_LOG10L=1;               AC_SUBST([HAVE_LOG10L])
   HAVE_MODFF=1;                AC_SUBST([HAVE_MODFF])
   HAVE_MODFL=1;                AC_SUBST([HAVE_MODFL])
   HAVE_POWF=1;                 AC_SUBST([HAVE_POWF])
@@ -187,6 +189,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
   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_LOG10L=1;          AC_SUBST([HAVE_DECL_LOG10L])
   HAVE_DECL_REMAINDER=1;       AC_SUBST([HAVE_DECL_REMAINDER])
   HAVE_DECL_ROUND=1;           AC_SUBST([HAVE_DECL_ROUND])
   HAVE_DECL_ROUNDF=1;          AC_SUBST([HAVE_DECL_ROUNDF])
diff --git a/modules/log10l b/modules/log10l
new file mode 100644 (file)
index 0000000..6e40021
--- /dev/null
@@ -0,0 +1,32 @@
+Description:
+log10l() function: base 10 logarithmic function.
+
+Files:
+lib/log10l.c
+m4/log10l.m4
+
+Depends-on:
+math
+log10           [test $HAVE_LOG10L = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1]
+logl            [test $HAVE_LOG10L = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0]
+
+configure.ac:
+gl_FUNC_LOG10L
+if test $HAVE_LOG10L = 0; then
+  AC_LIBOBJ([log10l])
+fi
+gl_MATH_MODULE_INDICATOR([log10l])
+
+Makefile.am:
+
+Include:
+<math.h>
+
+Link:
+$(LOG10L_LIBM)
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
index 1cef3b3..aa3011d 100644 (file)
@@ -71,6 +71,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
              -e 's/@''GNULIB_LOGF''@/$(GNULIB_LOGF)/g' \
              -e 's/@''GNULIB_LOGL''@/$(GNULIB_LOGL)/g' \
              -e 's/@''GNULIB_LOG10F''@/$(GNULIB_LOG10F)/g' \
+             -e 's/@''GNULIB_LOG10L''@/$(GNULIB_LOG10L)/g' \
              -e 's/@''GNULIB_MODFF''@/$(GNULIB_MODFF)/g' \
              -e 's/@''GNULIB_MODFL''@/$(GNULIB_MODFL)/g' \
              -e 's/@''GNULIB_POWF''@/$(GNULIB_POWF)/g' \
@@ -126,6 +127,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
              -e 's|@''HAVE_LOGF''@|$(HAVE_LOGF)|g' \
              -e 's|@''HAVE_LOGL''@|$(HAVE_LOGL)|g' \
              -e 's|@''HAVE_LOG10F''@|$(HAVE_LOG10F)|g' \
+             -e 's|@''HAVE_LOG10L''@|$(HAVE_LOG10L)|g' \
              -e 's|@''HAVE_MODFF''@|$(HAVE_MODFF)|g' \
              -e 's|@''HAVE_MODFL''@|$(HAVE_MODFL)|g' \
              -e 's|@''HAVE_POWF''@|$(HAVE_POWF)|g' \
@@ -156,6 +158,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
              -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_LOG10L''@|$(HAVE_DECL_LOG10L)|g' \
              -e 's|@''HAVE_DECL_REMAINDER''@|$(HAVE_DECL_REMAINDER)|g' \
              -e 's|@''HAVE_DECL_ROUND''@|$(HAVE_DECL_ROUND)|g' \
              -e 's|@''HAVE_DECL_ROUNDF''@|$(HAVE_DECL_ROUNDF)|g' \