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

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

index 2f5cf4d..540dcae 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2011-10-08  Bruno Haible  <bruno@clisp.org>
 
+       New module 'acosf'.
+       * lib/math.in.h (acosf): New declaration.
+       * lib/acosf.c: New file.
+       * m4/acosf.m4: New file.
+       * m4/math_h.m4 (gl_MATH_H): Test whether acosf is declared.
+       (gl_MATH_H_DEFAULTS): Initialize GNULIB_ACOSF, HAVE_ACOSF.
+       * modules/math (Makefile.am): Substitute GNULIB_ACOSF, HAVE_ACOSF.
+       * modules/acosf: New file.
+       * tests/test-math-c++.cc: Check the declaration of acosf.
+       * doc/posix-functions/acosf.texi: Mention the new module.
+
        acos: Use a .m4 file.
        * m4/acos.m4: New file.
        * modules/acos (Files): Add it.
index a1859fe..4afebe7 100644 (file)
@@ -4,14 +4,10 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/acosf.html}
 
-Gnulib module: ---
+Gnulib module: acosf
 
 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/acosf.c b/lib/acosf.c
new file mode 100644 (file)
index 0000000..25c9262
--- /dev/null
@@ -0,0 +1,26 @@
+/* Inverse 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
+acosf (float x)
+{
+  return (float) acos ((double) x);
+}
index a3c0d31..983a45c 100644 (file)
@@ -108,6 +108,21 @@ _NaN ()
 #endif
 
 
+#if @GNULIB_ACOSF@
+# if !@HAVE_ACOSF@
+#  undef acosf
+_GL_FUNCDECL_SYS (acosf, float, (float x));
+# endif
+_GL_CXXALIAS_SYS (acosf, float, (float x));
+_GL_CXXALIASWARN (acosf);
+#elif defined GNULIB_POSIXCHECK
+# undef acosf
+# if HAVE_RAW_DECL_ACOSF
+_GL_WARN_ON_USE (acosf, "acosf is unportable - "
+                 "use gnulib module acosf for portability");
+# endif
+#endif
+
 #if @GNULIB_ACOSL@
 # if !@HAVE_ACOSL@ || !@HAVE_DECL_ACOSL@
 _GL_FUNCDECL_SYS (acosl, long double, (long double x));
diff --git a/m4/acosf.m4 b/m4/acosf.m4
new file mode 100644 (file)
index 0000000..0bd6afc
--- /dev/null
@@ -0,0 +1,25 @@
+# acosf.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_ACOSF],
+[
+  AC_REQUIRE([gl_MATH_H_DEFAULTS])
+  AC_REQUIRE([gl_FUNC_ACOS])
+
+  dnl Test whether acosf() exists. Assume that acosf(), if it exists, is
+  dnl defined in the same library as acos().
+  save_LIBS="$LIBS"
+  LIBS="$LIBS $ACOS_LIBM"
+  AC_CHECK_FUNCS([acosf])
+  LIBS="$save_LIBS"
+  if test $ac_cv_func_acosf = yes; then
+    ACOSF_LIBM="$ACOS_LIBM"
+  else
+    HAVE_ACOSF=0
+    ACOSF_LIBM="$ACOS_LIBM"
+  fi
+  AC_SUBST([ACOSF_LIBM])
+])
index a705f01..4355728 100644 (file)
@@ -1,4 +1,4 @@
-# math_h.m4 serial 40
+# math_h.m4 serial 41
 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>]],
-    [acosl asinf asinl atanl ceilf ceill cosf cosl
+    [acosf acosl asinf 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
@@ -57,6 +57,7 @@ AC_DEFUN([gl_MATH_MODULE_INDICATOR],
 
 AC_DEFUN([gl_MATH_H_DEFAULTS],
 [
+  GNULIB_ACOSF=0;    AC_SUBST([GNULIB_ACOSF])
   GNULIB_ACOSL=0;    AC_SUBST([GNULIB_ACOSL])
   GNULIB_ASINF=0;    AC_SUBST([GNULIB_ASINF])
   GNULIB_ASINL=0;    AC_SUBST([GNULIB_ASINL])
@@ -104,6 +105,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
   GNULIB_TRUNCF=0;   AC_SUBST([GNULIB_TRUNCF])
   GNULIB_TRUNCL=0;   AC_SUBST([GNULIB_TRUNCL])
   dnl Assume proper GNU behavior unless another module says otherwise.
+  HAVE_ACOSF=1;                AC_SUBST([HAVE_ACOSF])
   HAVE_ACOSL=1;                AC_SUBST([HAVE_ACOSL])
   HAVE_ASINF=1;                AC_SUBST([HAVE_ASINF])
   HAVE_ASINL=1;                AC_SUBST([HAVE_ASINL])
diff --git a/modules/acosf b/modules/acosf
new file mode 100644 (file)
index 0000000..aa61b03
--- /dev/null
@@ -0,0 +1,31 @@
+Description:
+acosf() function: inverse cosine function.
+
+Files:
+lib/acosf.c
+m4/acosf.m4
+
+Depends-on:
+math
+acos            [test $HAVE_ACOSF = 0]
+
+configure.ac:
+gl_FUNC_ACOSF
+if test $HAVE_ACOSF = 0; then
+  AC_LIBOBJ([acosf])
+fi
+gl_MATH_MODULE_INDICATOR([acosf])
+
+Makefile.am:
+
+Include:
+<math.h>
+
+Link:
+$(ACOSF_LIBM)
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
index d005050..602dea4 100644 (file)
@@ -28,6 +28,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
              -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
              -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
              -e 's|@''NEXT_AS_FIRST_DIRECTIVE_MATH_H''@|$(NEXT_AS_FIRST_DIRECTIVE_MATH_H)|g' \
+             -e 's/@''GNULIB_ACOSF''@/$(GNULIB_ACOSF)/g' \
              -e 's/@''GNULIB_ACOSL''@/$(GNULIB_ACOSL)/g' \
              -e 's/@''GNULIB_ASINF''@/$(GNULIB_ASINF)/g' \
              -e 's/@''GNULIB_ASINL''@/$(GNULIB_ASINL)/g' \
@@ -75,7 +76,8 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
              -e 's/@''GNULIB_TRUNCF''@/$(GNULIB_TRUNCF)/g' \
              -e 's/@''GNULIB_TRUNCL''@/$(GNULIB_TRUNCL)/g' \
              < $(srcdir)/math.in.h | \
-         sed -e 's|@''HAVE_ACOSL''@|$(HAVE_ACOSL)|g' \
+         sed -e 's|@''HAVE_ACOSF''@|$(HAVE_ACOSF)|g' \
+             -e 's|@''HAVE_ACOSL''@|$(HAVE_ACOSL)|g' \
              -e 's|@''HAVE_ASINF''@|$(HAVE_ASINF)|g' \
              -e 's|@''HAVE_ASINL''@|$(HAVE_ASINL)|g' \
              -e 's|@''HAVE_ATANL''@|$(HAVE_ATANL)|g' \
index 4f82dd8..a5ef995 100644 (file)
@@ -24,6 +24,9 @@
 #include "signature.h"
 
 
+#if GNULIB_TEST_ACOSF
+SIGNATURE_CHECK (GNULIB_NAMESPACE::acosf, float, (float));
+#endif
 //SIGNATURE_CHECK (GNULIB_NAMESPACE::acos, double, (double));
 #if GNULIB_TEST_ASINF
 SIGNATURE_CHECK (GNULIB_NAMESPACE::asinf, float, (float));