# HG changeset patch # User Bruno Haible # Date 1318105124 -7200 # Node ID c2fa2febdb1f7655dc225c119b74f2cae7ef4e0a # Parent e369ba8115ea85a13a7a13f080980224a9400024 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. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2011-10-08 Bruno Haible + 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 --- 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 @@ 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 --- /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 . */ + +#include + +/* Specification. */ +#include + +float +logf (float x) +{ + return (float) log ((double) x); +} diff --git a/lib/math.in.h b/lib/math.in.h --- a/lib/math.in.h +++ b/lib/math.in.h @@ -499,6 +499,21 @@ #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 --- /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 --- 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 @@ gl_WARN_ON_USE_PREPARE([[#include ]], [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 @@ 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 @@ 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 --- /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: + + +Link: +$(LOGF_LIBM) + +License: +LGPL + +Maintainer: +Bruno Haible diff --git a/modules/math b/modules/math --- a/modules/math +++ b/modules/math @@ -54,6 +54,7 @@ -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 @@ -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 --- a/tests/test-math-c++.cc +++ b/tests/test-math-c++.cc @@ -64,6 +64,9 @@ //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 *));