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

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

index 4f1fdbd..f8a5a73 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2011-10-08  Bruno Haible  <bruno@clisp.org>
 
+       New module 'atan2f'.
+       * lib/math.in.h (atan2f): New declaration.
+       * lib/atan2f.c: New file.
+       * m4/atan2f.m4: New file.
+       * m4/math_h.m4 (gl_MATH_H): Test whether atan2f is declared.
+       (gl_MATH_H_DEFAULTS): Initialize GNULIB_ATAN2F, HAVE_ATAN2F.
+       * modules/math (Makefile.am): Substitute GNULIB_ATAN2F, HAVE_ATAN2F.
+       * modules/atan2f: New file.
+       * tests/test-math-c++.cc: Check the declaration of atan2f.
+       * doc/posix-functions/atan2f.texi: Mention the new module.
+
        atan2: Use a .m4 file.
        * m4/atan2.m4: New file.
        * modules/atan2 (Files): Add it.
index 817f20b..14f180c 100644 (file)
@@ -4,14 +4,10 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/atan2f.html}
 
-Gnulib module: ---
+Gnulib module: atan2f
 
 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/atan2f.c b/lib/atan2f.c
new file mode 100644 (file)
index 0000000..09771f6
--- /dev/null
@@ -0,0 +1,26 @@
+/* Angle of a point in the plane.
+   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
+atan2f (float y, float x)
+{
+  return (float) atan2 ((double) y, (double) x);
+}
index 9407681..512425c 100644 (file)
@@ -198,6 +198,22 @@ _GL_WARN_ON_USE (atanl, "atanl is unportable - "
 #endif
 
 
+#if @GNULIB_ATAN2F@
+# if !@HAVE_ATAN2F@
+#  undef atan2f
+_GL_FUNCDECL_SYS (atan2f, float, (float y, float x));
+# endif
+_GL_CXXALIAS_SYS (atan2f, float, (float y, float x));
+_GL_CXXALIASWARN (atan2f);
+#elif defined GNULIB_POSIXCHECK
+# undef atan2f
+# if HAVE_RAW_DECL_ATAN2F
+_GL_WARN_ON_USE (atan2f, "atan2f is unportable - "
+                 "use gnulib module atan2f for portability");
+# endif
+#endif
+
+
 #if @GNULIB_CEILF@
 # if @REPLACE_CEILF@
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
diff --git a/m4/atan2f.m4 b/m4/atan2f.m4
new file mode 100644 (file)
index 0000000..34aeb59
--- /dev/null
@@ -0,0 +1,25 @@
+# atan2f.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_ATAN2F],
+[
+  AC_REQUIRE([gl_MATH_H_DEFAULTS])
+  AC_REQUIRE([gl_FUNC_ATAN2])
+
+  dnl Test whether atan2f() exists. Assume that atan2f(), if it exists, is
+  dnl defined in the same library as atan2().
+  save_LIBS="$LIBS"
+  LIBS="$LIBS $ATAN2_LIBM"
+  AC_CHECK_FUNCS([atan2f])
+  LIBS="$save_LIBS"
+  if test $ac_cv_func_atan2f = yes; then
+    ATAN2F_LIBM="$ATAN2_LIBM"
+  else
+    HAVE_ATAN2F=0
+    ATAN2F_LIBM="$ATAN2_LIBM"
+  fi
+  AC_SUBST([ATAN2F_LIBM])
+])
index 81f382d..79c0ae1 100644 (file)
@@ -1,4 +1,4 @@
-# math_h.m4 serial 42
+# math_h.m4 serial 43
 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,
@@ -63,6 +63,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
   GNULIB_ASINL=0;    AC_SUBST([GNULIB_ASINL])
   GNULIB_ATANF=0;    AC_SUBST([GNULIB_ATANF])
   GNULIB_ATANL=0;    AC_SUBST([GNULIB_ATANL])
+  GNULIB_ATAN2F=0;   AC_SUBST([GNULIB_ATAN2F])
   GNULIB_CEIL=0;     AC_SUBST([GNULIB_CEIL])
   GNULIB_CEILF=0;    AC_SUBST([GNULIB_CEILF])
   GNULIB_CEILL=0;    AC_SUBST([GNULIB_CEILL])
@@ -112,6 +113,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
   HAVE_ASINL=1;                AC_SUBST([HAVE_ASINL])
   HAVE_ATANF=1;                AC_SUBST([HAVE_ATANF])
   HAVE_ATANL=1;                AC_SUBST([HAVE_ATANL])
+  HAVE_ATAN2F=1;               AC_SUBST([HAVE_ATAN2F])
   HAVE_COSF=1;                 AC_SUBST([HAVE_COSF])
   HAVE_COSL=1;                 AC_SUBST([HAVE_COSL])
   HAVE_EXPF=1;                 AC_SUBST([HAVE_EXPF])
diff --git a/modules/atan2f b/modules/atan2f
new file mode 100644 (file)
index 0000000..f2d7dc6
--- /dev/null
@@ -0,0 +1,31 @@
+Description:
+atan2f() function: angle of a point in the plane.
+
+Files:
+lib/atan2f.c
+m4/atan2f.m4
+
+Depends-on:
+math
+atan2           [test $HAVE_ATAN2F = 0]
+
+configure.ac:
+gl_FUNC_ATAN2F
+if test $HAVE_ATAN2F = 0; then
+  AC_LIBOBJ([atan2f])
+fi
+gl_MATH_MODULE_INDICATOR([atan2f])
+
+Makefile.am:
+
+Include:
+<math.h>
+
+Link:
+$(ATAN2F_LIBM)
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
index 9a9181f..4cd261d 100644 (file)
@@ -34,6 +34,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
              -e 's/@''GNULIB_ASINL''@/$(GNULIB_ASINL)/g' \
              -e 's/@''GNULIB_ATANF''@/$(GNULIB_ATANF)/g' \
              -e 's/@''GNULIB_ATANL''@/$(GNULIB_ATANL)/g' \
+             -e 's/@''GNULIB_ATAN2F''@/$(GNULIB_ATAN2F)/g' \
              -e 's/@''GNULIB_CEIL''@/$(GNULIB_CEIL)/g' \
              -e 's/@''GNULIB_CEILF''@/$(GNULIB_CEILF)/g' \
              -e 's/@''GNULIB_CEILL''@/$(GNULIB_CEILL)/g' \
@@ -83,6 +84,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
              -e 's|@''HAVE_ASINL''@|$(HAVE_ASINL)|g' \
              -e 's|@''HAVE_ATANF''@|$(HAVE_ATANF)|g' \
              -e 's|@''HAVE_ATANL''@|$(HAVE_ATANL)|g' \
+             -e 's|@''HAVE_ATAN2F''@|$(HAVE_ATAN2F)|g' \
              -e 's|@''HAVE_COSF''@|$(HAVE_COSF)|g' \
              -e 's|@''HAVE_COSL''@|$(HAVE_COSL)|g' \
              -e 's|@''HAVE_EXPF''@|$(HAVE_EXPF)|g' \
index d0f8c6e..a26a86f 100644 (file)
@@ -36,6 +36,9 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::asinf, float, (float));
 SIGNATURE_CHECK (GNULIB_NAMESPACE::atanf, float, (float));
 #endif
 //SIGNATURE_CHECK (GNULIB_NAMESPACE::atan, double, (double));
+#if GNULIB_TEST_ATAN2F
+SIGNATURE_CHECK (GNULIB_NAMESPACE::atan2f, float, (float, float));
+#endif
 //SIGNATURE_CHECK (GNULIB_NAMESPACE::atan2, double, (double, double));
 //SIGNATURE_CHECK (GNULIB_NAMESPACE::cbrt, double, (double));
 //SIGNATURE_CHECK (GNULIB_NAMESPACE::copysign, double, (double, double));