New module 'tanhf'.
authorBruno Haible <bruno@clisp.org>
Sat, 8 Oct 2011 22:59:02 +0000 (00:59 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 8 Oct 2011 22:59:02 +0000 (00:59 +0200)
* 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.

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

index e05e78d..16af412 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2011-10-08  Bruno Haible  <bruno@clisp.org>
 
 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.
        tanh: Use a .m4 file.
        * m4/tanh.m4: New file.
        * modules/tanh (Files): Add it.
index 1b7cb4f..6c73695 100644 (file)
@@ -4,14 +4,10 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/tanhf.html}
 
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/tanhf.html}
 
-Gnulib module: ---
+Gnulib module: tanhf
 
 Portability problems fixed by Gnulib:
 @itemize
 
 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.
 @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
 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
index d7da584..a637658 100644 (file)
@@ -845,6 +845,22 @@ _GL_WARN_ON_USE (tanl, "tanl is unportable - "
 #endif
 
 
 #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)
 #if @GNULIB_TRUNCF@
 # if @REPLACE_TRUNCF@
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
diff --git a/lib/tanhf.c b/lib/tanhf.c
new file mode 100644 (file)
index 0000000..b7591a0
--- /dev/null
@@ -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);
+}
index 6709764..0fb405b 100644 (file)
@@ -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,
 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 @@ AC_DEFUN([gl_MATH_H],
      expf expl fabsf floorf floorl fmodf frexpf frexpl
      ldexpf ldexpl logb logf logl log10f modff powf
      round roundf roundl sinf sinl sinhf sqrtf sqrtl
      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],
 ])
 
 AC_DEFUN([gl_MATH_MODULE_INDICATOR],
@@ -105,6 +105,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
   GNULIB_SQRTL=0;    AC_SUBST([GNULIB_SQRTL])
   GNULIB_TANF=0;     AC_SUBST([GNULIB_TANF])
   GNULIB_TANL=0;     AC_SUBST([GNULIB_TANL])
   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])
   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 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
   HAVE_SQRTL=1;                AC_SUBST([HAVE_SQRTL])
   HAVE_TANF=1;                 AC_SUBST([HAVE_TANF])
   HAVE_TANL=1;                 AC_SUBST([HAVE_TANL])
   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])
   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])
diff --git a/m4/tanhf.m4 b/m4/tanhf.m4
new file mode 100644 (file)
index 0000000..2608f97
--- /dev/null
@@ -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])
+])
index 5edfe2a..9c6f999 100644 (file)
@@ -76,6 +76,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
              -e 's/@''GNULIB_SQRTL''@/$(GNULIB_SQRTL)/g' \
              -e 's/@''GNULIB_TANF''@/$(GNULIB_TANF)/g' \
              -e 's/@''GNULIB_TANL''@/$(GNULIB_TANL)/g' \
              -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' \
              -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 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
              -e 's|@''HAVE_SQRTL''@|$(HAVE_SQRTL)|g' \
              -e 's|@''HAVE_TANF''@|$(HAVE_TANF)|g' \
              -e 's|@''HAVE_TANL''@|$(HAVE_TANL)|g' \
              -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' \
              -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' \
diff --git a/modules/tanhf b/modules/tanhf
new file mode 100644 (file)
index 0000000..44f606e
--- /dev/null
@@ -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
index bcb5b6d..d786273 100644 (file)
@@ -116,6 +116,9 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::sqrtf, float, (float));
 SIGNATURE_CHECK (GNULIB_NAMESPACE::tanf, float, (float));
 #endif
 //SIGNATURE_CHECK (GNULIB_NAMESPACE::tan, double, (double));
 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));
 //SIGNATURE_CHECK (GNULIB_NAMESPACE::tanh, double, (double));
 //SIGNATURE_CHECK (GNULIB_NAMESPACE::y0, double, (double));
 //SIGNATURE_CHECK (GNULIB_NAMESPACE::y1, double, (double));