* 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>
+
+ 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.
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.
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
#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));
--- /dev/null
+/* 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);
+}
-# 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,
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])
])
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])
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])
--- /dev/null
+# 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])
+])
-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' \
-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' \
--- /dev/null
+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
//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));