From: Bruno Haible Date: Mon, 29 Jul 2024 11:38:46 +0000 (+0200) Subject: logp1l: New module. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=3f8e0614d0d3b1e364059963a3554b13bc28c687;p=gnulib.git logp1l: New module. * lib/math.in.h (logp1l): New declaration. * lib/logp1l.c: New file. * m4/logp1l.m4: New file. * m4/math_h.m4 (gl_MATH_H): Test whether logp1l is declared. (gl_MATH_H_REQUIRE_DEFAULTS): Initialize GNULIB_LOGP1L. (gl_MATH_H_DEFAULTS): Initialize HAVE_LOGP1L. * modules/math (Makefile.am): Substitute GNULIB_LOGP1L, HAVE_LOGP1L. * modules/logp1l: New file. * doc/posix-functions/logp1l.texi: Mention the new module. --- diff --git a/ChangeLog b/ChangeLog index 7b2fd5ddf7..01c967a194 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2024-07-29 Bruno Haible + + logp1l: New module. + * lib/math.in.h (logp1l): New declaration. + * lib/logp1l.c: New file. + * m4/logp1l.m4: New file. + * m4/math_h.m4 (gl_MATH_H): Test whether logp1l is declared. + (gl_MATH_H_REQUIRE_DEFAULTS): Initialize GNULIB_LOGP1L. + (gl_MATH_H_DEFAULTS): Initialize HAVE_LOGP1L. + * modules/math (Makefile.am): Substitute GNULIB_LOGP1L, HAVE_LOGP1L. + * modules/logp1l: New file. + * doc/posix-functions/logp1l.texi: Mention the new module. + 2024-07-29 Bruno Haible logp1f: Add tests. diff --git a/doc/posix-functions/logp1l.texi b/doc/posix-functions/logp1l.texi index 75c29287b1..569c8256b3 100644 --- a/doc/posix-functions/logp1l.texi +++ b/doc/posix-functions/logp1l.texi @@ -4,15 +4,15 @@ ISO C23 specification:@* @url{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n3220.pdf} section 7.12.6.14 -Gnulib module: --- +Gnulib module: logp1l Portability problems fixed by Gnulib: @itemize +@item +This function is missing on all non-glibc platforms: +glibc 2.39, macOS 14, FreeBSD 14.0, NetBSD 10.0, OpenBSD 7.5, Minix 3.3.0, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 14, Android. @end itemize Portability problems not fixed by Gnulib: @itemize -@item -This function is missing on all non-glibc platforms: -glibc 2.39, macOS 14, FreeBSD 14.0, NetBSD 10.0, OpenBSD 7.5, Minix 3.3.0, AIX 7.3.1, HP-UX 11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 14, Android. @end itemize diff --git a/lib/logp1l.c b/lib/logp1l.c new file mode 100644 index 0000000000..1cebbf71d7 --- /dev/null +++ b/lib/logp1l.c @@ -0,0 +1,38 @@ +/* Natural logarithm of argument plus 1. + Copyright (C) 2024 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This file 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 Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +#if HAVE_SAME_LONG_DOUBLE_AS_DOUBLE + +long double +logp1l (long double x) +{ + return logp1 (x); +} + +#else + +long double +logp1l (long double x) +{ + return log1pl (x); +} + +#endif diff --git a/lib/math.in.h b/lib/math.in.h index cb99d9798e..c94ccb12ee 100644 --- a/lib/math.in.h +++ b/lib/math.in.h @@ -1891,6 +1891,22 @@ _GL_WARN_ON_USE (logp1, "logp1 is unportable - " # endif #endif +#if @GNULIB_LOGP1L@ +# if !@HAVE_LOGP1L@ +_GL_FUNCDECL_SYS (logp1l, long double, (long double x)); +# endif +_GL_CXXALIAS_SYS (logp1l, long double, (long double x)); +# if __GLIBC__ >= 2 +_GL_CXXALIASWARN1 (logp1l, long double, (long double x)); +# endif +#elif defined GNULIB_POSIXCHECK +# undef logp1l +# if HAVE_RAW_DECL_LOGP1L +_GL_WARN_ON_USE (logp1l, "logp1l is unportable - " + "use gnulib module logp1l for portability"); +# endif +#endif + #if @GNULIB_MODFF@ # if @REPLACE_MODFF@ diff --git a/m4/logp1l.m4 b/m4/logp1l.m4 new file mode 100644 index 0000000000..1892af8b68 --- /dev/null +++ b/m4/logp1l.m4 @@ -0,0 +1,32 @@ +# logp1l.m4 +# serial 1 +dnl Copyright (C) 2024 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_LOGP1L], +[ + AC_REQUIRE([gl_MATH_H_DEFAULTS]) + AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE]) + AC_REQUIRE([gl_FUNC_LOGP1]) + + dnl Persuade glibc to declare logp1l(). + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + + dnl Test whether logp1l() exists. Assume that logp1l(), if it exists, is + dnl defined in the same library as logp1(). + saved_LIBS="$LIBS" + LIBS="$LIBS $LOGP1_LIBM" + AC_CHECK_FUNCS([logp1l]) + LIBS="$saved_LIBS" + if test $ac_cv_func_logp1l = yes; then + LOGP1L_LIBM="$LOGP1_LIBM" + else + HAVE_LOGP1L=0 + dnl We implement logp1l through log1pl. + AC_REQUIRE([gl_FUNC_LOG1PL]) + LOGP1L_LIBM="$LOG1PL_LIBM" + fi + AC_SUBST([LOGP1L_LIBM]) +]) diff --git a/m4/math_h.m4 b/m4/math_h.m4 index 49326068d0..7e69629c3d 100644 --- a/m4/math_h.m4 +++ b/m4/math_h.m4 @@ -49,7 +49,7 @@ AC_DEFUN_ONCE([gl_MATH_H], ilogb ilogbf ilogbl ldexpf ldexpl log logf logl log10 log10f log10l log1p log1pf log1pl log2 log2f log2l - logb logbf logbl logp1 log1pf + logb logbf logbl logp1 log1pf logp1l modf modff modfl powf remainder remainderf remainderl rint rintf rintl round roundf roundl @@ -155,6 +155,7 @@ AC_DEFUN([gl_MATH_H_REQUIRE_DEFAULTS], gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOGBL]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOGP1]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOGP1F]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOGP1L]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MODF]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MODFF]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MODFL]) @@ -257,6 +258,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS], HAVE_LOGBL=1; AC_SUBST([HAVE_LOGBL]) HAVE_LOGP1=1; AC_SUBST([HAVE_LOGP1]) HAVE_LOGP1F=1; AC_SUBST([HAVE_LOGP1F]) + HAVE_LOGP1L=1; AC_SUBST([HAVE_LOGP1L]) HAVE_MODFF=1; AC_SUBST([HAVE_MODFF]) HAVE_MODFL=1; AC_SUBST([HAVE_MODFL]) HAVE_POWF=1; AC_SUBST([HAVE_POWF]) diff --git a/modules/logp1l b/modules/logp1l new file mode 100644 index 0000000000..55c3ac060d --- /dev/null +++ b/modules/logp1l @@ -0,0 +1,39 @@ +Description: +logp1l() function: natural logarithm of argument plus 1. + +Files: +lib/logp1l.c +m4/logp1l.m4 +m4/logp1.m4 +m4/isnand.m4 +m4/log.m4 +m4/round.m4 +m4/floor.m4 +m4/ceil.m4 +m4/mathfunc.m4 + +Depends-on: +math +log1pl [test $HAVE_LOGP1L = 0] + +configure.ac: +gl_FUNC_LOGP1L +gl_CONDITIONAL([GL_COND_OBJ_LOGP1L], [test $HAVE_LOGP1L = 0]) +gl_MATH_MODULE_INDICATOR([logp1l]) + +Makefile.am: +if GL_COND_OBJ_LOGP1L +lib_SOURCES += logp1l.c +endif + +Include: + + +Link: +$(LOGP1L_LIBM) + +License: +LGPL + +Maintainer: +all diff --git a/modules/math b/modules/math index 34c605c2f1..f0cfa27374 100644 --- a/modules/math +++ b/modules/math @@ -112,6 +112,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $( -e 's/@''GNULIB_LOGBL''@/$(GNULIB_LOGBL)/g' \ -e 's/@''GNULIB_LOGP1''@/$(GNULIB_LOGP1)/g' \ -e 's/@''GNULIB_LOGP1F''@/$(GNULIB_LOGP1F)/g' \ + -e 's/@''GNULIB_LOGP1L''@/$(GNULIB_LOGP1L)/g' \ -e 's/@''GNULIB_MODF''@/$(GNULIB_MODF)/g' \ -e 's/@''GNULIB_MODFF''@/$(GNULIB_MODFF)/g' \ -e 's/@''GNULIB_MODFL''@/$(GNULIB_MODFL)/g' \ @@ -207,6 +208,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $( -e 's|@''HAVE_LOGBL''@|$(HAVE_LOGBL)|g' \ -e 's|@''HAVE_LOGP1''@|$(HAVE_LOGP1)|g' \ -e 's|@''HAVE_LOGP1F''@|$(HAVE_LOGP1F)|g' \ + -e 's|@''HAVE_LOGP1L''@|$(HAVE_LOGP1L)|g' \ -e 's|@''HAVE_MODFF''@|$(HAVE_MODFF)|g' \ -e 's|@''HAVE_MODFL''@|$(HAVE_MODFL)|g' \ -e 's|@''HAVE_POWF''@|$(HAVE_POWF)|g' \