From e103887cbe53070d92acbf502f7922f3515705fc Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 9 Oct 2011 00:40:19 +0200 Subject: [PATCH] New module 'sinhf'. * lib/math.in.h (sinhf): New declaration. * lib/sinhf.c: New file. * m4/sinhf.m4: New file. * m4/math_h.m4 (gl_MATH_H): Test whether sinhf is declared. (gl_MATH_H_DEFAULTS): Initialize GNULIB_SINHF, HAVE_SINHF. * modules/math (Makefile.am): Substitute GNULIB_SINHF, HAVE_SINHF. * modules/sinhf: New file. * tests/test-math-c++.cc: Check the declaration of sinhf. * doc/posix-functions/sinhf.texi: Mention the new module. --- ChangeLog | 11 +++++++++++ doc/posix-functions/sinhf.texi | 10 +++++----- lib/math.in.h | 16 ++++++++++++++++ lib/sinhf.c | 26 ++++++++++++++++++++++++++ m4/math_h.m4 | 6 ++++-- m4/sinhf.m4 | 25 +++++++++++++++++++++++++ modules/math | 2 ++ modules/sinhf | 31 +++++++++++++++++++++++++++++++ tests/test-math-c++.cc | 3 +++ 9 files changed, 123 insertions(+), 7 deletions(-) create mode 100644 lib/sinhf.c create mode 100644 m4/sinhf.m4 create mode 100644 modules/sinhf diff --git a/ChangeLog b/ChangeLog index 03a9c88af..ce2390e12 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2011-10-08 Bruno Haible + New module 'sinhf'. + * lib/math.in.h (sinhf): New declaration. + * lib/sinhf.c: New file. + * m4/sinhf.m4: New file. + * m4/math_h.m4 (gl_MATH_H): Test whether sinhf is declared. + (gl_MATH_H_DEFAULTS): Initialize GNULIB_SINHF, HAVE_SINHF. + * modules/math (Makefile.am): Substitute GNULIB_SINHF, HAVE_SINHF. + * modules/sinhf: New file. + * tests/test-math-c++.cc: Check the declaration of sinhf. + * doc/posix-functions/sinhf.texi: Mention the new module. + sinh: Use a .m4 file. * m4/sinh.m4: New file. * modules/sinh (Files): Add it. diff --git a/doc/posix-functions/sinhf.texi b/doc/posix-functions/sinhf.texi index 23ad359c4..0d9a1dd7b 100644 --- a/doc/posix-functions/sinhf.texi +++ b/doc/posix-functions/sinhf.texi @@ -4,14 +4,10 @@ POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/sinhf.html} -Gnulib module: --- +Gnulib module: sinhf 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, Solaris 9. @@ -19,3 +15,7 @@ Minix 3.1.8, AIX 5.1, Solaris 9. This function is only defined as a macro with arguments on some platforms: MSVC 9. @end itemize + +Portability problems not fixed by Gnulib: +@itemize +@end itemize diff --git a/lib/math.in.h b/lib/math.in.h index 512425cb1..e7899ff44 100644 --- a/lib/math.in.h +++ b/lib/math.in.h @@ -753,6 +753,22 @@ _GL_WARN_ON_USE (sinl, "sinl is unportable - " #endif +#if @GNULIB_SINHF@ +# if !@HAVE_SINHF@ +# undef sinhf +_GL_FUNCDECL_SYS (sinhf, float, (float x)); +# endif +_GL_CXXALIAS_SYS (sinhf, float, (float x)); +_GL_CXXALIASWARN (sinhf); +#elif defined GNULIB_POSIXCHECK +# undef sinhf +# if HAVE_RAW_DECL_SINHF +_GL_WARN_ON_USE (sinhf, "sinhf is unportable - " + "use gnulib module sinhf for portability"); +# endif +#endif + + #if @GNULIB_SQRTF@ # if !@HAVE_SQRTF@ # undef sqrtf diff --git a/lib/sinhf.c b/lib/sinhf.c new file mode 100644 index 000000000..e44f30b99 --- /dev/null +++ b/lib/sinhf.c @@ -0,0 +1,26 @@ +/* Hyperbolic sine function. + Copyright (C) 2011 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 +sinhf (float x) +{ + return (float) sinh ((double) x); +} diff --git a/m4/math_h.m4 b/m4/math_h.m4 index 79c0ae1aa..60101ef22 100644 --- a/m4/math_h.m4 +++ b/m4/math_h.m4 @@ -1,4 +1,4 @@ -# math_h.m4 serial 43 +# math_h.m4 serial 44 dnl Copyright (C) 2007-2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -42,7 +42,7 @@ AC_DEFUN([gl_MATH_H], [acosf acosl asinf asinl atanf atanl ceilf ceill cosf cosl expf expl fabsf floorf floorl fmodf frexpf frexpl ldexpf ldexpl logb logf logl log10f modff powf - round roundf roundl sinf sinl sqrtf sqrtl + round roundf roundl sinf sinl sinhf sqrtf sqrtl tanf tanl trunc truncf truncl]) ]) @@ -99,6 +99,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS], GNULIB_SIGNBIT=0; AC_SUBST([GNULIB_SIGNBIT]) GNULIB_SINF=0; AC_SUBST([GNULIB_SINF]) GNULIB_SINL=0; AC_SUBST([GNULIB_SINL]) + GNULIB_SINHF=0; AC_SUBST([GNULIB_SINHF]) GNULIB_SQRTF=0; AC_SUBST([GNULIB_SQRTF]) GNULIB_SQRTL=0; AC_SUBST([GNULIB_SQRTL]) GNULIB_TANF=0; AC_SUBST([GNULIB_TANF]) @@ -132,6 +133,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS], HAVE_POWF=1; AC_SUBST([HAVE_POWF]) HAVE_SINF=1; AC_SUBST([HAVE_SINF]) HAVE_SINL=1; AC_SUBST([HAVE_SINL]) + HAVE_SINHF=1; AC_SUBST([HAVE_SINHF]) HAVE_SQRTF=1; AC_SUBST([HAVE_SQRTF]) HAVE_SQRTL=1; AC_SUBST([HAVE_SQRTL]) HAVE_TANF=1; AC_SUBST([HAVE_TANF]) diff --git a/m4/sinhf.m4 b/m4/sinhf.m4 new file mode 100644 index 000000000..99d43b975 --- /dev/null +++ b/m4/sinhf.m4 @@ -0,0 +1,25 @@ +# sinhf.m4 serial 1 +dnl Copyright (C) 2011 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_SINHF], +[ + AC_REQUIRE([gl_MATH_H_DEFAULTS]) + AC_REQUIRE([gl_FUNC_SINH]) + + dnl Test whether sinhf() exists. Assume that sinhf(), if it exists, is + dnl defined in the same library as sinh(). + save_LIBS="$LIBS" + LIBS="$LIBS $SINH_LIBM" + AC_CHECK_FUNCS([sinhf]) + LIBS="$save_LIBS" + if test $ac_cv_func_sinhf = yes; then + SINHF_LIBM="$SINH_LIBM" + else + HAVE_SINHF=0 + SINHF_LIBM="$SINH_LIBM" + fi + AC_SUBST([SINHF_LIBM]) +]) diff --git a/modules/math b/modules/math index 4cd261d86..2193dc57e 100644 --- a/modules/math +++ b/modules/math @@ -70,6 +70,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $( -e 's/@''GNULIB_SIGNBIT''@/$(GNULIB_SIGNBIT)/g' \ -e 's/@''GNULIB_SINF''@/$(GNULIB_SINF)/g' \ -e 's/@''GNULIB_SINL''@/$(GNULIB_SINL)/g' \ + -e 's/@''GNULIB_SINHF''@/$(GNULIB_SINHF)/g' \ -e 's/@''GNULIB_SQRTF''@/$(GNULIB_SQRTF)/g' \ -e 's/@''GNULIB_SQRTL''@/$(GNULIB_SQRTL)/g' \ -e 's/@''GNULIB_TANF''@/$(GNULIB_TANF)/g' \ @@ -103,6 +104,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $( -e 's|@''HAVE_POWF''@|$(HAVE_POWF)|g' \ -e 's|@''HAVE_SINF''@|$(HAVE_SINF)|g' \ -e 's|@''HAVE_SINL''@|$(HAVE_SINL)|g' \ + -e 's|@''HAVE_SINHF''@|$(HAVE_SINHF)|g' \ -e 's|@''HAVE_SQRTF''@|$(HAVE_SQRTF)|g' \ -e 's|@''HAVE_SQRTL''@|$(HAVE_SQRTL)|g' \ -e 's|@''HAVE_TANF''@|$(HAVE_TANF)|g' \ diff --git a/modules/sinhf b/modules/sinhf new file mode 100644 index 000000000..f45bbe319 --- /dev/null +++ b/modules/sinhf @@ -0,0 +1,31 @@ +Description: +sinhf() function: hyperbolic sine function. + +Files: +lib/sinhf.c +m4/sinhf.m4 + +Depends-on: +math +sinh [test $HAVE_SINHF = 0] + +configure.ac: +gl_FUNC_SINHF +if test $HAVE_SINHF = 0; then + AC_LIBOBJ([sinhf]) +fi +gl_MATH_MODULE_INDICATOR([sinhf]) + +Makefile.am: + +Include: + + +Link: +$(SINHF_LIBM) + +License: +LGPL + +Maintainer: +Bruno Haible diff --git a/tests/test-math-c++.cc b/tests/test-math-c++.cc index a26a86ffb..5e9d4bc66 100644 --- a/tests/test-math-c++.cc +++ b/tests/test-math-c++.cc @@ -101,6 +101,9 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::powf, float, (float, float)); SIGNATURE_CHECK (GNULIB_NAMESPACE::sinf, float, (float)); #endif //SIGNATURE_CHECK (GNULIB_NAMESPACE::sin, double, (double)); +#if GNULIB_TEST_SINHF +SIGNATURE_CHECK (GNULIB_NAMESPACE::sinhf, float, (float)); +#endif //SIGNATURE_CHECK (GNULIB_NAMESPACE::sinh, double, (double)); #if GNULIB_TEST_SQRTF SIGNATURE_CHECK (GNULIB_NAMESPACE::sqrtf, float, (float)); -- 2.11.0