]> Savannah Git Hosting - gnulib.git/commitdiff
New module 'expm1f'.
authorBruno Haible <bruno@clisp.org>
Tue, 6 Mar 2012 20:24:28 +0000 (21:24 +0100)
committerBruno Haible <bruno@clisp.org>
Tue, 6 Mar 2012 21:55:00 +0000 (22:55 +0100)
* lib/math.in.h (expm1f): New declaration.
* lib/expm1f.c: New file.
* m4/expm1f.m4: New file.
* m4/math_h.m4 (gl_MATH_H): Test whether expm1f is declared.
(gl_MATH_H_DEFAULTS): Initialize GNULIB_EXPM1F, HAVE_EXPM1F.
* modules/math (Makefile.am): Substitute GNULIB_EXPM1F, HAVE_EXPM1F.
* modules/expm1f: New file.
* tests/test-math-c++.cc: Check the declaration of expm1f.
* doc/posix-functions/expm1f.texi: Mention the new module.

ChangeLog
doc/posix-functions/expm1f.texi
lib/expm1f.c [new file with mode: 0644]
lib/math.in.h
m4/expm1f.m4 [new file with mode: 0644]
m4/math_h.m4
modules/expm1f [new file with mode: 0644]
modules/math
tests/test-math-c++.cc

index 1dbfe6c5662b9f3aa8b19d03c3010bfee061508a..a8bfd3cda4e3dcd82cc60a541ea2f171f647b48c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2012-03-06  Bruno Haible  <bruno@clisp.org>
+
+       New module 'expm1f'.
+       * lib/math.in.h (expm1f): New declaration.
+       * lib/expm1f.c: New file.
+       * m4/expm1f.m4: New file.
+       * m4/math_h.m4 (gl_MATH_H): Test whether expm1f is declared.
+       (gl_MATH_H_DEFAULTS): Initialize GNULIB_EXPM1F, HAVE_EXPM1F.
+       * modules/math (Makefile.am): Substitute GNULIB_EXPM1F, HAVE_EXPM1F.
+       * modules/expm1f: New file.
+       * tests/test-math-c++.cc: Check the declaration of expm1f.
+       * doc/posix-functions/expm1f.texi: Mention the new module.
+
 2012-03-06  Bruno Haible  <bruno@clisp.org>
 
        Tests for module 'expm1'.
index 8f31cd9de9360b8746bd50c16b3e7157b6b0d534..6023a837ee607737abea458a78461d1c5e47df16 100644 (file)
@@ -4,15 +4,15 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/expm1f.html}
 
-Gnulib module: ---
+Gnulib module: expm1f
 
 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, mingw, MSVC 9.
 @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, mingw, MSVC 9.
 @end itemize
