* lib/math.in.h (modff): New declaration.
* lib/modff.c: New file.
* m4/modff.m4: New file.
* m4/math_h.m4 (gl_MATH_H): Test whether modff is declared.
(gl_MATH_H_DEFAULTS): Initialize GNULIB_MODFF, HAVE_MODFF.
* modules/math (Makefile.am): Substitute GNULIB_MODFF, HAVE_MODFF.
* modules/modff: New file.
* tests/test-math-c++.cc: Check the declaration of modff.
* doc/posix-functions/modff.texi: Mention the new module.
2011-10-05 Bruno Haible <bruno@clisp.org>
+ New module 'modff'.
+ * lib/math.in.h (modff): New declaration.
+ * lib/modff.c: New file.
+ * m4/modff.m4: New file.
+ * m4/math_h.m4 (gl_MATH_H): Test whether modff is declared.
+ (gl_MATH_H_DEFAULTS): Initialize GNULIB_MODFF, HAVE_MODFF.
+ * modules/math (Makefile.am): Substitute GNULIB_MODFF, HAVE_MODFF.
+ * modules/modff: New file.
+ * tests/test-math-c++.cc: Check the declaration of modff.
+ * doc/posix-functions/modff.texi: Mention the new module.
+
modf tests: Make test sharper.
* tests/test-modf.c (main): Strengthen upper bound.
POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/modff.html}
-Gnulib module: ---
+Gnulib module: modff
Portability problems fixed by Gnulib:
@itemize
-@end itemize
-
-Portability problems not fixed by Gnulib:
-@itemize
@item
This function is missing on some platforms:
MacOS X 10.5, Minix 3.1.8, AIX 5.1, HP-UX 11.
@item
-This function is only defined as a macro with arguments on some platforms:
+This function is only defined as a buggy macro with arguments on some platforms:
MSVC 9.
@end itemize
+
+Portability problems not fixed by Gnulib:
+@itemize
+@end itemize
#endif
+#if @GNULIB_MODFF@
+# if !@HAVE_MODFF@
+# undef modff
+_GL_FUNCDECL_SYS (modff, float, (float x, float *iptr) _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (modff, float, (float x, float *iptr));
+_GL_CXXALIASWARN (modff);
+#elif defined GNULIB_POSIXCHECK
+# undef modff
+# if HAVE_RAW_DECL_MODFF
+_GL_WARN_ON_USE (modff, "modff is unportable - "
+ "use gnulib module modff for portability");
+# endif
+#endif
+
+
#if @GNULIB_ROUNDF@
# if @REPLACE_ROUNDF@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
--- /dev/null
+/* Get signed integer and fractional parts of a floating-point number.
+ 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
+modff (float x, float *iptr)
+{
+ double i;
+ double frac = modf ((double) x, &i);
+ *iptr = (float) i;
+ return (float) frac;
+}
-# math_h.m4 serial 27
+# math_h.m4 serial 28
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,
dnl corresponding gnulib module is not in use.
gl_WARN_ON_USE_PREPARE([[#include <math.h>]],
[acosl asinl atanl ceilf ceill cosl expl fabsf floorf floorl fmodf frexpl
- ldexpl logb logl round roundf roundl sinl sqrtl tanl trunc truncf truncl])
+ ldexpl logb logl modff round roundf roundl sinl sqrtl
+ tanl trunc truncf truncl])
])
AC_DEFUN([gl_MATH_MODULE_INDICATOR],
GNULIB_LDEXPL=0; AC_SUBST([GNULIB_LDEXPL])
GNULIB_LOGB=0; AC_SUBST([GNULIB_LOGB])
GNULIB_LOGL=0; AC_SUBST([GNULIB_LOGL])
+ GNULIB_MODFF=0; AC_SUBST([GNULIB_MODFF])
GNULIB_ROUND=0; AC_SUBST([GNULIB_ROUND])
GNULIB_ROUNDF=0; AC_SUBST([GNULIB_ROUNDF])
GNULIB_ROUNDL=0; AC_SUBST([GNULIB_ROUNDL])
HAVE_ISNAND=1; AC_SUBST([HAVE_ISNAND])
HAVE_ISNANL=1; AC_SUBST([HAVE_ISNANL])
HAVE_LOGL=1; AC_SUBST([HAVE_LOGL])
+ HAVE_MODFF=1; AC_SUBST([HAVE_MODFF])
HAVE_SINL=1; AC_SUBST([HAVE_SINL])
HAVE_SQRTL=1; AC_SUBST([HAVE_SQRTL])
HAVE_TANL=1; AC_SUBST([HAVE_TANL])
--- /dev/null
+# modff.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_MODFF],
+[
+ AC_REQUIRE([gl_MATH_H_DEFAULTS])
+ AC_REQUIRE([gl_FUNC_MODF])
+
+ dnl Test whether modff() exists. Assume that modff(), if it exists, is
+ dnl defined in the same library as modf().
+ save_LIBS="$LIBS"
+ LIBS="$LIBS $MODF_LIBM"
+ AC_CHECK_FUNCS([modff])
+ LIBS="$save_LIBS"
+ if test $ac_cv_func_modff = yes; then
+ MODFF_LIBM="$MODF_LIBM"
+ else
+ HAVE_MODFF=0
+ MODFF_LIBM="$MODF_LIBM"
+ fi
+ AC_SUBST([MODFF_LIBM])
+])
-e 's/@''GNULIB_LDEXPL''@/$(GNULIB_LDEXPL)/g' \
-e 's/@''GNULIB_LOGB''@/$(GNULIB_LOGB)/g' \
-e 's/@''GNULIB_LOGL''@/$(GNULIB_LOGL)/g' \
+ -e 's/@''GNULIB_MODFF''@/$(GNULIB_MODFF)/g' \
-e 's/@''GNULIB_ROUND''@/$(GNULIB_ROUND)/g' \
-e 's/@''GNULIB_ROUNDF''@/$(GNULIB_ROUNDF)/g' \
-e 's/@''GNULIB_ROUNDL''@/$(GNULIB_ROUNDL)/g' \
-e 's|@''HAVE_ISNAND''@|$(HAVE_ISNAND)|g' \
-e 's|@''HAVE_ISNANL''@|$(HAVE_ISNANL)|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_SQRTL''@|$(HAVE_SQRTL)|g' \
-e 's|@''HAVE_TANL''@|$(HAVE_TANL)|g' \
--- /dev/null
+Description:
+modff() function: get signed integer and fractional parts.
+
+Files:
+lib/modff.c
+m4/modff.m4
+
+Depends-on:
+math
+modf [test $HAVE_MODFF = 0]
+
+configure.ac:
+gl_FUNC_MODFF
+if test $HAVE_MODFF = 0; then
+ AC_LIBOBJ([modff])
+fi
+gl_MATH_MODULE_INDICATOR([modff])
+
+Makefile.am:
+
+Include:
+<math.h>
+
+Link:
+$(MODFF_LIBM)
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
//SIGNATURE_CHECK (GNULIB_NAMESPACE::log1p, double, (double));
//SIGNATURE_CHECK (GNULIB_NAMESPACE::logb, double, (double));
//SIGNATURE_CHECK (GNULIB_NAMESPACE::log, double, (double));
+#if GNULIB_TEST_MODFF
+SIGNATURE_CHECK (GNULIB_NAMESPACE::modff, float, (float, float *));
+#endif
//SIGNATURE_CHECK (GNULIB_NAMESPACE::modf, double, (double, double *));
//SIGNATURE_CHECK (GNULIB_NAMESPACE::nextafter, double, (double, double));
//SIGNATURE_CHECK (GNULIB_NAMESPACE::pow, double, (double, double));