Another math function missing on many platforms is log10l(). This module implements it.
2012-02-25 Bruno Haible <[email protected]> New module 'log10l'. * lib/math.in.h (log10l): New declaration. * lib/log10l.c: New file. * m4/log10l.m4: New file. * modules/log10l: New file. * m4/math_h.m4 (gl_MATH_H): Test whether log10l is declared. (gl_MATH_H_DEFAULTS): Initialize GNULIB_LOG10L, HAVE_LOG10L, HAVE_DECL_LOG10L. * modules/math (Makefile.am): Substitute GNULIB_LOG10L, HAVE_LOG10L, HAVE_DECL_LOG10L. * doc/posix-functions/log10l.texi: Mention the new module. ================================ lib/log10l.c ================================ /* Base 10 logarithmic function. 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> #if HAVE_SAME_LONG_DOUBLE_AS_DOUBLE long double log10l (long double x) { return log10 (x); } #else /* 1 / log(10) */ static const long double inv_log10 = 0.43429448190325182765112891891660508229439700580366656611445378316586464920887L; long double log10l (long double x) { return logl (x) * inv_log10; } #endif ================================ m4/log10l.m4 ================================ # log10l.m4 serial 1 dnl Copyright (C) 2011-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_LOG10L], [ AC_REQUIRE([gl_MATH_H_DEFAULTS]) AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE]) AC_REQUIRE([gl_FUNC_LOG10]) dnl Test whether log10l() is declared. On AIX 5.1 it is not declared. AC_CHECK_DECL([log10l], , [HAVE_DECL_LOG10L=0], [[#include <math.h>]]) dnl Test whether log10l() exists. Assume that log10l(), if it exists, is dnl defined in the same library as log10(). save_LIBS="$LIBS" LIBS="$LIBS $LOG10_LIBM" AC_CHECK_FUNCS([log10l]) LIBS="$save_LIBS" if test $ac_cv_func_log10l = yes; then LOG10L_LIBM="$LOG10_LIBM" else HAVE_LOG10L=0 if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then LOG10L_LIBM="$LOG10_LIBM" else AC_REQUIRE([gl_FUNC_LOGL]) LOG10L_LIBM="$LOGL_LIBM" fi fi AC_SUBST([LOG10L_LIBM]) ]) =============================== modules/log10l =============================== Description: log10l() function: base 10 logarithmic function. Files: lib/log10l.c m4/log10l.m4 Depends-on: math log10 [test $HAVE_LOG10L = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1] logl [test $HAVE_LOG10L = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0] configure.ac: gl_FUNC_LOG10L if test $HAVE_LOG10L = 0; then AC_LIBOBJ([log10l]) fi gl_MATH_MODULE_INDICATOR([log10l]) Makefile.am: Include: <math.h> Link: $(LOG10L_LIBM) License: LGPL Maintainer: Bruno Haible ============================================================================== --- doc/posix-functions/log10l.texi.orig Sun Feb 26 00:37:51 2012 +++ doc/posix-functions/log10l.texi Sun Feb 26 00:16:31 2012 @@ -4,15 +4,18 @@ POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/log10l.html} -Gnulib module: --- +Gnulib module: log10l Portability problems fixed by Gnulib: @itemize +@item +This function is missing on some platforms: +FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, HP-UX 11, IRIX 6.5, Solaris 9, Cygwin, Interix 3.5, BeOS. +@item +This function is not declared on some platforms: +AIX 5.1. @end itemize Portability problems not fixed by Gnulib: @itemize -@item -This function is missing on some platforms: -FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, HP-UX 11, IRIX 6.5, Solaris 9, Cygwin, Interix 3.5, BeOS. @end itemize --- lib/math.in.h.orig Sun Feb 26 00:37:51 2012 +++ lib/math.in.h Sun Feb 26 00:17:15 2012 @@ -849,6 +849,21 @@ # endif #endif +#if @GNULIB_LOG10L@ +# if !@HAVE_LOG10L@ || !@HAVE_DECL_LOG10L@ +# undef log10l +_GL_FUNCDECL_SYS (log10l, long double, (long double x)); +# endif +_GL_CXXALIAS_SYS (log10l, long double, (long double x)); +_GL_CXXALIASWARN (log10l); +#elif defined GNULIB_POSIXCHECK +# undef log10l +# if HAVE_RAW_DECL_LOG10L +_GL_WARN_ON_USE (log10l, "log10l is unportable - " + "use gnulib module log10l for portability"); +# endif +#endif + #if @GNULIB_MODFF@ # if !@HAVE_MODFF@ --- m4/math_h.m4.orig Sun Feb 26 00:37:51 2012 +++ m4/math_h.m4 Sun Feb 26 00:17:36 2012 @@ -1,4 +1,4 @@ -# math_h.m4 serial 62 +# math_h.m4 serial 63 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, @@ -42,7 +42,7 @@ [acosf acosl asinf asinl atanf atanl ceilf ceill copysign copysignf copysignl cosf cosl coshf expf expl fabsf fabsl floorf floorl fma fmaf fmal fmodf fmodl frexpf frexpl - ldexpf ldexpl logb logf logl log10f modff modfl powf + ldexpf ldexpl logb logf logl log10f log10l modff modfl powf remainder remainderf remainderl rint rintf rintl round roundf roundl sinf sinl sinhf sqrtf sqrtl tanf tanl tanhf trunc truncf truncl]) @@ -102,6 +102,7 @@ GNULIB_LOGF=0; AC_SUBST([GNULIB_LOGF]) GNULIB_LOGL=0; AC_SUBST([GNULIB_LOGL]) GNULIB_LOG10F=0; AC_SUBST([GNULIB_LOG10F]) + GNULIB_LOG10L=0; AC_SUBST([GNULIB_LOG10L]) GNULIB_MODFF=0; AC_SUBST([GNULIB_MODFF]) GNULIB_MODFL=0; AC_SUBST([GNULIB_MODFL]) GNULIB_POWF=0; AC_SUBST([GNULIB_POWF]) @@ -157,6 +158,7 @@ HAVE_LOGF=1; AC_SUBST([HAVE_LOGF]) HAVE_LOGL=1; AC_SUBST([HAVE_LOGL]) HAVE_LOG10F=1; AC_SUBST([HAVE_LOG10F]) + HAVE_LOG10L=1; AC_SUBST([HAVE_LOG10L]) HAVE_MODFF=1; AC_SUBST([HAVE_MODFF]) HAVE_MODFL=1; AC_SUBST([HAVE_MODFL]) HAVE_POWF=1; AC_SUBST([HAVE_POWF]) @@ -187,6 +189,7 @@ HAVE_DECL_LDEXPL=1; AC_SUBST([HAVE_DECL_LDEXPL]) HAVE_DECL_LOGB=1; AC_SUBST([HAVE_DECL_LOGB]) HAVE_DECL_LOGL=1; AC_SUBST([HAVE_DECL_LOGL]) + HAVE_DECL_LOG10L=1; AC_SUBST([HAVE_DECL_LOG10L]) HAVE_DECL_REMAINDER=1; AC_SUBST([HAVE_DECL_REMAINDER]) HAVE_DECL_ROUND=1; AC_SUBST([HAVE_DECL_ROUND]) HAVE_DECL_ROUNDF=1; AC_SUBST([HAVE_DECL_ROUNDF]) --- modules/math.orig Sun Feb 26 00:37:51 2012 +++ modules/math Sun Feb 26 00:17:57 2012 @@ -71,6 +71,7 @@ -e 's/@''GNULIB_LOGF''@/$(GNULIB_LOGF)/g' \ -e 's/@''GNULIB_LOGL''@/$(GNULIB_LOGL)/g' \ -e 's/@''GNULIB_LOG10F''@/$(GNULIB_LOG10F)/g' \ + -e 's/@''GNULIB_LOG10L''@/$(GNULIB_LOG10L)/g' \ -e 's/@''GNULIB_MODFF''@/$(GNULIB_MODFF)/g' \ -e 's/@''GNULIB_MODFL''@/$(GNULIB_MODFL)/g' \ -e 's/@''GNULIB_POWF''@/$(GNULIB_POWF)/g' \ @@ -126,6 +127,7 @@ -e 's|@''HAVE_LOGF''@|$(HAVE_LOGF)|g' \ -e 's|@''HAVE_LOGL''@|$(HAVE_LOGL)|g' \ -e 's|@''HAVE_LOG10F''@|$(HAVE_LOG10F)|g' \ + -e 's|@''HAVE_LOG10L''@|$(HAVE_LOG10L)|g' \ -e 's|@''HAVE_MODFF''@|$(HAVE_MODFF)|g' \ -e 's|@''HAVE_MODFL''@|$(HAVE_MODFL)|g' \ -e 's|@''HAVE_POWF''@|$(HAVE_POWF)|g' \ @@ -156,6 +158,7 @@ -e 's|@''HAVE_DECL_LDEXPL''@|$(HAVE_DECL_LDEXPL)|g' \ -e 's|@''HAVE_DECL_LOGB''@|$(HAVE_DECL_LOGB)|g' \ -e 's|@''HAVE_DECL_LOGL''@|$(HAVE_DECL_LOGL)|g' \ + -e 's|@''HAVE_DECL_LOG10L''@|$(HAVE_DECL_LOG10L)|g' \ -e 's|@''HAVE_DECL_REMAINDER''@|$(HAVE_DECL_REMAINDER)|g' \ -e 's|@''HAVE_DECL_ROUND''@|$(HAVE_DECL_ROUND)|g' \ -e 's|@''HAVE_DECL_ROUNDF''@|$(HAVE_DECL_ROUNDF)|g' \
