]> Savannah Git Hosting - gnulib.git/commitdiff
logp1f: New module.
authorBruno Haible <bruno@clisp.org>
Mon, 29 Jul 2024 11:15:23 +0000 (13:15 +0200)
committerBruno Haible <bruno@clisp.org>
Mon, 29 Jul 2024 11:54:03 +0000 (13:54 +0200)
* lib/math.in.h (logp1f): New declaration.
* lib/logp1f.c: New file.
* m4/logp1f.m4: New file.
* m4/log1p.m4 (gl_FUNC_LOG1P): Define through AC_DEFUN_ONCE.
* m4/isnand.m4 (gl_FUNC_ISNAND): Define through AC_DEFUN_ONCE.
* m4/math_h.m4 (gl_MATH_H): Test whether logp1f is declared.
(gl_MATH_H_REQUIRE_DEFAULTS): Initialize GNULIB_LOGP1F.
(gl_MATH_H_DEFAULTS): Initialize HAVE_LOGP1F.
* modules/math (Makefile.am): Substitute GNULIB_LOGP1F, HAVE_LOGP1F.
* modules/logp1f: New file.
* doc/posix-functions/logp1f.texi: Mention the new module.

ChangeLog
doc/posix-functions/logp1f.texi
lib/logp1f.c [new file with mode: 0644]
lib/math.in.h
m4/isnand.m4
m4/log1p.m4
m4/logp1f.m4 [new file with mode: 0644]
m4/math_h.m4
modules/logp1f [new file with mode: 0644]
modules/math

index 4b06ddac4cd57bda7bf2d73f3890f49b27bc4893..c16b3d27c7638c20532ed49016522a1b0d9c8207 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2024-07-29  Bruno Haible  <bruno@clisp.org>
+
+       logp1f: New module.
+       * lib/math.in.h (logp1f): New declaration.
+       * lib/logp1f.c: New file.
+       * m4/logp1f.m4: New file.
+       * m4/log1p.m4 (gl_FUNC_LOG1P): Define through AC_DEFUN_ONCE.
+       * m4/isnand.m4 (gl_FUNC_ISNAND): Define through AC_DEFUN_ONCE.
+       * m4/math_h.m4 (gl_MATH_H): Test whether logp1f is declared.
+       (gl_MATH_H_DEFAULTS): Initialize HAVE_LOGP1F.
+       * modules/math (Makefile.am): Substitute GNULIB_LOGP1F, HAVE_LOGP1F.
+       * modules/logp1f: New file.
+       * doc/posix-functions/logp1f.texi: Mention the new module.
+
 2024-07-29  Bruno Haible  <bruno@clisp.org>
 
        logp1: Add tests.
index ba8ab72025bfc21a84bf1609a9873db76b23c722..0ca79702071e6bae0a5818ad6e104b0b803cf72c 100644 (file)
@@ -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: logp1f
 
 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/logp1f.c b/lib/logp1f.c
