Mercurial > hg > octave-lojdl > gnulib-hg
changeset 15890:52fb6ed99832
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.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 09 Oct 2011 00:31:51 +0200 |
parents | 1c3fe3d6520b |
children | 9a3dbe3ea81d |
files | ChangeLog doc/posix-functions/atan2f.texi lib/atan2f.c lib/math.in.h m4/atan2f.m4 m4/math_h.m4 modules/atan2f modules/math tests/test-math-c++.cc |
diffstat | 9 files changed, 122 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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.
--- a/doc/posix-functions/atan2f.texi +++ b/doc/posix-functions/atan2f.texi @@ -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 @@ 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
new file mode 100644 --- /dev/null +++ b/lib/atan2f.c @@ -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); +}
--- a/lib/math.in.h +++ b/lib/math.in.h @@ -198,6 +198,22 @@ #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)
new file mode 100644 --- /dev/null +++ b/m4/atan2f.m4 @@ -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]) +])
--- a/m4/math_h.m4 +++ b/m4/math_h.m4 @@ -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 @@ 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 @@ 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])
new file mode 100644 --- /dev/null +++ b/modules/atan2f @@ -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
--- a/modules/math +++ b/modules/math @@ -34,6 +34,7 @@ -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 @@ -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' \
--- a/tests/test-math-c++.cc +++ b/tests/test-math-c++.cc @@ -36,6 +36,9 @@ 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));