Mercurial > hg > octave-lyh > gnulib-hg
changeset 15857:6b8400199763
New module 'sqrtf'.
* lib/math.in.h (sqrtf): New declaration.
* lib/sqrtf.c: New file.
* m4/sqrtf.m4: New file.
* m4/math_h.m4 (gl_MATH_H): Test whether sqrtf is declared.
(gl_MATH_H_DEFAULTS): Initialize GNULIB_SQRTF, HAVE_SQRTF.
* modules/math (Makefile.am): Substitute GNULIB_SQRTF, HAVE_SQRTF.
* modules/sqrtf: New file.
* tests/test-math-c++.cc: Check the declaration of sqrtf.
* doc/posix-functions/sqrtf.texi: Mention the new module.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sat, 08 Oct 2011 21:16:48 +0200 |
parents | 3251de063435 |
children | 827bfe5e7bdd |
files | ChangeLog doc/posix-functions/sqrtf.texi lib/math.in.h lib/sqrtf.c m4/math_h.m4 m4/sqrtf.m4 modules/math modules/sqrtf tests/test-math-c++.cc |
diffstat | 9 files changed, 124 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2011-10-08 Bruno Haible <bruno@clisp.org> + + New module 'sqrtf'. + * lib/math.in.h (sqrtf): New declaration. + * lib/sqrtf.c: New file. + * m4/sqrtf.m4: New file. + * m4/math_h.m4 (gl_MATH_H): Test whether sqrtf is declared. + (gl_MATH_H_DEFAULTS): Initialize GNULIB_SQRTF, HAVE_SQRTF. + * modules/math (Makefile.am): Substitute GNULIB_SQRTF, HAVE_SQRTF. + * modules/sqrtf: New file. + * tests/test-math-c++.cc: Check the declaration of sqrtf. + * doc/posix-functions/sqrtf.texi: Mention the new module. + 2011-10-08 Bruno Haible <bruno@clisp.org> Tests: Avoid link failures w.r.t. libintl.
--- a/doc/posix-functions/sqrtf.texi +++ b/doc/posix-functions/sqrtf.texi @@ -4,14 +4,10 @@ POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/sqrtf.html} -Gnulib module: --- +Gnulib module: sqrtf 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
--- a/lib/math.in.h +++ b/lib/math.in.h @@ -600,6 +600,21 @@ #endif +#if @GNULIB_SQRTF@ +# if !@HAVE_SQRTF@ +# undef sqrtf +_GL_FUNCDECL_SYS (sqrtf, float, (float x)); +# endif +_GL_CXXALIAS_SYS (sqrtf, float, (float x)); +_GL_CXXALIASWARN (sqrtf); +#elif defined GNULIB_POSIXCHECK +# undef sqrtf +# if HAVE_RAW_DECL_SQRTF +_GL_WARN_ON_USE (sqrtf, "sqrtf is unportable - " + "use gnulib module sqrtf for portability"); +# endif +#endif + #if @GNULIB_SQRTL@ # if !@HAVE_SQRTL@ || !@HAVE_DECL_SQRTL@ _GL_FUNCDECL_SYS (sqrtl, long double, (long double x));
new file mode 100644 --- /dev/null +++ b/lib/sqrtf.c @@ -0,0 +1,26 @@ +/* Square root. + 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 +sqrtf (float x) +{ + return (float) sqrt ((double) x); +}
--- a/m4/math_h.m4 +++ b/m4/math_h.m4 @@ -1,4 +1,4 @@ -# math_h.m4 serial 31 +# math_h.m4 serial 32 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, @@ -41,7 +41,7 @@ gl_WARN_ON_USE_PREPARE([[#include <math.h>]], [acosl asinl atanl ceilf ceill cosl expl fabsf floorf floorl fmodf frexpf frexpl - ldexpf ldexpl logb logl modff round roundf roundl sinl sqrtl + ldexpf ldexpl logb logl modff round roundf roundl sinl sqrtf sqrtl tanl trunc truncf truncl]) ]) @@ -88,6 +88,7 @@ GNULIB_ROUNDL=0; AC_SUBST([GNULIB_ROUNDL]) GNULIB_SIGNBIT=0; AC_SUBST([GNULIB_SIGNBIT]) GNULIB_SINL=0; AC_SUBST([GNULIB_SINL]) + GNULIB_SQRTF=0; AC_SUBST([GNULIB_SQRTF]) GNULIB_SQRTL=0; AC_SUBST([GNULIB_SQRTL]) GNULIB_TANL=0; AC_SUBST([GNULIB_TANL]) GNULIB_TRUNC=0; AC_SUBST([GNULIB_TRUNC]) @@ -109,6 +110,7 @@ HAVE_LOGL=1; AC_SUBST([HAVE_LOGL]) HAVE_MODFF=1; AC_SUBST([HAVE_MODFF]) HAVE_SINL=1; AC_SUBST([HAVE_SINL]) + HAVE_SQRTF=1; AC_SUBST([HAVE_SQRTF]) HAVE_SQRTL=1; AC_SUBST([HAVE_SQRTL]) HAVE_TANL=1; AC_SUBST([HAVE_TANL]) HAVE_DECL_ACOSL=1; AC_SUBST([HAVE_DECL_ACOSL])
new file mode 100644 --- /dev/null +++ b/m4/sqrtf.m4 @@ -0,0 +1,25 @@ +# sqrtf.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_SQRTF], +[ + AC_REQUIRE([gl_MATH_H_DEFAULTS]) + AC_REQUIRE([gl_FUNC_SQRT]) + + dnl Test whether sqrtf() exists. Assume that sqrtf(), if it exists, is + dnl defined in the same library as sqrt(). + save_LIBS="$LIBS" + LIBS="$LIBS $SQRT_LIBM" + AC_CHECK_FUNCS([sqrtf]) + LIBS="$save_LIBS" + if test $ac_cv_func_sqrtf = yes; then + SQRTF_LIBM="$SQRT_LIBM" + else + HAVE_SQRTF=0 + SQRTF_LIBM="$SQRT_LIBM" + fi + AC_SUBST([SQRTF_LIBM]) +])
--- a/modules/math +++ b/modules/math @@ -60,6 +60,7 @@ -e 's/@''GNULIB_ROUNDL''@/$(GNULIB_ROUNDL)/g' \ -e 's/@''GNULIB_SIGNBIT''@/$(GNULIB_SIGNBIT)/g' \ -e 's/@''GNULIB_SINL''@/$(GNULIB_SINL)/g' \ + -e 's/@''GNULIB_SQRTF''@/$(GNULIB_SQRTF)/g' \ -e 's/@''GNULIB_SQRTL''@/$(GNULIB_SQRTL)/g' \ -e 's/@''GNULIB_TANL''@/$(GNULIB_TANL)/g' \ -e 's/@''GNULIB_TRUNC''@/$(GNULIB_TRUNC)/g' \ @@ -81,6 +82,7 @@ -e 's|@''HAVE_LOGL''@|$(HAVE_LOGL)|g' \ -e 's|@''HAVE_MODFF''@|$(HAVE_MODFF)|g' \ -e 's|@''HAVE_SINL''@|$(HAVE_SINL)|g' \ + -e 's|@''HAVE_SQRTF''@|$(HAVE_SQRTF)|g' \ -e 's|@''HAVE_SQRTL''@|$(HAVE_SQRTL)|g' \ -e 's|@''HAVE_TANL''@|$(HAVE_TANL)|g' \ -e 's|@''HAVE_DECL_ACOSL''@|$(HAVE_DECL_ACOSL)|g' \
new file mode 100644 --- /dev/null +++ b/modules/sqrtf @@ -0,0 +1,31 @@ +Description: +sqrtf() function: square root. + +Files: +lib/sqrtf.c +m4/sqrtf.m4 + +Depends-on: +math +sqrt [test $HAVE_SQRTF = 0] + +configure.ac: +gl_FUNC_SQRTF +if test $HAVE_SQRTF = 0; then + AC_LIBOBJ([sqrtf]) +fi +gl_MATH_MODULE_INDICATOR([sqrtf]) + +Makefile.am: + +Include: +<math.h> + +Link: +$(SQRTF_LIBM) + +License: +LGPL + +Maintainer: +Bruno Haible
--- a/tests/test-math-c++.cc +++ b/tests/test-math-c++.cc @@ -72,6 +72,9 @@ //SIGNATURE_CHECK (GNULIB_NAMESPACE::rint, double, (double)); //SIGNATURE_CHECK (GNULIB_NAMESPACE::sin, double, (double)); //SIGNATURE_CHECK (GNULIB_NAMESPACE::sinh, double, (double)); +#if GNULIB_TEST_SQRTF +SIGNATURE_CHECK (GNULIB_NAMESPACE::sqrtf, float, (float)); +#endif //SIGNATURE_CHECK (GNULIB_NAMESPACE::sqrt, double, (double)); //SIGNATURE_CHECK (GNULIB_NAMESPACE::tan, double, (double)); //SIGNATURE_CHECK (GNULIB_NAMESPACE::tanh, double, (double));