New module 'logf'.
authorBruno Haible <bruno@clisp.org>
Sat, 8 Oct 2011 20:18:44 +0000 (22:18 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 8 Oct 2011 20:18:44 +0000 (22:18 +0200)
* lib/math.in.h (logf): New declaration.
* lib/logf.c: New file.
* m4/logf.m4: New file.
* m4/math_h.m4 (gl_MATH_H): Test whether logf is declared.
(gl_MATH_H_DEFAULTS): Initialize GNULIB_LOGF, HAVE_LOGF.
* modules/math (Makefile.am): Substitute GNULIB_LOGF, HAVE_LOGF.
* modules/logf: New file.
* tests/test-math-c++.cc: Check the declaration of logf.
* doc/posix-functions/logf.texi: Mention the new module.

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

index 6cec0e4..4b97ae0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2011-10-08  Bruno Haible  <bruno@clisp.org>
 
+       New module 'logf'.
+       * lib/math.in.h (logf): New declaration.
+       * lib/logf.c: New file.
+       * m4/logf.m4: New file.
+       * m4/math_h.m4 (gl_MATH_H): Test whether logf is declared.
+       (gl_MATH_H_DEFAULTS): Initialize GNULIB_LOGF, HAVE_LOGF.
+       * modules/math (Makefile.am): Substitute GNULIB_LOGF, HAVE_LOGF.
+       * modules/logf: New file.
+       * tests/test-math-c++.cc: Check the declaration of logf.
+       * doc/posix-functions/logf.texi: Mention the new module.
+
        log: Use a .m4 file.
        * m4/log.m4: New file.
        * modules/log (Files): Add it.
index 3951aff..a4de780 100644 (file)
@@ -4,14 +4,10 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/logf.html}
 
-Gnulib module: ---
+Gnulib module: logf
 
 Portability problems fixed by Gnulib:
 @itemize
-@end itemize
-
-Portability problems not fixed by Gnulib:
-@itemize
 @item
 This function is missing on some platforms:
 Minix 3.1.8, AIX 5.1, Solaris 9.
@@ -19,3 +15,7 @@ Minix 3.1.8, AIX 5.1, Solaris 9.
 This function is only defined as a macro with arguments on some platforms:
 MSVC 9.
 @end itemize
