* m4/fmodf-ieee.m4: New file.
* m4/fmodf.m4 (gl_FUNC_FMODF): If gl_FUNC_FMODF_IEEE is present, test
whether fmodf works with zero arguments. Replace it if not.
* lib/math.in.h (fmodf): Override if REPLACE_FMODF is 1.
* m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize REPLACE_FMODF.
* modules/math (Makefile.am): Substitute REPLACE_FMODF.
* modules/fmodf (configure.ac): Consider REPLACE_FMODF.
(Depends-on): Update dependencies.
* modules/fmodf-ieee (Files): Add m4/fmodf-ieee.m4.
(configure.ac): Invoke gl_FUNC_FMODF_IEEE.
* doc/posix-functions/fmodf.texi: Mention the problem on OSF/1.
2012-02-27 Bruno Haible <bruno@clisp.org>
+ fmodf-ieee: Work around test failure on OSF/1.
+ * m4/fmodf-ieee.m4: New file.
+ * m4/fmodf.m4 (gl_FUNC_FMODF): If gl_FUNC_FMODF_IEEE is present, test
+ whether fmodf works with zero arguments. Replace it if not.
+ * lib/math.in.h (fmodf): Override if REPLACE_FMODF is 1.
+ * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize REPLACE_FMODF.
+ * modules/math (Makefile.am): Substitute REPLACE_FMODF.
+ * modules/fmodf (configure.ac): Consider REPLACE_FMODF.
+ (Depends-on): Update dependencies.
+ * modules/fmodf-ieee (Files): Add m4/fmodf-ieee.m4.
+ (configure.ac): Invoke gl_FUNC_FMODF_IEEE.
+ * doc/posix-functions/fmodf.texi: Mention the problem on OSF/1.
+
fmodf-ieee: Work around test failure on MSVC 9.
* modules/fmodf-ieee (Depends-on): Add fmod-ieee.
* doc/posix-functions/fmodf.texi: Mention the fmodf-ieee module.
Portability problems fixed by Gnulib module @code{fmodf-ieee}:
@itemize
@item
+This function has problems when the second argument is zero on some platforms:
+OSF/1 5.1.
+@item
This function has problems when the first argument is minus zero on some
platforms:
MSVC 9.
#if @GNULIB_FMODF@
-# if !@HAVE_FMODF@
-# undef fmodf
+# if @REPLACE_FMODF@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef fmodf
+# define fmodf rpl_fmodf
+# endif
+_GL_FUNCDECL_RPL (fmodf, float, (float x, float y));
+_GL_CXXALIAS_RPL (fmodf, float, (float x, float y));
+# else
+# if !@HAVE_FMODF@
+# undef fmodf
_GL_FUNCDECL_SYS (fmodf, float, (float x, float y));
-# endif
+# endif
_GL_CXXALIAS_SYS (fmodf, float, (float x, float y));
+# endif
_GL_CXXALIASWARN (fmodf);
#elif defined GNULIB_POSIXCHECK
# undef fmodf
--- /dev/null
+# fmodf-ieee.m4 serial 1
+dnl Copyright (C) 2012 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.
+
+dnl This macro is in a separate file (not in fmodf.m4 and not inlined in the
+dnl module description), so that gl_FUNC_FMODF can test whether 'aclocal' has
+dnl found uses of this macro.
+
+AC_DEFUN([gl_FUNC_FMODF_IEEE],
+[
+ m4_divert_text([INIT_PREPARE], [gl_fmodf_required=ieee])
+ AC_REQUIRE([gl_FUNC_FMODF])
+])
-# fmodf.m4 serial 1
+# fmodf.m4 serial 2
dnl Copyright (C) 2011-2012 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
AC_DEFUN([gl_FUNC_FMODF],
[
+ m4_divert_text([DEFAULTS], [gl_fmodf_required=plain])
AC_REQUIRE([gl_MATH_H_DEFAULTS])
AC_REQUIRE([gl_FUNC_FMOD])
LIBS="$save_LIBS"
if test $ac_cv_func_fmodf = yes; then
FMODF_LIBM="$FMOD_LIBM"
+ m4_ifdef([gl_FUNC_FMODF_IEEE], [
+ if test $gl_fmodf_required = ieee && test $REPLACE_FMODF = 0; then
+ AC_CACHE_CHECK([whether fmodf works according to ISO C 99 with IEC 60559],
+ [gl_cv_func_fmodf_ieee],
+ [
+ save_LIBS="$LIBS"
+ LIBS="$LIBS $FMODF_LIBM"
+ AC_RUN_IFELSE(
+ [AC_LANG_SOURCE([[
+#ifndef __NO_MATH_INLINES
+# define __NO_MATH_INLINES 1 /* for glibc */
+#endif
+#include <math.h>
+/* Compare two numbers with ==.
+ This is a separate function because IRIX 6.5 "cc -O" miscompiles an
+ 'x == x' test. */
+static int
+numeric_equal (float x, float y)
+{
+ return x == y;
+}
+static float dummy (float x, float y) { return 0; }
+int main (int argc, char *argv[])
+{
+ float (*my_fmodf) (float, float) = argc ? fmodf : dummy;
+ float i;
+ float f;
+ /* Test fmodf(...,0.0f).
+ This test fails on OSF/1 5.1. */
+ f = my_fmodf (2.0f, 0.0f);
+ if (numeric_equal (f, f))
+ return 1;
+ return 0;
+}
+ ]])],
+ [gl_cv_func_fmodf_ieee=yes],
+ [gl_cv_func_fmodf_ieee=no],
+ [gl_cv_func_fmodf_ieee="guessing no"])
+ LIBS="$save_LIBS"
+ ])
+ case "$gl_cv_func_fmodf_ieee" in
+ *yes) ;;
+ *) REPLACE_FMODF=1 ;;
+ esac
+ fi
+ ])
else
HAVE_FMODF=0
+ fi
+ if test $HAVE_FMODF = 0 || test $REPLACE_FMODF = 1; then
+ dnl Find libraries needed to link lib/fmodf.c.
FMODF_LIBM="$FMOD_LIBM"
fi
AC_SUBST([FMODF_LIBM])
-# math_h.m4 serial 67
+# math_h.m4 serial 68
dnl Copyright (C) 2007-2012 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
REPLACE_FMAF=0; AC_SUBST([REPLACE_FMAF])
REPLACE_FMAL=0; AC_SUBST([REPLACE_FMAL])
REPLACE_FMOD=0; AC_SUBST([REPLACE_FMOD])
+ REPLACE_FMODF=0; AC_SUBST([REPLACE_FMODF])
REPLACE_FMODL=0; AC_SUBST([REPLACE_FMODL])
REPLACE_FREXPF=0; AC_SUBST([REPLACE_FREXPF])
REPLACE_FREXP=0; AC_SUBST([REPLACE_FREXP])
Depends-on:
math
-fmod [test $HAVE_FMODF = 0]
+fmod [test $HAVE_FMODF = 0 || test $REPLACE_FMODF = 1]
configure.ac:
gl_FUNC_FMODF
-if test $HAVE_FMODF = 0; then
+if test $HAVE_FMODF = 0 || test $REPLACE_FMODF = 1; then
AC_LIBOBJ([fmodf])
fi
gl_MATH_MODULE_INDICATOR([fmodf])
fmodf() function according to ISO C 99 with IEC 60559.
Files:
+m4/fmodf-ieee.m4
Depends-on:
fmodf
fmod-ieee [test $HAVE_FMODF = 0]
configure.ac:
+gl_FUNC_FMODF_IEEE
Makefile.am:
-e 's|@''REPLACE_FMAF''@|$(REPLACE_FMAF)|g' \
-e 's|@''REPLACE_FMAL''@|$(REPLACE_FMAL)|g' \
-e 's|@''REPLACE_FMOD''@|$(REPLACE_FMOD)|g' \
+ -e 's|@''REPLACE_FMODF''@|$(REPLACE_FMODF)|g' \
-e 's|@''REPLACE_FMODL''@|$(REPLACE_FMODL)|g' \
-e 's|@''REPLACE_FREXPF''@|$(REPLACE_FREXPF)|g' \
-e 's|@''REPLACE_FREXP''@|$(REPLACE_FREXP)|g' \