Mercurial > hg > octave-lyh > gnulib-hg
changeset 15866:215da3b412e0
New module 'log10f'.
* lib/math.in.h (log10f): New declaration.
* lib/log10f.c: New file.
* m4/log10f.m4: New file.
* m4/math_h.m4 (gl_MATH_H): Test whether log10f is declared.
(gl_MATH_H_DEFAULTS): Initialize GNULIB_LOG10F, HAVE_LOG10F.
* modules/math (Makefile.am): Substitute GNULIB_LOG10F, HAVE_LOG10F.
* modules/log10f: New file.
* tests/test-math-c++.cc: Check the declaration of log10f.
* doc/posix-functions/log10f.texi: Mention the new module.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sat, 08 Oct 2011 22:32:31 +0200 |
parents | 570755d1838e |
children | 1246d926298d |
files | ChangeLog doc/posix-functions/log10f.texi lib/log10f.c lib/math.in.h m4/log10f.m4 m4/math_h.m4 modules/log10f modules/math tests/test-math-c++.cc |
diffstat | 9 files changed, 124 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 'log10f'. + * lib/math.in.h (log10f): New declaration. + * lib/log10f.c: New file. + * m4/log10f.m4: New file. + * m4/math_h.m4 (gl_MATH_H): Test whether log10f is declared. + (gl_MATH_H_DEFAULTS): Initialize GNULIB_LOG10F, HAVE_LOG10F. + * modules/math (Makefile.am): Substitute GNULIB_LOG10F, HAVE_LOG10F. + * modules/log10f: New file. + * tests/test-math-c++.cc: Check the declaration of log10f. + * doc/posix-functions/log10f.texi: Mention the new module. + log10: Use a .m4 file. * m4/log10.m4: New file. * modules/log10 (Files): Add it.
--- a/doc/posix-functions/log10f.texi +++ b/doc/posix-functions/log10f.texi @@ -4,14 +4,10 @@ POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/log10f.html} -Gnulib module: --- +Gnulib module: log10f 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/log10f.c @@ -0,0 +1,26 @@ +/* Base 10 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 +log10f (float x) +{ + return (float) log10 ((double) x); +}
--- a/lib/math.in.h +++ b/lib/math.in.h @@ -529,6 +529,22 @@ #endif +#if @GNULIB_LOG10F@ +# if !@HAVE_LOG10F@ +# undef log10f +_GL_FUNCDECL_SYS (log10f, float, (float x)); +# endif +_GL_CXXALIAS_SYS (log10f, float, (float x)); +_GL_CXXALIASWARN (log10f); +#elif defined GNULIB_POSIXCHECK +# undef log10f +# if HAVE_RAW_DECL_LOG10F +_GL_WARN_ON_USE (log10f, "log10f is unportable - " + "use gnulib module log10f for portability"); +# endif +#endif + + #if @GNULIB_MODFF@ # if !@HAVE_MODFF@ # undef modff
new file mode 100644 --- /dev/null +++ b/m4/log10f.m4 @@ -0,0 +1,25 @@ +# log10f.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_LOG10F], +[ + AC_REQUIRE([gl_MATH_H_DEFAULTS]) + AC_REQUIRE([gl_FUNC_LOG10]) + + dnl Test whether log10f() exists. Assume that log10f(), if it exists, is + dnl defined in the same library as log10(). + save_LIBS="$LIBS" + LIBS="$LIBS $LOG10_LIBM" + AC_CHECK_FUNCS([log10f]) + LIBS="$save_LIBS" + if test $ac_cv_func_log10f = yes; then + LOG10F_LIBM="$LOG10_LIBM" + else + HAVE_LOG10F=0 + LOG10F_LIBM="$LOG10_LIBM" + fi + AC_SUBST([LOG10F_LIBM]) +])
--- a/m4/math_h.m4 +++ b/m4/math_h.m4 @@ -1,4 +1,4 @@ -# math_h.m4 serial 34 +# math_h.m4 serial 35 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,8 @@ 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 logf logl modff round roundf roundl sinl sqrtf sqrtl + ldexpf ldexpl logb logf logl log10f modff + round roundf roundl sinl sqrtf sqrtl tanl trunc truncf truncl]) ]) @@ -84,6 +85,7 @@ GNULIB_LOGB=0; AC_SUBST([GNULIB_LOGB]) GNULIB_LOGF=0; AC_SUBST([GNULIB_LOGF]) GNULIB_LOGL=0; AC_SUBST([GNULIB_LOGL]) + GNULIB_LOG10F=0; AC_SUBST([GNULIB_LOG10F]) GNULIB_MODFF=0; AC_SUBST([GNULIB_MODFF]) GNULIB_ROUND=0; AC_SUBST([GNULIB_ROUND]) GNULIB_ROUNDF=0; AC_SUBST([GNULIB_ROUNDF]) @@ -112,6 +114,7 @@ HAVE_LDEXPF=1; AC_SUBST([HAVE_LDEXPF]) HAVE_LOGF=1; AC_SUBST([HAVE_LOGF]) HAVE_LOGL=1; AC_SUBST([HAVE_LOGL]) + HAVE_LOG10F=1; AC_SUBST([HAVE_LOG10F]) HAVE_MODFF=1; AC_SUBST([HAVE_MODFF]) HAVE_SINL=1; AC_SUBST([HAVE_SINL]) HAVE_SQRTF=1; AC_SUBST([HAVE_SQRTF])
new file mode 100644 --- /dev/null +++ b/modules/log10f @@ -0,0 +1,31 @@ +Description: +log10f() function: base 10 logarithmic function. + +Files: +lib/log10f.c +m4/log10f.m4 + +Depends-on: +math +log10 [test $HAVE_LOG10F = 0] + +configure.ac: +gl_FUNC_LOG10F +if test $HAVE_LOG10F = 0; then + AC_LIBOBJ([log10f]) +fi +gl_MATH_MODULE_INDICATOR([log10f]) + +Makefile.am: + +Include: +<math.h> + +Link: +$(LOG10F_LIBM) + +License: +LGPL + +Maintainer: +Bruno Haible
--- a/modules/math +++ b/modules/math @@ -56,6 +56,7 @@ -e 's/@''GNULIB_LOGB''@/$(GNULIB_LOGB)/g' \ -e 's/@''GNULIB_LOGF''@/$(GNULIB_LOGF)/g' \ -e 's/@''GNULIB_LOGL''@/$(GNULIB_LOGL)/g' \ + -e 's/@''GNULIB_LOG10F''@/$(GNULIB_LOG10F)/g' \ -e 's/@''GNULIB_MODFF''@/$(GNULIB_MODFF)/g' \ -e 's/@''GNULIB_ROUND''@/$(GNULIB_ROUND)/g' \ -e 's/@''GNULIB_ROUNDF''@/$(GNULIB_ROUNDF)/g' \ @@ -84,6 +85,7 @@ -e 's|@''HAVE_LDEXPF''@|$(HAVE_LDEXPF)|g' \ -e 's|@''HAVE_LOGF''@|$(HAVE_LOGF)|g' \ -e 's|@''HAVE_LOGL''@|$(HAVE_LOGL)|g' \ + -e 's|@''HAVE_LOG10F''@|$(HAVE_LOG10F)|g' \ -e 's|@''HAVE_MODFF''@|$(HAVE_MODFF)|g' \ -e 's|@''HAVE_SINL''@|$(HAVE_SINL)|g' \ -e 's|@''HAVE_SQRTF''@|$(HAVE_SQRTF)|g' \
--- a/tests/test-math-c++.cc +++ b/tests/test-math-c++.cc @@ -68,6 +68,9 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::logf, float, (float)); #endif //SIGNATURE_CHECK (GNULIB_NAMESPACE::log, double, (double)); +#if GNULIB_TEST_LOG10F +SIGNATURE_CHECK (GNULIB_NAMESPACE::log10f, float, (float)); +#endif #if GNULIB_TEST_MODFF SIGNATURE_CHECK (GNULIB_NAMESPACE::modff, float, (float, float *)); #endif