summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2012-02-27 13:18:57 +0100
committerBruno Haible <bruno@clisp.org>2012-02-27 13:18:57 +0100
commit6a43f7b2199b69e39f804fd7b432f86f10c66e0e (patch)
tree5ed0acb6635eac9de6b4970e3f9f81286d226c6c
parent34932c93e2dbb16636664ae6e0f954fcce289047 (diff)
downloadgnulib-6a43f7b2199b69e39f804fd7b432f86f10c66e0e.tar.gz
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.
-rw-r--r--ChangeLog13
-rw-r--r--doc/posix-functions/fmodf.texi3
-rw-r--r--lib/math.in.h15
-rw-r--r--m4/fmodf-ieee.m415
-rw-r--r--m4/fmodf.m452
-rw-r--r--m4/math_h.m43
-rw-r--r--modules/fmodf4
-rw-r--r--modules/fmodf-ieee2
-rw-r--r--modules/math1
9 files changed, 101 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index ea481d26c6..cbd22733d6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
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.
diff --git a/doc/posix-functions/fmodf.texi b/doc/posix-functions/fmodf.texi
index 68ff51b659..27e6638ea6 100644
--- a/doc/posix-functions/fmodf.texi
+++ b/doc/posix-functions/fmodf.texi
@@ -19,6 +19,9 @@ MSVC 9.
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.
diff --git a/lib/math.in.h b/lib/math.in.h
index abbfc6291a..219104116b 100644
--- a/lib/math.in.h
+++ b/lib/math.in.h
@@ -615,11 +615,20 @@ _GL_WARN_ON_USE (fmal, "fmal is unportable - "
#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
diff --git a/m4/fmodf-ieee.m4 b/m4/fmodf-ieee.m4
new file mode 100644
index 0000000000..883b0bec5b
--- /dev/null
+++ b/m4/fmodf-ieee.m4
@@ -0,0 +1,15 @@
+# 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])
+])
diff --git a/m4/fmodf.m4 b/m4/fmodf.m4
index cc0e666c0d..812140d6f7 100644
--- a/m4/fmodf.m4
+++ b/m4/fmodf.m4
@@ -1,4 +1,4 @@
-# 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,
@@ -6,6 +6,7 @@ dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_FUNC_FMODF],
[
+ m4_divert_text([DEFAULTS], [gl_fmodf_required=plain])
AC_REQUIRE([gl_MATH_H_DEFAULTS])
AC_REQUIRE([gl_FUNC_FMOD])
@@ -17,8 +18,57 @@ AC_DEFUN([gl_FUNC_FMODF],
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])
diff --git a/m4/math_h.m4 b/m4/math_h.m4
index 81c9da9513..34885e0a82 100644
--- a/m4/math_h.m4
+++ b/m4/math_h.m4
@@ -1,4 +1,4 @@
-# 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,
@@ -214,6 +214,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
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])
diff --git a/modules/fmodf b/modules/fmodf
index 705ce3b938..fa49437a64 100644
--- a/modules/fmodf
+++ b/modules/fmodf
@@ -7,11 +7,11 @@ m4/fmodf.m4
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])
diff --git a/modules/fmodf-ieee b/modules/fmodf-ieee
index 9569c9173f..b4e33b9458 100644
--- a/modules/fmodf-ieee
+++ b/modules/fmodf-ieee
@@ -2,6 +2,7 @@ Description:
fmodf() function according to ISO C 99 with IEC 60559.
Files:
+m4/fmodf-ieee.m4
Depends-on:
fmodf
@@ -9,6 +10,7 @@ fpieee
fmod-ieee [test $HAVE_FMODF = 0]
configure.ac:
+gl_FUNC_FMODF_IEEE
Makefile.am:
diff --git a/modules/math b/modules/math
index 8dd0625305..612aebedd9 100644
--- a/modules/math
+++ b/modules/math
@@ -183,6 +183,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
-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' \