Mercurial > hg > octave-lyh > gnulib-hg
changeset 15863:c2fa2febdb1f
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.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sat, 08 Oct 2011 22:18:44 +0200 |
parents | e369ba8115ea |
children | 06e0834eb24e |
files | ChangeLog doc/posix-functions/logf.texi lib/logf.c lib/math.in.h m4/logf.m4 m4/math_h.m4 modules/logf modules/math tests/test-math-c++.cc |
diffstat | 9 files changed, 122 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- 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.
--- 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
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 <http://www.gnu.org/licenses/>. */ + +#include <config.h> + +/* Specification. */ +#include <math.h> + +float +logf (float x) +{ + return (float) log ((double) x); +}
--- 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));
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]) +])
--- 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 <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 @@ 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])
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: +<math.h> + +Link: +$(LOGF_LIBM) + +License: +LGPL + +Maintainer: +Bruno Haible
--- 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' \
--- 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 *));