From: Bruno Haible Date: Mon, 27 Feb 2012 04:03:10 +0000 (+0100) Subject: modfl-ieee: Work around test failures on IRIX, OSF/1, mingw. X-Git-Tag: v0.1~1055 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=579928caf1c6bb983cbba7ee18603c077be78392;p=gnulib.git modfl-ieee: Work around test failures on IRIX, OSF/1, mingw. * m4/modfl-ieee.m4: New file. * m4/modfl.m4 (gl_FUNC_MODFL): If gl_FUNC_MODFL_IEEE is present, test whether modfl works with Inf. Replace it if not. * lib/math.in.h (modfl): Override if REPLACE_MODFF is 1. * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize REPLACE_MODFL. * modules/math (Makefile.am): Substitute REPLACE_MODFL. * modules/modfl (configure.ac): Consider REPLACE_MODFL. (Depends-on): Update dependencies. * modules/modfl-ieee (Files): Add m4/modfl-ieee.m4, m4/minus-zero.m4, m4/signbit.m4. (configure.ac): Invoke gl_FUNC_MODFL_IEEE. * doc/posix-functions/modfl.texi: Mention the modfl-ieee module. --- diff --git a/ChangeLog b/ChangeLog index f0c8d6ca9..ed9c384c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,19 @@ 2012-02-26 Bruno Haible + modfl-ieee: Work around test failures on IRIX, OSF/1, mingw. + * m4/modfl-ieee.m4: New file. + * m4/modfl.m4 (gl_FUNC_MODFL): If gl_FUNC_MODFL_IEEE is present, test + whether modfl works with Inf. Replace it if not. + * lib/math.in.h (modfl): Override if REPLACE_MODFF is 1. + * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize REPLACE_MODFL. + * modules/math (Makefile.am): Substitute REPLACE_MODFL. + * modules/modfl (configure.ac): Consider REPLACE_MODFL. + (Depends-on): Update dependencies. + * modules/modfl-ieee (Files): Add m4/modfl-ieee.m4, m4/minus-zero.m4, + m4/signbit.m4. + (configure.ac): Invoke gl_FUNC_MODFL_IEEE. + * doc/posix-functions/modfl.texi: Mention the modfl-ieee module. + modfl-ieee: Fix dependencies. * modules/modfl-ieee (Depends-on): Add modf-ieee. diff --git a/doc/posix-functions/modfl.texi b/doc/posix-functions/modfl.texi index cb16466cc..b246e35d4 100644 --- a/doc/posix-functions/modfl.texi +++ b/doc/posix-functions/modfl.texi @@ -4,9 +4,9 @@ POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/modfl.html} -Gnulib module: modfl +Gnulib module: modfl or modfl-ieee -Portability problems fixed by Gnulib: +Portability problems fixed by either Gnulib module @code{modfl} or @code{modfl-ieee}: @itemize @item This function is missing on some platforms: @@ -16,6 +16,13 @@ This function is only defined as a macro with arguments on some platforms: MSVC 9. @end itemize +Portability problems fixed by Gnulib module @code{modfl-ieee}: +@itemize +@item +This function has problems with infinite arguments on some platforms: +IRIX 6.5, OSF/1 5.1, mingw. +@end itemize + Portability problems not fixed by Gnulib: @itemize @end itemize diff --git a/lib/math.in.h b/lib/math.in.h index b5fc9164d..721ddf500 100644 --- a/lib/math.in.h +++ b/lib/math.in.h @@ -910,12 +910,22 @@ _GL_WARN_ON_USE (modf, "modf has portability problems - " #endif #if @GNULIB_MODFL@ -# if !@HAVE_MODFL@ -# undef modfl +# if @REPLACE_MODFL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef modfl +# define modfl rpl_modfl +# endif +_GL_FUNCDECL_RPL (modfl, long double, (long double x, long double *iptr) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (modfl, long double, (long double x, long double *iptr)); +# else +# if !@HAVE_MODFL@ +# undef modfl _GL_FUNCDECL_SYS (modfl, long double, (long double x, long double *iptr) _GL_ARG_NONNULL ((2))); -# endif +# endif _GL_CXXALIAS_SYS (modfl, long double, (long double x, long double *iptr)); +# endif _GL_CXXALIASWARN (modfl); #elif defined GNULIB_POSIXCHECK # undef modfl diff --git a/m4/math_h.m4 b/m4/math_h.m4 index 8afa4ba7d..5eb83efca 100644 --- a/m4/math_h.m4 +++ b/m4/math_h.m4 @@ -1,4 +1,4 @@ -# math_h.m4 serial 65 +# math_h.m4 serial 66 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, @@ -222,6 +222,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS], REPLACE_LDEXPL=0; AC_SUBST([REPLACE_LDEXPL]) REPLACE_MODF=0; AC_SUBST([REPLACE_MODF]) REPLACE_MODFF=0; AC_SUBST([REPLACE_MODFF]) + REPLACE_MODFL=0; AC_SUBST([REPLACE_MODFL]) REPLACE_NAN=0; AC_SUBST([REPLACE_NAN]) REPLACE_ROUND=0; AC_SUBST([REPLACE_ROUND]) REPLACE_ROUNDF=0; AC_SUBST([REPLACE_ROUNDF]) diff --git a/m4/modfl-ieee.m4 b/m4/modfl-ieee.m4 new file mode 100644 index 000000000..04b6112b6 --- /dev/null +++ b/m4/modfl-ieee.m4 @@ -0,0 +1,15 @@ +# modfl-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 modfl.m4 and not inlined in the +dnl module description), so that gl_FUNC_MODFL can test whether 'aclocal' has +dnl found uses of this macro. + +AC_DEFUN([gl_FUNC_MODFL_IEEE], +[ + m4_divert_text([INIT_PREPARE], [gl_modfl_required=ieee]) + AC_REQUIRE([gl_FUNC_MODFL]) +]) diff --git a/m4/modfl.m4 b/m4/modfl.m4 index 98aa36389..7764eb226 100644 --- a/m4/modfl.m4 +++ b/m4/modfl.m4 @@ -6,6 +6,7 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_MODFL], [ + m4_divert_text([DEFAULTS], [gl_modfl_required=plain]) AC_REQUIRE([gl_MATH_H_DEFAULTS]) AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE]) @@ -13,9 +14,63 @@ AC_DEFUN([gl_FUNC_MODFL], dnl exists, is defined in the same library as modf(). This is not the case dnl on FreeBSD, Solaris. gl_MATHFUNC([modfl], [long double], [(long double, long double *)]) - if test $gl_cv_func_modfl_no_libm = no \ - && test $gl_cv_func_modfl_in_libm = no; then + if test $gl_cv_func_modfl_no_libm = yes \ + || test $gl_cv_func_modfl_in_libm = yes; then + m4_ifdef([gl_FUNC_MODFL_IEEE], [ + if test $gl_modfl_required = ieee && test $REPLACE_MODFL = 0; then + AC_CACHE_CHECK([whether modfl works according to ISO C 99 with IEC 60559], + [gl_cv_func_modfl_ieee], + [ + save_LIBS="$LIBS" + LIBS="$LIBS $MODFL_LIBM" + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#ifndef __NO_MATH_INLINES +# define __NO_MATH_INLINES 1 /* for glibc */ +#endif +#include +]gl_LONG_DOUBLE_MINUS_ZERO_CODE[ +]gl_LONG_DOUBLE_SIGNBIT_CODE[ +/* Compare two numbers with ==. + This is a separate function because IRIX 6.5 "cc -O" miscompiles an + 'x == x' test. */ +static int +numeric_equal (long double x, long double y) +{ + return x == y; +} +static long double dummy (long double x, long double *iptr) { return 0; } +long double zero; +long double minus_one = - 1.0L; +int main (int argc, char *argv[]) +{ + long double (*my_modfl) (long double, long double *) = argc ? modfl : dummy; + long double i; + long double f; + /* Test modfl(-Inf,...). + This test fails on IRIX 6.5, OSF/1 5.1, mingw. */ + f = my_modfl (minus_one / zero, &i); + if (!(f == 0.0L) || (signbitl (minus_zerol) && !signbitl (f))) + return 1; + return 0; +} + ]])], + [gl_cv_func_modfl_ieee=yes], + [gl_cv_func_modfl_ieee=no], + [gl_cv_func_modfl_ieee="guessing no"]) + LIBS="$save_LIBS" + ]) + case "$gl_cv_func_modfl_ieee" in + *yes) ;; + *) REPLACE_MODFL=1 ;; + esac + fi + ]) + else HAVE_MODFL=0 + fi + if test $HAVE_MODFL = 0 || test $REPLACE_MODFL = 1; then + dnl Find libraries needed to link lib/modfl.c. if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then AC_REQUIRE([gl_FUNC_MODF]) MODFL_LIBM="$MODF_LIBM" diff --git a/modules/math b/modules/math index 8e8ff5689..189cc80e7 100644 --- a/modules/math +++ b/modules/math @@ -193,6 +193,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $( -e 's|@''REPLACE_LDEXPL''@|$(REPLACE_LDEXPL)|g' \ -e 's|@''REPLACE_MODF''@|$(REPLACE_MODF)|g' \ -e 's|@''REPLACE_MODFF''@|$(REPLACE_MODFF)|g' \ + -e 's|@''REPLACE_MODFL''@|$(REPLACE_MODFL)|g' \ -e 's|@''REPLACE_NAN''@|$(REPLACE_NAN)|g' \ -e 's|@''REPLACE_ROUND''@|$(REPLACE_ROUND)|g' \ -e 's|@''REPLACE_ROUNDF''@|$(REPLACE_ROUNDF)|g' \ diff --git a/modules/modfl b/modules/modfl index 3456a4c58..c2f414b8a 100644 --- a/modules/modfl +++ b/modules/modfl @@ -8,14 +8,14 @@ m4/mathfunc.m4 Depends-on: math -modf [test $HAVE_MODFL = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1] -isfinite [test $HAVE_MODFL = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0] -truncl [test $HAVE_MODFL = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0] -isinf [test $HAVE_MODFL = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0] +modf [{ test $HAVE_MODFL = 0 || test $REPLACE_MODFL = 1; } && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1] +isfinite [{ test $HAVE_MODFL = 0 || test $REPLACE_MODFL = 1; } && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0] +truncl [{ test $HAVE_MODFL = 0 || test $REPLACE_MODFL = 1; } && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0] +isinf [{ test $HAVE_MODFL = 0 || test $REPLACE_MODFL = 1; } && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0] configure.ac: gl_FUNC_MODFL -if test $HAVE_MODFL = 0; then +if test $HAVE_MODFL = 0 || test $REPLACE_MODFL = 1; then AC_LIBOBJ([modfl]) fi gl_MATH_MODULE_INDICATOR([modfl]) diff --git a/modules/modfl-ieee b/modules/modfl-ieee index 43475f99a..6cf466680 100644 --- a/modules/modfl-ieee +++ b/modules/modfl-ieee @@ -2,6 +2,9 @@ Description: modfl() function according to ISO C 99 with IEC 60559. Files: +m4/modfl-ieee.m4 +m4/minus-zero.m4 +m4/signbit.m4 Depends-on: modfl @@ -9,6 +12,7 @@ fpieee modf-ieee [test $HAVE_MODFL = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1] configure.ac: +gl_FUNC_MODFL_IEEE Makefile.am: