summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2011-10-08 23:55:44 +0200
committerBruno Haible <bruno@clisp.org>2011-10-08 23:55:44 +0200
commita5766f2b114a3a8ca55f7257aa9eef8b5ddc466a (patch)
tree7a684a16bfa59ac6e6e32d312e2a418b3d0abf86
parent50ef96d5a5201fa07917adcf7a118cb45d4de80a (diff)
downloadgnulib-a5766f2b114a3a8ca55f7257aa9eef8b5ddc466a.tar.gz
New module 'atanf'.
* lib/math.in.h (atanf): New declaration. * lib/atanf.c: New file. * m4/atanf.m4: New file. * m4/math_h.m4 (gl_MATH_H): Test whether atanf is declared. (gl_MATH_H_DEFAULTS): Initialize GNULIB_ATANF, HAVE_ATANF. * modules/math (Makefile.am): Substitute GNULIB_ATANF, HAVE_ATANF. * modules/atanf: New file. * tests/test-math-c++.cc: Check the declaration of atanf. * doc/posix-functions/atanf.texi: Mention the new module.
-rw-r--r--ChangeLog11
-rw-r--r--doc/posix-functions/atanf.texi10
-rw-r--r--lib/atanf.c26
-rw-r--r--lib/math.in.h15
-rw-r--r--m4/atanf.m425
-rw-r--r--m4/math_h.m46
-rw-r--r--modules/atanf31
-rw-r--r--modules/math2
-rw-r--r--tests/test-math-c++.cc3
9 files changed, 122 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 2b7a1552a4..92c13aec6c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2011-10-08 Bruno Haible <bruno@clisp.org>
+ New module 'atanf'.
+ * lib/math.in.h (atanf): New declaration.
+ * lib/atanf.c: New file.
+ * m4/atanf.m4: New file.
+ * m4/math_h.m4 (gl_MATH_H): Test whether atanf is declared.
+ (gl_MATH_H_DEFAULTS): Initialize GNULIB_ATANF, HAVE_ATANF.
+ * modules/math (Makefile.am): Substitute GNULIB_ATANF, HAVE_ATANF.
+ * modules/atanf: New file.
+ * tests/test-math-c++.cc: Check the declaration of atanf.
+ * doc/posix-functions/atanf.texi: Mention the new module.
+
atan: Use a .m4 file.
* m4/atan.m4: New file.
* modules/atan (Files): Add it.
diff --git a/doc/posix-functions/atanf.texi b/doc/posix-functions/atanf.texi
index c29064a1d0..509937aab9 100644
--- a/doc/posix-functions/atanf.texi
+++ b/doc/posix-functions/atanf.texi
@@ -4,14 +4,10 @@
POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/atanf.html}
-Gnulib module: ---
+Gnulib module: atanf
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/atanf.c b/lib/atanf.c
new file mode 100644
index 0000000000..f8bd4f19e8
--- /dev/null
+++ b/lib/atanf.c
@@ -0,0 +1,26 @@
+/* Inverse 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
+atanf (float x)
+{
+ return (float) atan ((double) x);
+}
diff --git a/lib/math.in.h b/lib/math.in.h
index 983a45c04e..94076815ae 100644
--- a/lib/math.in.h
+++ b/lib/math.in.h
@@ -168,6 +168,21 @@ _GL_WARN_ON_USE (asinl, "asinl is unportable - "
#endif
+#if @GNULIB_ATANF@
+# if !@HAVE_ATANF@
+# undef atanf
+_GL_FUNCDECL_SYS (atanf, float, (float x));
+# endif
+_GL_CXXALIAS_SYS (atanf, float, (float x));
+_GL_CXXALIASWARN (atanf);
+#elif defined GNULIB_POSIXCHECK
+# undef atanf
+# if HAVE_RAW_DECL_ATANF
+_GL_WARN_ON_USE (atanf, "atanf is unportable - "
+ "use gnulib module atanf for portability");
+# endif
+#endif
+
#if @GNULIB_ATANL@
# if !@HAVE_ATANL@ || !@HAVE_DECL_ATANL@
_GL_FUNCDECL_SYS (atanl, long double, (long double x));
diff --git a/m4/atanf.m4 b/m4/atanf.m4
new file mode 100644
index 0000000000..e64ba04587
--- /dev/null
+++ b/m4/atanf.m4
@@ -0,0 +1,25 @@
+# atanf.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_ATANF],
+[
+ AC_REQUIRE([gl_MATH_H_DEFAULTS])
+ AC_REQUIRE([gl_FUNC_ATAN])
+
+ dnl Test whether atanf() exists. Assume that atanf(), if it exists, is
+ dnl defined in the same library as atan().
+ save_LIBS="$LIBS"
+ LIBS="$LIBS $ATAN_LIBM"
+ AC_CHECK_FUNCS([atanf])
+ LIBS="$save_LIBS"
+ if test $ac_cv_func_atanf = yes; then
+ ATANF_LIBM="$ATAN_LIBM"
+ else
+ HAVE_ATANF=0
+ ATANF_LIBM="$ATAN_LIBM"
+ fi
+ AC_SUBST([ATANF_LIBM])
+])
diff --git a/m4/math_h.m4 b/m4/math_h.m4
index 4355728a31..81f382d7f3 100644
--- a/m4/math_h.m4
+++ b/m4/math_h.m4
@@ -1,4 +1,4 @@
-# math_h.m4 serial 41
+# math_h.m4 serial 42
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 atanl ceilf ceill cosf cosl
+ [acosf acosl asinf asinl atanf 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
@@ -61,6 +61,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
GNULIB_ACOSL=0; AC_SUBST([GNULIB_ACOSL])
GNULIB_ASINF=0; AC_SUBST([GNULIB_ASINF])
GNULIB_ASINL=0; AC_SUBST([GNULIB_ASINL])
+ GNULIB_ATANF=0; AC_SUBST([GNULIB_ATANF])
GNULIB_ATANL=0; AC_SUBST([GNULIB_ATANL])
GNULIB_CEIL=0; AC_SUBST([GNULIB_CEIL])
GNULIB_CEILF=0; AC_SUBST([GNULIB_CEILF])
@@ -109,6 +110,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
HAVE_ACOSL=1; AC_SUBST([HAVE_ACOSL])
HAVE_ASINF=1; AC_SUBST([HAVE_ASINF])
HAVE_ASINL=1; AC_SUBST([HAVE_ASINL])
+ HAVE_ATANF=1; AC_SUBST([HAVE_ATANF])
HAVE_ATANL=1; AC_SUBST([HAVE_ATANL])
HAVE_COSF=1; AC_SUBST([HAVE_COSF])
HAVE_COSL=1; AC_SUBST([HAVE_COSL])
diff --git a/modules/atanf b/modules/atanf
new file mode 100644
index 0000000000..b17a4e621f
--- /dev/null
+++ b/modules/atanf
@@ -0,0 +1,31 @@
+Description:
+atanf() function: inverse tangent function.
+
+Files:
+lib/atanf.c
+m4/atanf.m4
+
+Depends-on:
+math
+atan [test $HAVE_ATANF = 0]
+
+configure.ac:
+gl_FUNC_ATANF
+if test $HAVE_ATANF = 0; then
+ AC_LIBOBJ([atanf])
+fi
+gl_MATH_MODULE_INDICATOR([atanf])
+
+Makefile.am:
+
+Include:
+<math.h>
+
+Link:
+$(ATANF_LIBM)
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
diff --git a/modules/math b/modules/math
index 602dea40c8..9a9181fbdc 100644
--- a/modules/math
+++ b/modules/math
@@ -32,6 +32,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
-e 's/@''GNULIB_ACOSL''@/$(GNULIB_ACOSL)/g' \
-e 's/@''GNULIB_ASINF''@/$(GNULIB_ASINF)/g' \
-e 's/@''GNULIB_ASINL''@/$(GNULIB_ASINL)/g' \
+ -e 's/@''GNULIB_ATANF''@/$(GNULIB_ATANF)/g' \
-e 's/@''GNULIB_ATANL''@/$(GNULIB_ATANL)/g' \
-e 's/@''GNULIB_CEIL''@/$(GNULIB_CEIL)/g' \
-e 's/@''GNULIB_CEILF''@/$(GNULIB_CEILF)/g' \
@@ -80,6 +81,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
-e 's|@''HAVE_ACOSL''@|$(HAVE_ACOSL)|g' \
-e 's|@''HAVE_ASINF''@|$(HAVE_ASINF)|g' \
-e 's|@''HAVE_ASINL''@|$(HAVE_ASINL)|g' \
+ -e 's|@''HAVE_ATANF''@|$(HAVE_ATANF)|g' \
-e 's|@''HAVE_ATANL''@|$(HAVE_ATANL)|g' \
-e 's|@''HAVE_COSF''@|$(HAVE_COSF)|g' \
-e 's|@''HAVE_COSL''@|$(HAVE_COSL)|g' \
diff --git a/tests/test-math-c++.cc b/tests/test-math-c++.cc
index a5ef9958a2..d0f8c6e917 100644
--- a/tests/test-math-c++.cc
+++ b/tests/test-math-c++.cc
@@ -32,6 +32,9 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::acosf, float, (float));
SIGNATURE_CHECK (GNULIB_NAMESPACE::asinf, float, (float));
#endif
//SIGNATURE_CHECK (GNULIB_NAMESPACE::asin, double, (double));
+#if GNULIB_TEST_ATANF
+SIGNATURE_CHECK (GNULIB_NAMESPACE::atanf, float, (float));
+#endif
//SIGNATURE_CHECK (GNULIB_NAMESPACE::atan, double, (double));
//SIGNATURE_CHECK (GNULIB_NAMESPACE::atan2, double, (double, double));
//SIGNATURE_CHECK (GNULIB_NAMESPACE::cbrt, double, (double));