diff --git a/lib/expm1f.c b/lib/expm1f.c
new file mode 100644 (file)
index 0000000..78b7fb7
--- /dev/null
@@ -0,0 +1,26 @@
+/* Exponential function minus one.
+   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
+expm1f (float x)
+{
+  return (float) expm1 ((double) x);
+}
index cf6304b0e050741631084b20d2fde6cc5c794ab7..ee716e901243717b51fbc044f95a0242998548e6 100644 (file)
@@ -532,6 +532,20 @@ _GL_WARN_ON_USE (expl, "expl is unportable - "
 #endif
 
 
+#if @GNULIB_EXPM1F@
+# if !@HAVE_EXPM1F@
+_GL_FUNCDECL_SYS (expm1f, float, (float x));
+# endif
+_GL_CXXALIAS_SYS (expm1f, float, (float x));
+_GL_CXXALIASWARN (expm1f);
+#elif defined GNULIB_POSIXCHECK
+# undef expm1f
+# if HAVE_RAW_DECL_EXPM1F
+_GL_WARN_ON_USE (expm1f, "expm1f is unportable - "
+                 "use gnulib module expm1f for portability");
+# endif
+#endif
+
 #if @GNULIB_EXPM1@
 # if !@HAVE_EXPM1@
 _GL_FUNCDECL_SYS (expm1, double, (double x));
diff --git a/m4/expm1f.m4 b/m4/expm1f.m4
new file mode 100644 (file)
index 0000000..f78262a
--- /dev/null
@@ -0,0 +1,29 @@
+# expm1f.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_EXPM1F],
+[
+  AC_REQUIRE([gl_MATH_H_DEFAULTS])
+  AC_REQUIRE([gl_FUNC_EXPM1])
+
+  dnl Persuade glibc <math.h> to declare expm1f().
+  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+
+  dnl Test whether expm1f() exists. Assume that expm1f(), if it exists, is
+  dnl defined in the same library as expm1().
+  save_LIBS="$LIBS"
+  LIBS="$LIBS $EXPM1_LIBM"
+  AC_CHECK_FUNCS([expm1f])
+  LIBS="$save_LIBS"
+  if test $ac_cv_func_expm1f = yes; then
+    EXPM1F_LIBM="$EXPM1_LIBM"
+  else
+    HAVE_EXPM1F=0
+    dnl Find libraries needed to link lib/expm1f.c.
+    EXPM1F_LIBM="$EXPM1_LIBM"
+  fi
+  AC_SUBST([EXPM1F_LIBM])
+])
index 6ce34abde038a2787a227402e8b8e9b7f5d5194d..c3038cad0da5a2bff6d943f01628fa79b3537380 100644 (file)
@@ -1,4 +1,4 @@
-# math_h.m4 serial 80
+# math_h.m4 serial 81
 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,
@@ -41,7 +41,7 @@ AC_DEFUN([gl_MATH_H],
   gl_WARN_ON_USE_PREPARE([[#include <math.h>]],
     [acosf acosl asinf asinl atanf atanl
      cbrt cbrtf cbrtl ceilf ceill copysign copysignf copysignl cosf cosl coshf
-     expf expl expm1 fabsf fabsl floorf floorl fma fmaf fmal
+     expf expl expm1 expm1f fabsf fabsl floorf floorl fma fmaf fmal
      fmod fmodf fmodl frexpf frexpl hypotf hypotl
      ldexpf ldexpl logb logf logl log10f log10l modf modff modfl powf
      remainder remainderf remainderl
@@ -82,6 +82,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
   GNULIB_EXPF=0;       AC_SUBST([GNULIB_EXPF])
   GNULIB_EXPL=0;       AC_SUBST([GNULIB_EXPL])
   GNULIB_EXPM1=0;      AC_SUBST([GNULIB_EXPM1])
+  GNULIB_EXPM1F=0;     AC_SUBST([GNULIB_EXPM1F])
   GNULIB_FABSF=0;      AC_SUBST([GNULIB_FABSF])
   GNULIB_FABSL=0;      AC_SUBST([GNULIB_FABSL])
   GNULIB_FLOOR=0;      AC_SUBST([GNULIB_FLOOR])
@@ -157,6 +158,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
   HAVE_EXPF=1;                 AC_SUBST([HAVE_EXPF])
   HAVE_EXPL=1;                 AC_SUBST([HAVE_EXPL])
   HAVE_EXPM1=1;                AC_SUBST([HAVE_EXPM1])
+  HAVE_EXPM1F=1;               AC_SUBST([HAVE_EXPM1F])
   HAVE_FABSF=1;                AC_SUBST([HAVE_FABSF])
   HAVE_FABSL=1;                AC_SUBST([HAVE_FABSL])
   HAVE_FMA=1;                  AC_SUBST([HAVE_FMA])
diff --git a/modules/expm1f b/modules/expm1f
new file mode 100644 (file)
index 0000000..823886a
--- /dev/null
@@ -0,0 +1,32 @@
+Description:
+expm1f() function: exponential function minus one.
+
+Files:
+lib/expm1f.c
+m4/expm1f.m4
+
+Depends-on:
+math
+extensions
+expm1           [test $HAVE_EXPM1F = 0]
+
+configure.ac:
+gl_FUNC_EXPM1F
+if test $HAVE_EXPM1F = 0; then
+  AC_LIBOBJ([expm1f])
+fi
+gl_MATH_MODULE_INDICATOR([expm1f])
+
+Makefile.am:
+
+Include:
+<math.h>
+
+Link:
+$(EXPM1F_LIBM)
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
index ee6133d162c6343b3d2f0bc710ecbf660b8e2d02..1dd3298a301008ec77e00d01b257da79f9e29aca 100644 (file)
@@ -50,6 +50,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
              -e 's/@''GNULIB_EXPF''@/$(GNULIB_EXPF)/g' \
              -e 's/@''GNULIB_EXPL''@/$(GNULIB_EXPL)/g' \
              -e 's/@''GNULIB_EXPM1''@/$(GNULIB_EXPM1)/g' \
+             -e 's/@''GNULIB_EXPM1F''@/$(GNULIB_EXPM1F)/g' \
              -e 's/@''GNULIB_FABSF''@/$(GNULIB_FABSF)/g' \
              -e 's/@''GNULIB_FABSL''@/$(GNULIB_FABSL)/g' \
              -e 's/@''GNULIB_FLOOR''@/$(GNULIB_FLOOR)/g' \
@@ -125,6 +126,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
              -e 's|@''HAVE_EXPF''@|$(HAVE_EXPF)|g' \
              -e 's|@''HAVE_EXPL''@|$(HAVE_EXPL)|g' \
              -e 's|@''HAVE_EXPM1''@|$(HAVE_EXPM1)|g' \
+             -e 's|@''HAVE_EXPM1F''@|$(HAVE_EXPM1F)|g' \
              -e 's|@''HAVE_FABSF''@|$(HAVE_FABSF)|g' \
              -e 's|@''HAVE_FABSL''@|$(HAVE_FABSL)|g' \
              -e 's|@''HAVE_FMA''@|$(HAVE_FMA)|g' \
index 9648486fb9652252ef052df763cba94362104bb3..6b79bb0370ac777684ee70d81494744feff68c22 100644 (file)
@@ -124,6 +124,9 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::expf, float, (float));
 SIGNATURE_CHECK (GNULIB_NAMESPACE::expl, long double, (long double));
 #endif
 
+#if GNULIB_TEST_EXPM1F
+SIGNATURE_CHECK (GNULIB_NAMESPACE::expm1f, float, (float));
+#endif
 #if GNULIB_TEST_EXPM1
 SIGNATURE_CHECK (GNULIB_NAMESPACE::expm1, double, (double));
 #endif