changeset 15899:31b76bf2f9e4

New module 'tanhf'. * lib/math.in.h (tanhf): New declaration. * lib/tanhf.c: New file. * m4/tanhf.m4: New file. * m4/math_h.m4 (gl_MATH_H): Test whether tanhf is declared. (gl_MATH_H_DEFAULTS): Initialize GNULIB_TANHF, HAVE_TANHF. * modules/math (Makefile.am): Substitute GNULIB_TANHF, HAVE_TANHF. * modules/tanhf: New file. * tests/test-math-c++.cc: Check the declaration of tanhf. * doc/posix-functions/tanhf.texi: Mention the new module.
author Bruno Haible <bruno@clisp.org>
date Sun, 09 Oct 2011 00:59:02 +0200
parents ada42afa1b8f
children ee6ece33a21b
files ChangeLog doc/posix-functions/tanhf.texi lib/math.in.h lib/tanhf.c m4/math_h.m4 m4/tanhf.m4 modules/math modules/tanhf tests/test-math-c++.cc
diffstat 9 files changed, 123 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2011-10-08  Bruno Haible  <bruno@clisp.org>
 
+	New module 'tanhf'.
+	* lib/math.in.h (tanhf): New declaration.
+	* lib/tanhf.c: New file.
+	* m4/tanhf.m4: New file.
+	* m4/math_h.m4 (gl_MATH_H): Test whether tanhf is declared.
+	(gl_MATH_H_DEFAULTS): Initialize GNULIB_TANHF, HAVE_TANHF.
+	* modules/math (Makefile.am): Substitute GNULIB_TANHF, HAVE_TANHF.
+	* modules/tanhf: New file.
+	* tests/test-math-c++.cc: Check the declaration of tanhf.
+	* doc/posix-functions/tanhf.texi: Mention the new module.
+
 	tanh: Use a .m4 file.
 	* m4/tanh.m4: New file.
 	* modules/tanh (Files): Add it.
--- a/doc/posix-functions/tanhf.texi
+++ b/doc/posix-functions/tanhf.texi
@@ -4,14 +4,10 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/tanhf.html}
 
-Gnulib module: ---
+Gnulib module: tanhf
 
 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 @@
 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
--- a/lib/math.in.h
+++ b/lib/math.in.h
@@ -845,6 +845,22 @@
 #endif
 
 