new file mode 100644 (file)
index 0000000..0bb1486
--- /dev/null
@@ -0,0 +1,26 @@
+/* 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 <https://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <math.h>
+
+float
+logp1f (float x)
+{
+  return log1pf (x);
+}
index 8effcbd6beec32fb7b9bd646903c8a28b537ddb8..cb99d9798e959d7f1147bc8721d0c09fc51db546 100644 (file)
@@ -1859,6 +1859,22 @@ _GL_WARN_ON_USE (logbl, "logbl is unportable - "
 #endif
 
 
+#if @GNULIB_LOGP1F@
+# if !@HAVE_LOGP1F@
+_GL_FUNCDECL_SYS (logp1f, float, (float x));
+# endif
+_GL_CXXALIAS_SYS (logp1f, float, (float x));
+# if __GLIBC__ >= 2
+_GL_CXXALIASWARN1 (logp1f, float, (float x));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef logp1f
+# if HAVE_RAW_DECL_LOGP1F
+_GL_WARN_ON_USE (logp1f, "logp1f is unportable - "
+                 "use gnulib module logp1f for portability");
+# endif
+#endif
+
 #if @GNULIB_LOGP1@
 # if !@HAVE_LOGP1@
 _GL_FUNCDECL_SYS (logp1, double, (double x));
index 207407d36122575f9993d6177d683456048ff047..7f7d88d85967e1ac2cc49bed7cae2cdfb4461816 100644 (file)
@@ -1,5 +1,5 @@
 # isnand.m4
-# serial 14
+# serial 15
 dnl Copyright (C) 2007-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,
@@ -7,7 +7,7 @@ dnl with or without modifications, as long as this notice is preserved.
 
 dnl Check how to get or define isnand().
 
-AC_DEFUN([gl_FUNC_ISNAND],
+AC_DEFUN_ONCE([gl_FUNC_ISNAND],
 [
   AC_REQUIRE([gl_MATH_H_DEFAULTS])
   ISNAND_LIBM=
index cb7d5920cea2f5bbe914be5a1442845590c513d2..bd1c989b68b4393e4087ec31ed33258366dbadbb 100644 (file)
@@ -1,11 +1,11 @@
 # log1p.m4
-# serial 11
+# serial 12
 dnl Copyright (C) 2012-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_LOG1P],
+AC_DEFUN_ONCE([gl_FUNC_LOG1P],
 [
   m4_divert_text([DEFAULTS], [gl_log1p_required=plain])
   AC_REQUIRE([gl_MATH_H_DEFAULTS])
diff --git a/m4/logp1f.m4 b/m4/logp1f.m4
new file mode 100644 (file)
index 0000000..d3d1c2d
--- /dev/null
@@ -0,0 +1,31 @@
+# logp1f.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_LOGP1F],
+[
+  AC_REQUIRE([gl_MATH_H_DEFAULTS])
+  AC_REQUIRE([gl_FUNC_LOGP1])
+
+  dnl Persuade glibc <math.h> to declare logp1f().
+  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+
+  dnl Test whether logp1f() exists. Assume that logp1f(), if it exists, is
+  dnl defined in the same library as logp1().
+  saved_LIBS="$LIBS"
+  LIBS="$LIBS $LOGP1_LIBM"
+  AC_CHECK_FUNCS([logp1f])
+  LIBS="$saved_LIBS"
+  if test $ac_cv_func_logp1f = yes; then
+    LOGP1F_LIBM="$LOGP1_LIBM"
+  else
+    HAVE_LOGP1F=0
+    dnl We implement logp1f through log1pf.
+    AC_REQUIRE([gl_FUNC_LOG1PF])
+    LOGP1F_LIBM="$LOG1PF_LIBM"
+  fi
+  AC_SUBST([LOGP1F_LIBM])
+])
index 8781c082dfa06853e56baf7a0cf49ea2c2ce65c0..49326068d04f9fd68e43d682e3005c99d7edd276 100644 (file)
@@ -1,5 +1,5 @@
 # math_h.m4
-# serial 139
+# serial 140
 dnl Copyright (C) 2007-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,
@@ -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
+     logb logbf logbl logp1 log1pf
      modf modff modfl powf
      remainder remainderf remainderl
      rint rintf rintl round roundf roundl
@@ -154,6 +154,7 @@ AC_DEFUN([gl_MATH_H_REQUIRE_DEFAULTS],
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOGBF])
     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_MODF])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MODFF])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MODFL])
@@ -255,6 +256,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
   HAVE_LOGBF=1;                     AC_SUBST([HAVE_LOGBF])
   HAVE_LOGBL=1;                     AC_SUBST([HAVE_LOGBL])
   HAVE_LOGP1=1;                     AC_SUBST([HAVE_LOGP1])
+  HAVE_LOGP1F=1;                    AC_SUBST([HAVE_LOGP1F])
   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/logp1f b/modules/logp1f
new file mode 100644 (file)
index 0000000..cf72c20
--- /dev/null
@@ -0,0 +1,39 @@
+Description:
+logp1f() function: natural logarithm of argument plus 1.
+
+Files:
+lib/logp1f.c
+m4/logp1f.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
+log1pf          [test $HAVE_LOGP1F = 0]
+
+configure.ac:
+gl_FUNC_LOGP1F
+gl_CONDITIONAL([GL_COND_OBJ_LOGP1F], [test $HAVE_LOGP1F = 0])
+gl_MATH_MODULE_INDICATOR([logp1f])
+
+Makefile.am:
+if GL_COND_OBJ_LOGP1F
+lib_SOURCES += logp1f.c
+endif
+
+Include:
+<math.h>
+
+Link:
+$(LOGP1F_LIBM)
+
+License:
+LGPL
+
+Maintainer:
+all
index fed10a5c5efd058b0c8ae574bc8dd3ba5b0a85b8..34c605c2f1d165f85a16160954978013f21ac6ca 100644 (file)
@@ -111,6 +111,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
              -e 's/@''GNULIB_LOGBF''@/$(GNULIB_LOGBF)/g' \
              -e 's/@''GNULIB_LOGBL''@/$(GNULIB_LOGBL)/g' \
              -e 's/@''GNULIB_LOGP1''@/$(GNULIB_LOGP1)/g' \
+             -e 's/@''GNULIB_LOGP1F''@/$(GNULIB_LOGP1F)/g' \
              -e 's/@''GNULIB_MODF''@/$(GNULIB_MODF)/g' \
              -e 's/@''GNULIB_MODFF''@/$(GNULIB_MODFF)/g' \
              -e 's/@''GNULIB_MODFL''@/$(GNULIB_MODFL)/g' \
@@ -205,6 +206,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
              -e 's|@''HAVE_LOGBF''@|$(HAVE_LOGBF)|g' \
              -e 's|@''HAVE_LOGBL''@|$(HAVE_LOGBL)|g' \
              -e 's|@''HAVE_LOGP1''@|$(HAVE_LOGP1)|g' \
+             -e 's|@''HAVE_LOGP1F''@|$(HAVE_LOGP1F)|g' \
              -e 's|@''HAVE_MODFF''@|$(HAVE_MODFF)|g' \
              -e 's|@''HAVE_MODFL''@|$(HAVE_MODFL)|g' \
              -e 's|@''HAVE_POWF''@|$(HAVE_POWF)|g' \