+
+Portability problems not fixed by Gnulib:
+@itemize
+@end itemize
diff --git a/lib/logf.c b/lib/logf.c
new file mode 100644 (file)
index 0000000..684e9f3
--- /dev/null
@@ -0,0 +1,26 @@
+/* Natural logarithmic function.
+   Copyright (C) 2011 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>
+
+float
+logf (float x)
+{
+  return (float) log ((double) x);
+}
index 3055b91..0d19c7f 100644 (file)
@@ -499,6 +499,21 @@ _GL_WARN_ON_USE (logb, "logb is unportable - "
 #endif
 
 
+#if @GNULIB_LOGF@
+# if !@HAVE_LOGF@
+#  undef logf
+_GL_FUNCDECL_SYS (logf, float, (float x));
+# endif
+_GL_CXXALIAS_SYS (logf, float, (float x));
+_GL_CXXALIASWARN (logf);
+#elif defined GNULIB_POSIXCHECK
+# undef logf
+# if HAVE_RAW_DECL_LOGF
+_GL_WARN_ON_USE (logf, "logf is unportable - "
+                 "use gnulib module logf for portability");
+# endif
+#endif
+
 #if @GNULIB_LOGL@
 # if !@HAVE_LOGL@ || !@HAVE_DECL_LOGL@
 _GL_FUNCDECL_SYS (logl, long double, (long double x));
diff --git a/m4/logf.m4 b/m4/logf.m4
new file mode 100644 (file)
index 0000000..f4173f0
--- /dev/null
@@ -0,0 +1,25 @@
+# logf.m4 serial 1
+dnl Copyright (C) 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_LOGF],
+[
+  AC_REQUIRE([gl_MATH_H_DEFAULTS])
+  AC_REQUIRE([gl_FUNC_LOG])
+
+  dnl Test whether logf() exists. Assume that logf(), if it exists, is
+  dnl defined in the same library as log().
+  save_LIBS="$LIBS"
+  LIBS="$LIBS $LOG_LIBM"
+  AC_CHECK_FUNCS([logf])
+  LIBS="$save_LIBS"
+  if test $ac_cv_func_logf = yes; then
+    LOGF_LIBM="$LOG_LIBM"
+  else
+    HAVE_LOGF=0
+    LOGF_LIBM="$LOG_LIBM"
+  fi
+  AC_SUBST([LOGF_LIBM])
+])
index c307291..9afd85f 100644 (file)
@@ -1,4 +1,4 @@
-# math_h.m4 serial 33
+# math_h.m4 serial 34
 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,
@@ -41,7 +41,7 @@ AC_DEFUN([gl_MATH_H],
   gl_WARN_ON_USE_PREPARE([[#include <math.h>]],
     [acosl asinl atanl ceilf ceill cosl expf expl fabsf floorf floorl fmodf
      frexpf frexpl
-     ldexpf ldexpl logb logl modff round roundf roundl sinl sqrtf sqrtl
+     ldexpf ldexpl logb logf logl modff round roundf roundl sinl sqrtf sqrtl
      tanl trunc truncf truncl])
 ])
 
@@ -82,6 +82,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
   GNULIB_LDEXPF=0;   AC_SUBST([GNULIB_LDEXPF])
   GNULIB_LDEXPL=0;   AC_SUBST([GNULIB_LDEXPL])
   GNULIB_LOGB=0;     AC_SUBST([GNULIB_LOGB])
+  GNULIB_LOGF=0;     AC_SUBST([GNULIB_LOGF])
   GNULIB_LOGL=0;     AC_SUBST([GNULIB_LOGL])
   GNULIB_MODFF=0;    AC_SUBST([GNULIB_MODFF])
   GNULIB_ROUND=0;    AC_SUBST([GNULIB_ROUND])
@@ -109,6 +110,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
   HAVE_ISNAND=1;               AC_SUBST([HAVE_ISNAND])
   HAVE_ISNANL=1;               AC_SUBST([HAVE_ISNANL])
   HAVE_LDEXPF=1;               AC_SUBST([HAVE_LDEXPF])
+  HAVE_LOGF=1;                 AC_SUBST([HAVE_LOGF])
   HAVE_LOGL=1;                 AC_SUBST([HAVE_LOGL])
   HAVE_MODFF=1;                AC_SUBST([HAVE_MODFF])
   HAVE_SINL=1;                 AC_SUBST([HAVE_SINL])
diff --git a/modules/logf b/modules/logf
new file mode 100644 (file)
index 0000000..a2e3f25
--- /dev/null
@@ -0,0 +1,31 @@
+Description:
+logf() function: natural logarithmic function.
+
+Files:
+lib/logf.c
+m4/logf.m4
+
+Depends-on:
+math
+log             [test $HAVE_LOGF = 0]
+
+configure.ac:
+gl_FUNC_LOGF
+if test $HAVE_LOGF = 0; then
+  AC_LIBOBJ([logf])
+fi
+gl_MATH_MODULE_INDICATOR([logf])
+
+Makefile.am:
+
+Include:
+<math.h>
+
+Link:
+$(LOGF_LIBM)
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
index 6e9be85..ee8ae60 100644 (file)
@@ -54,6 +54,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
              -e 's/@''GNULIB_LDEXPF''@/$(GNULIB_LDEXPF)/g' \
              -e 's/@''GNULIB_LDEXPL''@/$(GNULIB_LDEXPL)/g' \
              -e 's/@''GNULIB_LOGB''@/$(GNULIB_LOGB)/g' \
+             -e 's/@''GNULIB_LOGF''@/$(GNULIB_LOGF)/g' \
              -e 's/@''GNULIB_LOGL''@/$(GNULIB_LOGL)/g' \
              -e 's/@''GNULIB_MODFF''@/$(GNULIB_MODFF)/g' \
              -e 's/@''GNULIB_ROUND''@/$(GNULIB_ROUND)/g' \
@@ -81,6 +82,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
              -e 's|@''HAVE_ISNAND''@|$(HAVE_ISNAND)|g' \
              -e 's|@''HAVE_ISNANL''@|$(HAVE_ISNANL)|g' \
              -e 's|@''HAVE_LDEXPF''@|$(HAVE_LDEXPF)|g' \
+             -e 's|@''HAVE_LOGF''@|$(HAVE_LOGF)|g' \
              -e 's|@''HAVE_LOGL''@|$(HAVE_LOGL)|g' \
              -e 's|@''HAVE_MODFF''@|$(HAVE_MODFF)|g' \
              -e 's|@''HAVE_SINL''@|$(HAVE_SINL)|g' \
index 9461fab..6a59450 100644 (file)
@@ -64,6 +64,9 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::ldexpf, float, (float, int));
 //SIGNATURE_CHECK (GNULIB_NAMESPACE::log10, double, (double));
 //SIGNATURE_CHECK (GNULIB_NAMESPACE::log1p, double, (double));
 //SIGNATURE_CHECK (GNULIB_NAMESPACE::logb, double, (double));
+#if GNULIB_TEST_LOGF
+SIGNATURE_CHECK (GNULIB_NAMESPACE::logf, float, (float));
+#endif
 //SIGNATURE_CHECK (GNULIB_NAMESPACE::log, double, (double));
 #if GNULIB_TEST_MODFF
 SIGNATURE_CHECK (GNULIB_NAMESPACE::modff, float, (float, float *));