From: Bruno Haible Date: Sat, 8 Oct 2011 21:29:33 +0000 (+0200) Subject: New module 'asinf'. X-Git-Tag: v0.1~1645 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=effe7821374f8b7e22e9de3df9cc4e5f285712bd;p=gnulib.git New module 'asinf'. * lib/math.in.h (asinf): New declaration. * lib/asinf.c: New file. * m4/asinf.m4: New file. * m4/math_h.m4 (gl_MATH_H): Test whether asinf is declared. (gl_MATH_H_DEFAULTS): Initialize GNULIB_ASINF, HAVE_ASINF. * modules/math (Makefile.am): Substitute GNULIB_ASINF, HAVE_ASINF. * modules/asinf: New file. * tests/test-math-c++.cc: Check the declaration of asinf. * doc/posix-functions/asinf.texi: Mention the new module. --- diff --git a/ChangeLog b/ChangeLog index ac1f0d944..772a27a9b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2011-10-08 Bruno Haible + New module 'asinf'. + * lib/math.in.h (asinf): New declaration. + * lib/asinf.c: New file. + * m4/asinf.m4: New file. + * m4/math_h.m4 (gl_MATH_H): Test whether asinf is declared. + (gl_MATH_H_DEFAULTS): Initialize GNULIB_ASINF, HAVE_ASINF. + * modules/math (Makefile.am): Substitute GNULIB_ASINF, HAVE_ASINF. + * modules/asinf: New file. + * tests/test-math-c++.cc: Check the declaration of asinf. + * doc/posix-functions/asinf.texi: Mention the new module. + asin: Use a .m4 file. * m4/asin.m4: New file. * modules/asin (Files): Add it. diff --git a/doc/posix-functions/asinf.texi b/doc/posix-functions/asinf.texi index 999593b1b..fbf532b89 100644 --- a/doc/posix-functions/asinf.texi +++ b/doc/posix-functions/asinf.texi @@ -4,14 +4,10 @@ POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/asinf.html} -Gnulib module: --- +Gnulib module: asinf 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/asinf.c b/lib/asinf.c new file mode 100644 index 000000000..82f1d346d --- /dev/null +++ b/lib/asinf.c @@ -0,0 +1,26 @@ +/* Inverse sine 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 +asinf (float x) +{ + return (float) asin ((double) x); +} diff --git a/lib/math.in.h b/lib/math.in.h index 053774ea3..a3c0d3133 100644 --- a/lib/math.in.h +++ b/lib/math.in.h @@ -123,6 +123,21 @@ _GL_WARN_ON_USE (acosl, "acosl is unportable - " #endif +#if @GNULIB_ASINF@ +# if !@HAVE_ASINF@ +# undef asinf +_GL_FUNCDECL_SYS (asinf, float, (float x)); +# endif +_GL_CXXALIAS_SYS (asinf, float, (float x)); +_GL_CXXALIASWARN (asinf); +#elif defined GNULIB_POSIXCHECK +# undef asinf +# if HAVE_RAW_DECL_ASINF +_GL_WARN_ON_USE (asinf, "asinf is unportable - " + "use gnulib module asinf for portability"); +# endif +#endif + #if @GNULIB_ASINL@ # if !@HAVE_ASINL@ || !@HAVE_DECL_ASINL@ _GL_FUNCDECL_SYS (asinl, long double, (long double x)); diff --git a/m4/asinf.m4 b/m4/asinf.m4 new file mode 100644 index 000000000..ad69aaf18 --- /dev/null +++ b/m4/asinf.m4 @@ -0,0 +1,25 @@ +# asinf.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_ASINF], +[ + AC_REQUIRE([gl_MATH_H_DEFAULTS]) + AC_REQUIRE([gl_FUNC_ASIN]) + + dnl Test whether asinf() exists. Assume that asinf(), if it exists, is + dnl defined in the same library as asin(). + save_LIBS="$LIBS" + LIBS="$LIBS $ASIN_LIBM" + AC_CHECK_FUNCS([asinf]) + LIBS="$save_LIBS" + if test $ac_cv_func_asinf = yes; then + ASINF_LIBM="$ASIN_LIBM" + else + HAVE_ASINF=0 + ASINF_LIBM="$ASIN_LIBM" + fi + AC_SUBST([ASINF_LIBM]) +]) diff --git a/m4/math_h.m4 b/m4/math_h.m4 index 1a78358a3..a705f0184 100644 --- a/m4/math_h.m4 +++ b/m4/math_h.m4 @@ -1,4 +1,4 @@ -# math_h.m4 serial 39 +# math_h.m4 serial 40 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 asinl atanl ceilf ceill cosf cosl + [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 @@ -58,6 +58,7 @@ AC_DEFUN([gl_MATH_MODULE_INDICATOR], 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_ATANL=0; AC_SUBST([GNULIB_ATANL]) GNULIB_CEIL=0; AC_SUBST([GNULIB_CEIL]) @@ -104,6 +105,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS], GNULIB_TRUNCL=0; AC_SUBST([GNULIB_TRUNCL]) dnl Assume proper GNU behavior unless another module says otherwise. HAVE_ACOSL=1; AC_SUBST([HAVE_ACOSL]) + HAVE_ASINF=1; AC_SUBST([HAVE_ASINF]) HAVE_ASINL=1; AC_SUBST([HAVE_ASINL]) HAVE_ATANL=1; AC_SUBST([HAVE_ATANL]) HAVE_COSF=1; AC_SUBST([HAVE_COSF]) diff --git a/modules/asinf b/modules/asinf new file mode 100644 index 000000000..395ff2c27 --- /dev/null +++ b/modules/asinf @@ -0,0 +1,31 @@ +Description: +asinf() function: inverse sine function. + +Files: +lib/asinf.c +m4/asinf.m4 + +Depends-on: +math +asin [test $HAVE_ASINF = 0] + +configure.ac: +gl_FUNC_ASINF +if test $HAVE_ASINF = 0; then + AC_LIBOBJ([asinf]) +fi +gl_MATH_MODULE_INDICATOR([asinf]) + +Makefile.am: + +Include: + + +Link: +$(ASINF_LIBM) + +License: +LGPL + +Maintainer: +Bruno Haible diff --git a/modules/math b/modules/math index 876ddc9d0..d005050af 100644 --- a/modules/math +++ b/modules/math @@ -29,6 +29,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $( -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_ACOSL''@/$(GNULIB_ACOSL)/g' \ + -e 's/@''GNULIB_ASINF''@/$(GNULIB_ASINF)/g' \ -e 's/@''GNULIB_ASINL''@/$(GNULIB_ASINL)/g' \ -e 's/@''GNULIB_ATANL''@/$(GNULIB_ATANL)/g' \ -e 's/@''GNULIB_CEIL''@/$(GNULIB_CEIL)/g' \ @@ -75,6 +76,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $( -e 's/@''GNULIB_TRUNCL''@/$(GNULIB_TRUNCL)/g' \ < $(srcdir)/math.in.h | \ sed -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' \ -e 's|@''HAVE_COSF''@|$(HAVE_COSF)|g' \ diff --git a/tests/test-math-c++.cc b/tests/test-math-c++.cc index a839f8f36..4f82dd8f8 100644 --- a/tests/test-math-c++.cc +++ b/tests/test-math-c++.cc @@ -25,6 +25,9 @@ //SIGNATURE_CHECK (GNULIB_NAMESPACE::acos, double, (double)); +#if GNULIB_TEST_ASINF +SIGNATURE_CHECK (GNULIB_NAMESPACE::asinf, float, (float)); +#endif //SIGNATURE_CHECK (GNULIB_NAMESPACE::asin, double, (double)); //SIGNATURE_CHECK (GNULIB_NAMESPACE::atan, double, (double)); //SIGNATURE_CHECK (GNULIB_NAMESPACE::atan2, double, (double, double));