changeset 16583:258b00af8457

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.
author Bruno Haible <bruno@clisp.org>
date Tue, 06 Mar 2012 21:24:28 +0100
parents 199ab6e5373c
children 3f0643d139b2
files ChangeLog doc/posix-functions/expm1f.texi lib/expm1f.c lib/math.in.h m4/expm1f.m4 m4/math_h.m4 modules/expm1f modules/math tests/test-math-c++.cc
diffstat 9 files changed, 128 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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'.
--- a/doc/posix-functions/expm1f.texi
+++ b/doc/posix-functions/expm1f.texi
@@ -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
-@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
+
+Portability problems not fixed by Gnulib:
+@itemize
+@end itemize
new file mode 100644
--- /dev/null
+++ b/lib/expm1f.c
@@ -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);
+}
--- a/lib/math.in.h
+++ b/lib/math.in.h
@@ -532,6 +532,20 @@
 #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));
new file mode 100644
--- /dev/null
+++ b/m4/expm1f.m4
@@ -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])
+])
--- a/m4/math_h.m4
+++ b/m4/math_h.m4
@@ -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 @@
   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 @@
   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 @@
   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])
new file mode 100644
--- /dev/null
+++ b/modules/expm1f
@@ -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
--- a/modules/math
+++ b/modules/math
@@ -50,6 +50,7 @@
 	      -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 @@
 	      -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' \
--- a/tests/test-math-c++.cc
+++ b/tests/test-math-c++.cc
@@ -124,6 +124,9 @@
 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