summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2011-10-08 22:18:44 +0200
committerBruno Haible <bruno@clisp.org>2011-10-08 22:18:44 +0200
commit54a8ff340a865f5409072565e5b199c4451ea60e (patch)
tree723ff6eb43d48c0623741123f99f876d3b466b91
parent5ee056682b93c9282a02587c825b46eb1e64ee0d (diff)
downloadgnulib-54a8ff340a865f5409072565e5b199c4451ea60e.tar.gz
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.
-rw-r--r--ChangeLog11
-rw-r--r--doc/posix-functions/logf.texi10
-rw-r--r--lib/logf.c26
-rw-r--r--lib/math.in.h15
-rw-r--r--m4/logf.m425
-rw-r--r--m4/math_h.m46
-rw-r--r--modules/logf31
-rw-r--r--modules/math2
-rw-r--r--tests/test-math-c++.cc3
9 files changed, 122 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 6cec0e487a..4b97ae0985 100644
--- 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.
diff --git a/doc/posix-functions/logf.texi b/doc/posix-functions/logf.texi
index 3951afff12..a4de780b76 100644
--- a/doc/posix-functions/logf.texi
+++ b/doc/posix-functions/logf.texi
@@ -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
index 0000000000..684e9f31d6
--- /dev/null
+++ b/lib/logf.c
@@ -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);
+}
diff --git a/lib/math.in.h b/lib/math.in.h
index 3055b91e50..0d19c7fc90 100644
--- a/lib/math.in.h
+++ b/lib/math.in.h
@@ -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
index 0000000000..f4173f0b08
--- /dev/null
+++ b/m4/logf.m4
@@ -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])
+])
diff --git a/m4/math_h.m4 b/m4/math_h.m4
index c307291004..9afd85f60b 100644
--- a/m4/math_h.m4
+++ b/m4/math_h.m4
@@ -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
index 0000000000..a2e3f256b5
--- /dev/null
+++ b/modules/logf
@@ -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
diff --git a/modules/math b/modules/math
index 6e9be85628..ee8ae60a4e 100644
--- a/modules/math
+++ b/modules/math
@@ -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' \
diff --git a/tests/test-math-c++.cc b/tests/test-math-c++.cc
index 9461fab421..6a59450e75 100644
--- a/tests/test-math-c++.cc
+++ b/tests/test-math-c++.cc
@@ -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 *));