From: Bruno Haible Date: Sat, 8 Oct 2011 20:32:31 +0000 (+0200) Subject: New module 'log10f'. X-Git-Tag: v0.1~1660 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=bb09133116a45861827711f5e8faf2c82b98c552;p=gnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index d8e474390..13c600618 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2011-10-08 Bruno Haible + 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. diff --git a/doc/posix-functions/log10f.texi b/doc/posix-functions/log10f.texi index 63c8fae69..f63509bd4 100644 --- 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 @@ 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/log10f.c b/lib/log10f.c new file mode 100644 index 000000000..ad50c535d --- /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 . */ + +#include + +/* Specification. */ +#include + +float +log10f (float x) +{ + return (float) log10 ((double) x); +} diff --git a/lib/math.in.h b/lib/math.in.h index 0d19c7fc9..4a868559a 100644 --- a/lib/math.in.h +++ b/lib/math.in.h @@ -529,6 +529,22 @@ _GL_WARN_ON_USE (logl, "logl is unportable - " #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 diff --git a/m4/log10f.m4 b/m4/log10f.m4 new file mode 100644 index 000000000..ab29a0fa6 --- /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]) +]) diff --git a/m4/math_h.m4 b/m4/math_h.m4 index 9afd85f60..a8044f195 100644 --- 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 @@ AC_DEFUN([gl_MATH_H], gl_WARN_ON_USE_PREPARE([[#include ]], [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 @@ AC_DEFUN([gl_MATH_H_DEFAULTS], 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 @@ AC_DEFUN([gl_MATH_H_DEFAULTS], 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]) diff --git a/modules/log10f b/modules/log10f new file mode 100644 index 000000000..d6c5b8b1c --- /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: + + +Link: +$(LOG10F_LIBM) + +License: +LGPL + +Maintainer: +Bruno Haible diff --git a/modules/math b/modules/math index ee8ae60a4..9f2b22946 100644 --- a/modules/math +++ b/modules/math @@ -56,6 +56,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $( -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 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $( -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' \ diff --git a/tests/test-math-c++.cc b/tests/test-math-c++.cc index 6a59450e7..67d7f71c0 100644 --- a/tests/test-math-c++.cc +++ b/tests/test-math-c++.cc @@ -68,6 +68,9 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::ldexpf, float, (float, int)); 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