Mercurial > hg > octave-lyh > gnulib-hg
changeset 16657:86d5719ce2ff
New module 'log1pf'.
* lib/math.in.h (log1pf): New declaration.
* lib/log1pf.c: New file.
* m4/log1pf.m4: New file.
* m4/math_h.m4 (gl_MATH_H): Test whether log1pf is declared.
(gl_MATH_H_DEFAULTS): Initialize GNULIB_LOG1PF, HAVE_LOG1PF,
REPLACE_LOG1PF.
* modules/math (Makefile.am): Substitute GNULIB_LOG1PF, HAVE_LOG1PF,
REPLACE_LOG1PF.
* modules/log1pf: New file.
* tests/test-math-c++.cc: Check the declaration of log1pf.
* doc/posix-functions/log1pf.texi: Mention the new module.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sat, 10 Mar 2012 22:28:49 +0100 |
parents | a7869cc6ce1f |
children | 36c3013ca332 |
files | ChangeLog doc/posix-functions/log1pf.texi lib/log1pf.c lib/math.in.h m4/log1pf.m4 m4/math_h.m4 modules/log1pf modules/math tests/test-math-c++.cc |
diffstat | 9 files changed, 187 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2012-03-10 Bruno Haible <bruno@clisp.org> + + New module 'log1pf'. + * lib/math.in.h (log1pf): New declaration. + * lib/log1pf.c: New file. + * m4/log1pf.m4: New file. + * m4/math_h.m4 (gl_MATH_H): Test whether log1pf is declared. + (gl_MATH_H_DEFAULTS): Initialize GNULIB_LOG1PF, HAVE_LOG1PF, + REPLACE_LOG1PF. + * modules/math (Makefile.am): Substitute GNULIB_LOG1PF, HAVE_LOG1PF, + REPLACE_LOG1PF. + * modules/log1pf: New file. + * tests/test-math-c++.cc: Check the declaration of log1pf. + * doc/posix-functions/log1pf.texi: Mention the new module. + 2012-03-10 Bruno Haible <bruno@clisp.org> log1p tests: More tests.
--- a/doc/posix-functions/log1pf.texi +++ b/doc/posix-functions/log1pf.texi @@ -4,15 +4,18 @@ POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/log1pf.html} -Gnulib module: --- +Gnulib module: log1pf Portability problems fixed by Gnulib: @itemize +@item +This function is missing on some platforms: +Minix 3.1.8, AIX 5.1, HP-UX 11, Solaris 9, MSVC 9. +@item +This function returns a wrong value for the argument -1.0f on some platforms: +IRIX 6.5. @end itemize Portability problems not fixed by Gnulib: @itemize -@item -This function is missing on some platforms: -Minix 3.1.8, AIX 5.1, HP-UX 11, Solaris 9, MSVC 9. @end itemize
new file mode 100644 --- /dev/null +++ b/lib/log1pf.c @@ -0,0 +1,26 @@ +/* Natural logarithm of 1 plus argument. + Copyright (C) 2012 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 +log1pf (float x) +{ + return (float) log1p ((double) x); +}
--- a/lib/math.in.h +++ b/lib/math.in.h @@ -1221,6 +1221,29 @@ #endif +#if @GNULIB_LOG1PF@ +# if @REPLACE_LOG1PF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef log1pf +# define log1pf rpl_log1pf +# endif +_GL_FUNCDECL_RPL (log1pf, float, (float x)); +_GL_CXXALIAS_RPL (log1pf, float, (float x)); +# else +# if !@HAVE_LOG1PF@ +_GL_FUNCDECL_SYS (log1pf, float, (float x)); +# endif +_GL_CXXALIAS_SYS (log1pf, float, (float x)); +# endif +_GL_CXXALIASWARN (log1pf); +#elif defined GNULIB_POSIXCHECK +# undef log1pf +# if HAVE_RAW_DECL_LOG1PF +_GL_WARN_ON_USE (log1pf, "log1pf is unportable - " + "use gnulib module log1pf for portability"); +# endif +#endif + #if @GNULIB_LOG1P@ # if !@HAVE_LOG1P@ _GL_FUNCDECL_SYS (log1p, double, (double x));
new file mode 100644 --- /dev/null +++ b/m4/log1pf.m4 @@ -0,0 +1,72 @@ +# log1pf.m4 serial 1 +dnl Copyright (C) 2012 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_LOG1PF], +[ + AC_REQUIRE([gl_MATH_H_DEFAULTS]) + AC_REQUIRE([gl_FUNC_LOG1P]) + + dnl Persuade glibc <math.h> to declare log1pf(). + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + + dnl Test whether log1pf() exists. Assume that log1pf(), if it exists, is + dnl defined in the same library as log1p(). + save_LIBS="$LIBS" + LIBS="$LIBS $LOG1P_LIBM" + AC_CHECK_FUNCS([log1pf]) + LIBS="$save_LIBS" + if test $ac_cv_func_log1pf = yes; then + LOG1PF_LIBM="$LOG1P_LIBM" + + save_LIBS="$LIBS" + LIBS="$LIBS $LOG1PF_LIBM" + gl_FUNC_LOG1PF_WORKS + LIBS="$save_LIBS" + case "$gl_cv_func_log1pf_works" in + *yes) ;; + *) REPLACE_LOG1PF=1 ;; + esac + else + HAVE_LOG1PF=0 + fi + if test $HAVE_LOG1PF = 0 || test $REPLACE_LOG1PF = 1; then + dnl Find libraries needed to link lib/log1pf.c. + LOG1PF_LIBM="$LOG1P_LIBM" + fi + AC_SUBST([LOG1PF_LIBM]) +]) + +dnl Test whether log1pf() works. +dnl On IRIX 6.5, log1pf(-1.0f) returns +Infinity instead of -Infinity. +AC_DEFUN([gl_FUNC_LOG1PF_WORKS], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether log1pf works], [gl_cv_func_log1pf_works], + [ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include <math.h> +volatile float x; +float y; +int main () +{ + x = -1.0f; + y = log1pf (x); + if (!(y + y == y && y < 0.0f)) + return 1; + return 0; +} +]])], + [gl_cv_func_log1pf_works=yes], + [gl_cv_func_log1pf_works=no], + [case "$host_os" in + irix*) gl_cv_func_log1pf_works="guessing no";; + *) gl_cv_func_log1pf_works="guessing yes";; + esac + ]) + ]) +])
--- a/m4/math_h.m4 +++ b/m4/math_h.m4 @@ -1,4 +1,4 @@ -# math_h.m4 serial 96 +# math_h.m4 serial 97 dnl Copyright (C) 2007-2012 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -44,7 +44,8 @@ expf expl exp2 exp2f exp2l expm1 expm1f expm1l fabsf fabsl floorf floorl fma fmaf fmal fmod fmodf fmodl frexpf frexpl hypotf hypotl - ldexpf ldexpl logb log logf logl log10f log10l log1p modf modff modfl powf + ldexpf ldexpl logb log logf logl log10f log10l log1p log1pf + modf modff modfl powf remainder remainderf remainderl rint rintf rintl round roundf roundl sinf sinl sinhf sqrtf sqrtl tanf tanl tanhf trunc truncf truncl]) @@ -120,6 +121,7 @@ GNULIB_LOG10F=0; AC_SUBST([GNULIB_LOG10F]) GNULIB_LOG10L=0; AC_SUBST([GNULIB_LOG10L]) GNULIB_LOG1P=0; AC_SUBST([GNULIB_LOG1P]) + GNULIB_LOG1PF=0; AC_SUBST([GNULIB_LOG1PF]) GNULIB_MODF=0; AC_SUBST([GNULIB_MODF]) GNULIB_MODFF=0; AC_SUBST([GNULIB_MODFF]) GNULIB_MODFL=0; AC_SUBST([GNULIB_MODFL]) @@ -184,6 +186,7 @@ HAVE_LOG10F=1; AC_SUBST([HAVE_LOG10F]) HAVE_LOG10L=1; AC_SUBST([HAVE_LOG10L]) HAVE_LOG1P=1; AC_SUBST([HAVE_LOG1P]) + HAVE_LOG1PF=1; AC_SUBST([HAVE_LOG1PF]) HAVE_MODFF=1; AC_SUBST([HAVE_MODFF]) HAVE_MODFL=1; AC_SUBST([HAVE_MODFL]) HAVE_POWF=1; AC_SUBST([HAVE_POWF]) @@ -265,6 +268,7 @@ REPLACE_LOG=0; AC_SUBST([REPLACE_LOG]) REPLACE_LOGF=0; AC_SUBST([REPLACE_LOGF]) REPLACE_LOGL=0; AC_SUBST([REPLACE_LOGL]) + REPLACE_LOG1PF=0; AC_SUBST([REPLACE_LOG1PF]) REPLACE_MODF=0; AC_SUBST([REPLACE_MODF]) REPLACE_MODFF=0; AC_SUBST([REPLACE_MODFF]) REPLACE_MODFL=0; AC_SUBST([REPLACE_MODFL])
new file mode 100644 --- /dev/null +++ b/modules/log1pf @@ -0,0 +1,32 @@ +Description: +log1pf() function: natural logarithm of 1 plus argument. + +Files: +lib/log1pf.c +m4/log1pf.m4 + +Depends-on: +math +extensions +log1p [test $HAVE_LOG1PF = 0 || test $REPLACE_LOG1PF = 1] + +configure.ac: +gl_FUNC_LOG1PF +if test $HAVE_LOG1PF = 0 || test $REPLACE_LOG1PF = 1; then + AC_LIBOBJ([log1pf]) +fi +gl_MATH_MODULE_INDICATOR([log1pf]) + +Makefile.am: + +Include: +<math.h> + +Link: +$(LOG1PF_LIBM) + +License: +LGPL + +Maintainer: +Bruno Haible
--- a/modules/math +++ b/modules/math @@ -87,6 +87,7 @@ -e 's/@''GNULIB_LOG10F''@/$(GNULIB_LOG10F)/g' \ -e 's/@''GNULIB_LOG10L''@/$(GNULIB_LOG10L)/g' \ -e 's/@''GNULIB_LOG1P''@/$(GNULIB_LOG1P)/g' \ + -e 's/@''GNULIB_LOG1PF''@/$(GNULIB_LOG1PF)/g' \ -e 's/@''GNULIB_MODF''@/$(GNULIB_MODF)/g' \ -e 's/@''GNULIB_MODFF''@/$(GNULIB_MODFF)/g' \ -e 's/@''GNULIB_MODFL''@/$(GNULIB_MODFL)/g' \ @@ -151,6 +152,7 @@ -e 's|@''HAVE_LOG10F''@|$(HAVE_LOG10F)|g' \ -e 's|@''HAVE_LOG10L''@|$(HAVE_LOG10L)|g' \ -e 's|@''HAVE_LOG1P''@|$(HAVE_LOG1P)|g' \ + -e 's|@''HAVE_LOG1PF''@|$(HAVE_LOG1PF)|g' \ -e 's|@''HAVE_MODFF''@|$(HAVE_MODFF)|g' \ -e 's|@''HAVE_MODFL''@|$(HAVE_MODFL)|g' \ -e 's|@''HAVE_POWF''@|$(HAVE_POWF)|g' \ @@ -234,6 +236,7 @@ -e 's|@''REPLACE_LOG''@|$(REPLACE_LOG)|g' \ -e 's|@''REPLACE_LOGF''@|$(REPLACE_LOGF)|g' \ -e 's|@''REPLACE_LOGL''@|$(REPLACE_LOGL)|g' \ + -e 's|@''REPLACE_LOG1PF''@|$(REPLACE_LOG1PF)|g' \ -e 's|@''REPLACE_MODF''@|$(REPLACE_MODF)|g' \ -e 's|@''REPLACE_MODFF''@|$(REPLACE_MODFF)|g' \ -e 's|@''REPLACE_MODFL''@|$(REPLACE_MODFL)|g' \
--- a/tests/test-math-c++.cc +++ b/tests/test-math-c++.cc @@ -215,6 +215,9 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::log10l, long double, (long double)); #endif +#if GNULIB_TEST_LOG1PF +SIGNATURE_CHECK (GNULIB_NAMESPACE::log1pf, float, (float)); +#endif #if GNULIB_TEST_LOG1P SIGNATURE_CHECK (GNULIB_NAMESPACE::log1p, double, (double)); #endif