New module 'coshf'.
authorBruno Haible <bruno@clisp.org>
Sat, 8 Oct 2011 22:48:38 +0000 (00:48 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 8 Oct 2011 22:48:38 +0000 (00:48 +0200)
* lib/math.in.h (coshf): New declaration.
* lib/coshf.c: New file.
* m4/coshf.m4: New file.
* m4/math_h.m4 (gl_MATH_H): Test whether coshf is declared.
(gl_MATH_H_DEFAULTS): Initialize GNULIB_COSHF, HAVE_COSHF.
* modules/math (Makefile.am): Substitute GNULIB_COSHF, HAVE_COSHF.
* modules/coshf: New file.
* tests/test-math-c++.cc: Check the declaration of coshf.
* doc/posix-functions/coshf.texi: Mention the new module.

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

index 0de795a..15d3dad 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2011-10-08  Bruno Haible  <bruno@clisp.org>
 
+       New module 'coshf'.
+       * lib/math.in.h (coshf): New declaration.
+       * lib/coshf.c: New file.
+       * m4/coshf.m4: New file.
+       * m4/math_h.m4 (gl_MATH_H): Test whether coshf is declared.
+       (gl_MATH_H_DEFAULTS): Initialize GNULIB_COSHF, HAVE_COSHF.
+       * modules/math (Makefile.am): Substitute GNULIB_COSHF, HAVE_COSHF.
+       * modules/coshf: New file.
+       * tests/test-math-c++.cc: Check the declaration of coshf.
+       * doc/posix-functions/coshf.texi: Mention the new module.
+
        cosh: Use a .m4 file.
        * m4/cosh.m4: New file.
        * modules/cosh (Files): Add it.
index 11560c6..8b883df 100644 (file)
@@ -4,14 +4,10 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/coshf.html}
 
-Gnulib module: ---
+Gnulib module: coshf
 
 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/coshf.c b/lib/coshf.c
