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

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

index 268c468..ee7bb8d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2011-10-08  Bruno Haible  <bruno@clisp.org>
 
+       New module 'cosf'.
+       * lib/math.in.h (cosf): New declaration.
+       * lib/cosf.c: New file.
+       * m4/cosf.m4: New file.
+       * m4/math_h.m4 (gl_MATH_H): Test whether cosf is declared.
+       (gl_MATH_H_DEFAULTS): Initialize GNULIB_COSF, HAVE_COSF.
+       * modules/math (Makefile.am): Substitute GNULIB_COSF, HAVE_COSF.
+       * modules/cosf: New file.
+       * tests/test-math-c++.cc: Check the declaration of cosf.
+       * doc/posix-functions/cosf.texi: Mention the new module.
+
        cos: Use a .m4 file.
        * m4/cos.m4: New file.
        * modules/cos (Files): Add it.
index 0b70de0..f814162 100644 (file)
@@ -4,14 +4,10 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/cosf.html}
 
-Gnulib module: ---
+Gnulib module: cosf
 
 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/cosf.c b/lib/cosf.c
new file mode 100644 (file)
index 0000000..e9156a9
--- /dev/null
@@ -0,0 +1,26 @@
+/* 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
+cosf (float x)
+{
+  return (float) cos ((double) x);
+}
index b27b651..4cbdbb3 100644 (file)
@@ -213,6 +213,21 @@ _GL_WARN_ON_USE (ceill, "ceill is unportable - "
 #endif
 
 
+#if @GNULIB_COSF@
+# if !@HAVE_COSF@
+#  undef cosf
+_GL_FUNCDECL_SYS (cosf, float, (float x));
+# endif
+_GL_CXXALIAS_SYS (cosf, float, (float x));
+_GL_CXXALIASWARN (cosf);
+#elif defined GNULIB_POSIXCHECK
+# undef cosf
+# if HAVE_RAW_DECL_COSF
+_GL_WARN_ON_USE (cosf, "cosf is unportable - "
+                 "use gnulib module cosf for portability");
+# endif
+#endif
+
 #if @GNULIB_COSL@
 # if !@HAVE_COSL@ || !@HAVE_DECL_COSL@
 _GL_FUNCDECL_SYS (cosl, long double, (long double x));
diff --git a/m4/cosf.m4 b/m4/cosf.m4
new file mode 100644 (file)
index 0000000..d552dfc
--- /dev/null
@@ -0,0 +1,25 @@
+# cosf.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_COSF],
+[
+  AC_REQUIRE([gl_MATH_H_DEFAULTS])
+  AC_REQUIRE([gl_FUNC_COS])
+
+  dnl Test whether cosf() exists. Assume that cosf(), if it exists, is
+  dnl defined in the same library as cos().
+  save_LIBS="$LIBS"
+  LIBS="$LIBS $COS_LIBM"
+  AC_CHECK_FUNCS([cosf])
+  LIBS="$save_LIBS"
+  if test $ac_cv_func_cosf = yes; then
+    COSF_LIBM="$COS_LIBM"
+  else
+    HAVE_COSF=0
+    COSF_LIBM="$COS_LIBM"
+  fi
+  AC_SUBST([COSF_LIBM])
+])
index dc8695a..ce1ef0b 100644 (file)
@@ -1,4 +1,4 @@
-# math_h.m4 serial 37
+# math_h.m4 serial 38
 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,8 +39,8 @@ 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>]],
-    [acosl asinl atanl ceilf ceill cosl expf expl fabsf floorf floorl fmodf
-     frexpf frexpl
+    [acosl asinl 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
      tanl trunc truncf truncl])
@@ -63,6 +63,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
   GNULIB_CEIL=0;     AC_SUBST([GNULIB_CEIL])
   GNULIB_CEILF=0;    AC_SUBST([GNULIB_CEILF])
   GNULIB_CEILL=0;    AC_SUBST([GNULIB_CEILL])
+  GNULIB_COSF=0;     AC_SUBST([GNULIB_COSF])
   GNULIB_COSL=0;     AC_SUBST([GNULIB_COSL])
   GNULIB_EXPF=0;     AC_SUBST([GNULIB_EXPF])
   GNULIB_EXPL=0;     AC_SUBST([GNULIB_EXPL])
@@ -104,6 +105,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
   HAVE_ACOSL=1;                AC_SUBST([HAVE_ACOSL])
   HAVE_ASINL=1;                AC_SUBST([HAVE_ASINL])
   HAVE_ATANL=1;                AC_SUBST([HAVE_ATANL])
+  HAVE_COSF=1;                 AC_SUBST([HAVE_COSF])
   HAVE_COSL=1;                 AC_SUBST([HAVE_COSL])
   HAVE_EXPF=1;                 AC_SUBST([HAVE_EXPF])
   HAVE_EXPL=1;                 AC_SUBST([HAVE_EXPL])
diff --git a/modules/cosf b/modules/cosf
new file mode 100644 (file)
index 0000000..b9b9860
--- /dev/null
@@ -0,0 +1,31 @@
+Description:
+cosf() function: cosine function.
+
+Files:
+lib/cosf.c
+m4/cosf.m4
+
+Depends-on:
+math
+cos             [test $HAVE_COSF = 0]
+
+configure.ac:
+gl_FUNC_COSF
+if test $HAVE_COSF = 0; then
+  AC_LIBOBJ([cosf])
+fi
+gl_MATH_MODULE_INDICATOR([cosf])
+
+Makefile.am:
+
+Include:
+<math.h>
+
+Link:
+$(COSF_LIBM)
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
index 1dc0239..adff1be 100644 (file)
@@ -34,6 +34,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
              -e 's/@''GNULIB_CEIL''@/$(GNULIB_CEIL)/g' \
              -e 's/@''GNULIB_CEILF''@/$(GNULIB_CEILF)/g' \
              -e 's/@''GNULIB_CEILL''@/$(GNULIB_CEILL)/g' \
+             -e 's/@''GNULIB_COSF''@/$(GNULIB_COSF)/g' \
              -e 's/@''GNULIB_COSL''@/$(GNULIB_COSL)/g' \
              -e 's/@''GNULIB_EXPF''@/$(GNULIB_EXPF)/g' \
              -e 's/@''GNULIB_EXPL''@/$(GNULIB_EXPL)/g' \
@@ -75,6 +76,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
          sed -e 's|@''HAVE_ACOSL''@|$(HAVE_ACOSL)|g' \
              -e 's|@''HAVE_ASINL''@|$(HAVE_ASINL)|g' \
              -e 's|@''HAVE_ATANL''@|$(HAVE_ATANL)|g' \
+             -e 's|@''HAVE_COSF''@|$(HAVE_COSF)|g' \
              -e 's|@''HAVE_COSL''@|$(HAVE_COSL)|g' \
              -e 's|@''HAVE_EXPF''@|$(HAVE_EXPF)|g' \
              -e 's|@''HAVE_EXPL''@|$(HAVE_EXPL)|g' \
index 64eb465..32542fe 100644 (file)
@@ -30,6 +30,9 @@
 //SIGNATURE_CHECK (GNULIB_NAMESPACE::atan2, double, (double, double));
 //SIGNATURE_CHECK (GNULIB_NAMESPACE::cbrt, double, (double));
 //SIGNATURE_CHECK (GNULIB_NAMESPACE::copysign, double, (double, double));
+#if GNULIB_TEST_COSF
+SIGNATURE_CHECK (GNULIB_NAMESPACE::cosf, float, (float));
+#endif
 //SIGNATURE_CHECK (GNULIB_NAMESPACE::cos, double, (double));
 //SIGNATURE_CHECK (GNULIB_NAMESPACE::cosh, double, (double));
 //SIGNATURE_CHECK (GNULIB_NAMESPACE::erf, double, (double));