From: Bruno Haible Date: Sat, 8 Oct 2011 21:42:50 +0000 (+0200) Subject: New module 'acosf'. X-Git-Tag: v0.1~1642 X-Git-Url: http://erislabs.net/gitweb/?a=commitdiff_plain;h=668d099b94c3e88afc7e1957858adc963f072124;p=gnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index 2f5cf4ded..540dcae37 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2011-10-08 Bruno Haible + 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. diff --git a/doc/posix-functions/acosf.texi b/doc/posix-functions/acosf.texi index a1859feeb..4afebe7dd 100644 --- a/doc/posix-functions/acosf.texi +++ b/doc/posix-functions/acosf.texi @@ -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 index 000000000..25c9262e9 --- /dev/null +++ b/lib/acosf.c @@ -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 . */ + +#include + +/* Specification. */ +#include + +float +acosf (float x) +{ + return (float) acos ((double) x); +} diff --git a/lib/math.in.h b/lib/math.in.h index a3c0d3133..983a45c04 100644 --- a/lib/math.in.h +++ b/lib/math.in.h @@ -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 index 000000000..0bd6afc81 --- /dev/null +++ b/m4/acosf.m4 @@ -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]) +]) diff --git a/m4/math_h.m4 b/m4/math_h.m4 index a705f0184..4355728a3 100644 --- a/m4/math_h.m4 +++ b/m4/math_h.m4 @@ -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 ]], - [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 index 000000000..aa61b0365 --- /dev/null +++ b/modules/acosf @@ -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: + + +Link: +$(ACOSF_LIBM) + +License: +LGPL + +Maintainer: +Bruno Haible diff --git a/modules/math b/modules/math index d005050af..602dea40c 100644 --- a/modules/math +++ b/modules/math @@ -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' \ diff --git a/tests/test-math-c++.cc b/tests/test-math-c++.cc index 4f82dd8f8..a5ef9958a 100644 --- a/tests/test-math-c++.cc +++ b/tests/test-math-c++.cc @@ -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));