new file mode 100644 (file)
index 0000000..c9775d7
--- /dev/null
@@ -0,0 +1,26 @@
+/* Hyperbolic cosine 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
+coshf (float x)
+{
+  return (float) cosh ((double) x);
+}
index e7899ff..d7da584 100644 (file)
@@ -304,6 +304,22 @@ _GL_WARN_ON_USE (cosl, "cosl is unportable - "
 #endif
 
 
+#if @GNULIB_COSHF@
+# if !@HAVE_COSHF@
+#  undef coshf
+_GL_FUNCDECL_SYS (coshf, float, (float x));
+# endif
+_GL_CXXALIAS_SYS (coshf, float, (float x));
+_GL_CXXALIASWARN (coshf);
+#elif defined GNULIB_POSIXCHECK
+# undef coshf
+# if HAVE_RAW_DECL_COSHF
+_GL_WARN_ON_USE (coshf, "coshf is unportable - "
+                 "use gnulib module coshf for portability");
+# endif
+#endif
+
+
 #if @GNULIB_EXPF@
 # if !@HAVE_EXPF@
 #  undef expf
diff --git a/m4/coshf.m4 b/m4/coshf.m4
new file mode 100644 (file)
index 0000000..0bbb3c3
--- /dev/null
@@ -0,0 +1,25 @@
+# coshf.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_COSHF],
+[
+  AC_REQUIRE([gl_MATH_H_DEFAULTS])
+  AC_REQUIRE([gl_FUNC_COSH])
+
+  dnl Test whether coshf() exists. Assume that coshf(), if it exists, is
+  dnl defined in the same library as cosh().
+  save_LIBS="$LIBS"
+  LIBS="$LIBS $COSH_LIBM"
+  AC_CHECK_FUNCS([coshf])
+  LIBS="$save_LIBS"
+  if test $ac_cv_func_coshf = yes; then
+    COSHF_LIBM="$COSH_LIBM"
+  else
+    HAVE_COSHF=0
+    COSHF_LIBM="$COSH_LIBM"
+  fi
+  AC_SUBST([COSHF_LIBM])
+])
index 60101ef..6709764 100644 (file)
@@ -1,4 +1,4 @@
-# math_h.m4 serial 44
+# math_h.m4 serial 45
 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,
@@ -39,7 +39,7 @@ AC_DEFUN([gl_MATH_H],
   dnl Check for declarations of anything we want to poison if the
   dnl corresponding gnulib module is not in use.
   gl_WARN_ON_USE_PREPARE([[#include <math.h>]],
-    [acosf acosl asinf asinl atanf atanl ceilf ceill cosf cosl
+    [acosf acosl asinf asinl atanf atanl ceilf ceill cosf cosl coshf
      expf expl fabsf floorf floorl fmodf frexpf frexpl
      ldexpf ldexpl logb logf logl log10f modff powf
      round roundf roundl sinf sinl sinhf sqrtf sqrtl
@@ -69,6 +69,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
   GNULIB_CEILL=0;    AC_SUBST([GNULIB_CEILL])
   GNULIB_COSF=0;     AC_SUBST([GNULIB_COSF])
   GNULIB_COSL=0;     AC_SUBST([GNULIB_COSL])
+  GNULIB_COSHF=0;    AC_SUBST([GNULIB_COSHF])
   GNULIB_EXPF=0;     AC_SUBST([GNULIB_EXPF])
   GNULIB_EXPL=0;     AC_SUBST([GNULIB_EXPL])
   GNULIB_FABSF=0;    AC_SUBST([GNULIB_FABSF])
@@ -117,6 +118,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
   HAVE_ATAN2F=1;               AC_SUBST([HAVE_ATAN2F])
   HAVE_COSF=1;                 AC_SUBST([HAVE_COSF])
   HAVE_COSL=1;                 AC_SUBST([HAVE_COSL])
+  HAVE_COSHF=1;                AC_SUBST([HAVE_COSHF])
   HAVE_EXPF=1;                 AC_SUBST([HAVE_EXPF])
   HAVE_EXPL=1;                 AC_SUBST([HAVE_EXPL])
   HAVE_FABSF=1;                AC_SUBST([HAVE_FABSF])
diff --git a/modules/coshf b/modules/coshf
new file mode 100644 (file)
index 0000000..d8a1e4b
--- /dev/null
@@ -0,0 +1,31 @@
+Description:
+coshf() function: hyperbolic cosine function.
+
+Files:
+lib/coshf.c
+m4/coshf.m4
+
+Depends-on:
+math
+cosh            [test $HAVE_COSHF = 0]
+
+configure.ac:
+gl_FUNC_COSHF
+if test $HAVE_COSHF = 0; then
+  AC_LIBOBJ([coshf])
+fi
+gl_MATH_MODULE_INDICATOR([coshf])
+
+Makefile.am:
+
+Include:
+<math.h>
+
+Link:
+$(COSHF_LIBM)
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
index 2193dc5..5edfe2a 100644 (file)
@@ -40,6 +40,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
              -e 's/@''GNULIB_CEILL''@/$(GNULIB_CEILL)/g' \
              -e 's/@''GNULIB_COSF''@/$(GNULIB_COSF)/g' \
              -e 's/@''GNULIB_COSL''@/$(GNULIB_COSL)/g' \
+             -e 's/@''GNULIB_COSHF''@/$(GNULIB_COSHF)/g' \
              -e 's/@''GNULIB_EXPF''@/$(GNULIB_EXPF)/g' \
              -e 's/@''GNULIB_EXPL''@/$(GNULIB_EXPL)/g' \
              -e 's/@''GNULIB_FABSF''@/$(GNULIB_FABSF)/g' \
@@ -88,6 +89,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
              -e 's|@''HAVE_ATAN2F''@|$(HAVE_ATAN2F)|g' \
              -e 's|@''HAVE_COSF''@|$(HAVE_COSF)|g' \
              -e 's|@''HAVE_COSL''@|$(HAVE_COSL)|g' \
+             -e 's|@''HAVE_COSHF''@|$(HAVE_COSHF)|g' \
              -e 's|@''HAVE_EXPF''@|$(HAVE_EXPF)|g' \
              -e 's|@''HAVE_EXPL''@|$(HAVE_EXPL)|g' \
              -e 's|@''HAVE_FABSF''@|$(HAVE_FABSF)|g' \
index 5e9d4bc..bcb5b6d 100644 (file)
@@ -46,6 +46,9 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::atan2f, float, (float, float));
 SIGNATURE_CHECK (GNULIB_NAMESPACE::cosf, float, (float));
 #endif
 //SIGNATURE_CHECK (GNULIB_NAMESPACE::cos, double, (double));
+#if GNULIB_TEST_COSHF
+SIGNATURE_CHECK (GNULIB_NAMESPACE::coshf, float, (float));
+#endif
 //SIGNATURE_CHECK (GNULIB_NAMESPACE::cosh, double, (double));
 //SIGNATURE_CHECK (GNULIB_NAMESPACE::erf, double, (double));
 //SIGNATURE_CHECK (GNULIB_NAMESPACE::erfc, double, (double));