From fef5744cfb2fe5d6241e66a8e736f6926e7ea621 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Tue, 6 Mar 2012 21:24:28 +0100 Subject: [PATCH] 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. --- ChangeLog | 13 +++++++++++++ doc/posix-functions/expm1f.texi | 8 ++++---- lib/expm1f.c | 26 ++++++++++++++++++++++++++ lib/math.in.h | 14 ++++++++++++++ m4/expm1f.m4 | 29 +++++++++++++++++++++++++++++ m4/math_h.m4 | 6 ++++-- modules/expm1f | 32 ++++++++++++++++++++++++++++++++ modules/math | 2 ++ tests/test-math-c++.cc | 3 +++ 9 files changed, 127 insertions(+), 6 deletions(-) create mode 100644 lib/expm1f.c create mode 100644 m4/expm1f.m4 create mode 100644 modules/expm1f diff --git a/ChangeLog b/ChangeLog index 1dbfe6c56..a8bfd3cda 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,18 @@ 2012-03-06 Bruno Haible + 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 + Tests for module 'expm1'. * modules/expm1-tests: New file. * tests/test-expm1.c: New file. diff --git a/doc/posix-functions/expm1f.texi b/doc/posix-functions/expm1f.texi index 8f31cd9de..6023a837e 100644 --- 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 +@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 index 000000000..78b7fb758 --- /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 . */ + +#include + +/* Specification. */ +#include + +float +expm1f (float x) +{ + return (float) expm1 ((double) x); +} diff --git a/lib/math.in.h b/lib/math.in.h index cf6304b0e..ee716e901 100644 --- a/lib/math.in.h +++ b/lib/math.in.h @@ -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 index 000000000..f78262a47 --- /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 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]) +]) diff --git a/m4/math_h.m4 b/m4/math_h.m4 index 6ce34abde..c3038cad0 100644 --- 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 @@ AC_DEFUN([gl_MATH_H], gl_WARN_ON_USE_PREPARE([[#include ]], [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 index 000000000..823886ac8 --- /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: + + +Link: +$(EXPM1F_LIBM) + +License: +LGPL + +Maintainer: +Bruno Haible diff --git a/modules/math b/modules/math index ee6133d16..1dd3298a3 100644 --- a/modules/math +++ b/modules/math @@ -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' \ diff --git a/tests/test-math-c++.cc b/tests/test-math-c++.cc index 9648486fb..6b79bb037 100644 --- a/tests/test-math-c++.cc +++ b/tests/test-math-c++.cc @@ -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 -- 2.11.0