+#if @GNULIB_TANHF@
+# if !@HAVE_TANHF@
+#  undef tanhf
+_GL_FUNCDECL_SYS (tanhf, float, (float x));
+# endif
+_GL_CXXALIAS_SYS (tanhf, float, (float x));
+_GL_CXXALIASWARN (tanhf);
+#elif defined GNULIB_POSIXCHECK
+# undef tanhf
+# if HAVE_RAW_DECL_TANHF
+_GL_WARN_ON_USE (tanhf, "tanhf is unportable - "
+                 "use gnulib module tanhf for portability");
+# endif
+#endif
+
+
 #if @GNULIB_TRUNCF@
 # if @REPLACE_TRUNCF@
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
new file mode 100644
--- /dev/null
+++ b/lib/tanhf.c
@@ -0,0 +1,26 @@
+/* Hyperbolic tangent 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 <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <math.h>
+
+float
+tanhf (float x)
+{
+  return (float) tanh ((double) x);
+}
--- a/m4/math_h.m4
+++ b/m4/math_h.m4
@@ -1,4 +1,4 @@
-# math_h.m4 serial 45
+# math_h.m4 serial 46
 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,
@@ -43,7 +43,7 @@
      expf expl fabsf floorf floorl fmodf frexpf frexpl
      ldexpf ldexpl logb logf logl log10f modff powf
      round roundf roundl sinf sinl sinhf sqrtf sqrtl
-     tanf tanl trunc truncf truncl])
+     tanf tanl tanhf trunc truncf truncl])
 ])
 
 AC_DEFUN([gl_MATH_MODULE_INDICATOR],
@@ -105,6 +105,7 @@
   GNULIB_SQRTL=0;    AC_SUBST([GNULIB_SQRTL])
   GNULIB_TANF=0;     AC_SUBST([GNULIB_TANF])
   GNULIB_TANL=0;     AC_SUBST([GNULIB_TANL])
+  GNULIB_TANHF=0;    AC_SUBST([GNULIB_TANHF])
   GNULIB_TRUNC=0;    AC_SUBST([GNULIB_TRUNC])
   GNULIB_TRUNCF=0;   AC_SUBST([GNULIB_TRUNCF])
   GNULIB_TRUNCL=0;   AC_SUBST([GNULIB_TRUNCL])
@@ -140,6 +141,7 @@
   HAVE_SQRTL=1;                AC_SUBST([HAVE_SQRTL])
   HAVE_TANF=1;                 AC_SUBST([HAVE_TANF])
   HAVE_TANL=1;                 AC_SUBST([HAVE_TANL])
+  HAVE_TANHF=1;                AC_SUBST([HAVE_TANHF])
   HAVE_DECL_ACOSL=1;           AC_SUBST([HAVE_DECL_ACOSL])
   HAVE_DECL_ASINL=1;           AC_SUBST([HAVE_DECL_ASINL])
   HAVE_DECL_ATANL=1;           AC_SUBST([HAVE_DECL_ATANL])
new file mode 100644
--- /dev/null
+++ b/m4/tanhf.m4
@@ -0,0 +1,25 @@
+# tanhf.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_TANHF],
+[
+  AC_REQUIRE([gl_MATH_H_DEFAULTS])
+  AC_REQUIRE([gl_FUNC_TANH])
+
+  dnl Test whether tanhf() exists. Assume that tanhf(), if it exists, is
+  dnl defined in the same library as tanh().
+  save_LIBS="$LIBS"
+  LIBS="$LIBS $TANH_LIBM"
+  AC_CHECK_FUNCS([tanhf])
+  LIBS="$save_LIBS"
+  if test $ac_cv_func_tanhf = yes; then
+    TANHF_LIBM="$TANH_LIBM"
+  else
+    HAVE_TANHF=0
+    TANHF_LIBM="$TANH_LIBM"
+  fi
+  AC_SUBST([TANHF_LIBM])
+])
--- a/modules/math
+++ b/modules/math
@@ -76,6 +76,7 @@
 	      -e 's/@''GNULIB_SQRTL''@/$(GNULIB_SQRTL)/g' \
 	      -e 's/@''GNULIB_TANF''@/$(GNULIB_TANF)/g' \
 	      -e 's/@''GNULIB_TANL''@/$(GNULIB_TANL)/g' \
+	      -e 's/@''GNULIB_TANHF''@/$(GNULIB_TANHF)/g' \
 	      -e 's/@''GNULIB_TRUNC''@/$(GNULIB_TRUNC)/g' \
 	      -e 's/@''GNULIB_TRUNCF''@/$(GNULIB_TRUNCF)/g' \
 	      -e 's/@''GNULIB_TRUNCL''@/$(GNULIB_TRUNCL)/g' \
@@ -111,6 +112,7 @@
 	      -e 's|@''HAVE_SQRTL''@|$(HAVE_SQRTL)|g' \
 	      -e 's|@''HAVE_TANF''@|$(HAVE_TANF)|g' \
 	      -e 's|@''HAVE_TANL''@|$(HAVE_TANL)|g' \
+	      -e 's|@''HAVE_TANHF''@|$(HAVE_TANHF)|g' \
 	      -e 's|@''HAVE_DECL_ACOSL''@|$(HAVE_DECL_ACOSL)|g' \
 	      -e 's|@''HAVE_DECL_ASINL''@|$(HAVE_DECL_ASINL)|g' \
 	      -e 's|@''HAVE_DECL_ATANL''@|$(HAVE_DECL_ATANL)|g' \
new file mode 100644
--- /dev/null
+++ b/modules/tanhf
@@ -0,0 +1,31 @@
+Description:
+tanhf() function: hyperbolic tangent function.
+
+Files:
+lib/tanhf.c
+m4/tanhf.m4
+
+Depends-on:
+math
+tanh            [test $HAVE_TANHF = 0]
+
+configure.ac:
+gl_FUNC_TANHF
+if test $HAVE_TANHF = 0; then
+  AC_LIBOBJ([tanhf])
+fi
+gl_MATH_MODULE_INDICATOR([tanhf])
+
+Makefile.am:
+
+Include:
+<math.h>
+
+Link:
+$(TANHF_LIBM)
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
--- a/tests/test-math-c++.cc
+++ b/tests/test-math-c++.cc
@@ -116,6 +116,9 @@
 SIGNATURE_CHECK (GNULIB_NAMESPACE::tanf, float, (float));
 #endif
 //SIGNATURE_CHECK (GNULIB_NAMESPACE::tan, double, (double));
+#if GNULIB_TEST_TANHF
+SIGNATURE_CHECK (GNULIB_NAMESPACE::tanhf, float, (float));
+#endif
 //SIGNATURE_CHECK (GNULIB_NAMESPACE::tanh, double, (double));
 //SIGNATURE_CHECK (GNULIB_NAMESPACE::y0, double, (double));
 //SIGNATURE_CHECK (GNULIB_NAMESPACE::y1, double, (double));