diff options
author | Bruno Haible <bruno@clisp.org> | 2012-02-27 18:07:29 +0100 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2012-02-27 20:38:16 +0100 |
commit | a66795fc04d933313f4030b87d9da582555e78d7 (patch) | |
tree | c0ab386b17be284b86384c9e19fa4686b97b0d4c /m4/remainder.m4 | |
parent | 5dedf26dd50d9acd31d51cf068fdcf824e6bf25b (diff) | |
download | gnulib-a66795fc04d933313f4030b87d9da582555e78d7.tar.gz |
remainder-ieee: Work around test failure on OSF/1.
* m4/remainder-ieee.m4: New file.
* m4/remainder.m4 (gl_FUNC_REMAINDER): If gl_FUNC_REMAINDER_IEEE is
present, test whether remainder works with a zero second argument.
Replace it if not.
* lib/math.in.h (remainder): Override if REPLACE_REMAINDER is 1.
* m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize REPLACE_REMAINDER.
* modules/math (Makefile.am): Substitute REPLACE_REMAINDER.
* modules/remainder (configure.ac): Consider REPLACE_REMAINDER.
(Depends-on): Update dependencies.
* modules/remainder-ieee (Files): Add m4/remainder-ieee.m4.
(configure.ac): Invoke gl_FUNC_REMAINDER_IEEE.
* doc/posix-functions/remainder.texi: Mention the remainder-ieee module.
Diffstat (limited to 'm4/remainder.m4')
-rw-r--r-- | m4/remainder.m4 | 57 |
1 files changed, 54 insertions, 3 deletions
diff --git a/m4/remainder.m4 b/m4/remainder.m4 index 6cc0001b5f..dc4dbdfe8e 100644 --- a/m4/remainder.m4 +++ b/m4/remainder.m4 @@ -1,4 +1,4 @@ -# remainder.m4 serial 1 +# remainder.m4 serial 2 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, @@ -6,6 +6,7 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_REMAINDER], [ + m4_divert_text([DEFAULTS], [gl_remainder_required=plain]) AC_REQUIRE([gl_MATH_H_DEFAULTS]) dnl Test whether remainder() is declared. On IRIX 5.3 it is not declared. @@ -50,9 +51,59 @@ AC_DEFUN([gl_FUNC_REMAINDER], REMAINDER_LIBM=-lm fi fi - if test $gl_cv_func_remainder_no_libm = no \ - && test $gl_cv_func_remainder_in_libm = no; then + if test $gl_cv_func_remainder_no_libm = yes \ + || test $gl_cv_func_remainder_in_libm = yes; then + : + m4_ifdef([gl_FUNC_REMAINDER_IEEE], [ + if test $gl_remainder_required = ieee && test $REPLACE_REMAINDER = 0; then + AC_CACHE_CHECK([whether remainder works according to ISO C 99 with IEC 60559], + [gl_cv_func_remainder_ieee], + [ + save_LIBS="$LIBS" + LIBS="$LIBS $REMAINDER_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 (double x, double y) +{ + return x == y; +} +static double dummy (double x, double y) { return 0; } +int main (int argc, char *argv[]) +{ + double (*my_remainder) (double, double) = argc ? remainder : dummy; + double i; + double f; + /* Test remainder(...,0.0). + This test fails on OSF/1 5.1. */ + f = my_remainder (2.0, 0.0); + if (numeric_equal (f, f)) + return 1; + return 0; +} + ]])], + [gl_cv_func_remainder_ieee=yes], + [gl_cv_func_remainder_ieee=no], + [gl_cv_func_remainder_ieee="guessing no"]) + LIBS="$save_LIBS" + ]) + case "$gl_cv_func_remainder_ieee" in + *yes) ;; + *) REPLACE_REMAINDER=1 ;; + esac + fi + ]) + else HAVE_REMAINDER=0 + fi + if test $HAVE_REMAINDER = 0 || test $REPLACE_REMAINDER = 1; then dnl Find libraries needed to link lib/remainder.c. AC_REQUIRE([gl_FUNC_ROUND]) AC_REQUIRE([gl_FUNC_FMA]) |