>From 5b490ef07f257a5dd41fc0b351c1a387b8a8f89c Mon Sep 17 00:00:00 2001 From: Bruno Haible
Date: Mon, 21 Jan 2019 00:33:28 +0100 Subject: [PATCH 6/6] rintl: Override broken implementation on NetBSD. * lib/math.in.h (rintl): Test also REPLACE_RINTL. * m4/rintl.m4 (gl_FUNC_RINTL): Add test for negative arguments. Set REPLACE_RINTL. * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize REPLACE_RINTL. * modules/math (Makefile.in): Substitute REPLACE_RINTL. * modules/rintl (Depends-on, configure.ac): Test REPLACE_RINTL. * doc/posix-functions/rintl.texi: Mention the NetBSD bug. --- ChangeLog | 11 ++++++++ doc/posix-functions/rintl.texi | 3 +++ lib/math.in.h | 13 ++++++++-- m4/math_h.m4 | 3 ++- m4/rintl.m4 | 58 +++++++++++++++++++++++++++++++++++++++--- modules/math | 1 + modules/rintl | 4 +-- 7 files changed, 85 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 00516b2..3f40cc4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2019-01-20 Bruno Haible + rintl: Override broken implementation on NetBSD. + * lib/math.in.h (rintl): Test also REPLACE_RINTL. + * m4/rintl.m4 (gl_FUNC_RINTL): Add test for negative arguments. Set + REPLACE_RINTL. + * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize REPLACE_RINTL. + * modules/math (Makefile.in): Substitute REPLACE_RINTL. + * modules/rintl (Depends-on, configure.ac): Test REPLACE_RINTL. + * doc/posix-functions/rintl.texi: Mention the NetBSD bug. + +2019-01-20 Bruno Haible + log10l: Work around inaccurate implementation on NetBSD. * m4/log10l.m4 (gl_FUNC_LOG10L_WORKS): Add test for a certain accuracy. * lib/log10l.c: Comment out too simplistic override. diff --git a/doc/posix-functions/rintl.texi b/doc/posix-functions/rintl.texi index d843544..26f50f5 100644 --- a/doc/posix-functions/rintl.texi +++ b/doc/posix-functions/rintl.texi @@ -11,6 +11,9 @@ Portability problems fixed by Gnulib: @item This function is missing on some platforms: FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 5.1, HP-UX 11, IRIX 6.5, Solaris 9, Cygwin 1.5.x, MSVC 9, Interix 3.5, BeOS, Android 4.4. address@hidden +This function produces wrong results for negative numbers on some platforms: +NetBSD 8.0. @end itemize Portability problems not fixed by Gnulib: diff --git a/lib/math.in.h b/lib/math.in.h index 270caaf..aa03ea3 100644 --- a/lib/math.in.h +++ b/lib/math.in.h @@ -1845,10 +1845,19 @@ _GL_WARN_ON_USE (rint, "rint is unportable - " #endif #if @GNULIB_RINTL@ -# if address@hidden@ +# if @REPLACE_RINTL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef rintl +# define rintl rpl_rintl +# endif +_GL_FUNCDECL_RPL (rintl, long double, (long double x)); +_GL_CXXALIAS_RPL (rintl, long double, (long double x)); +# else +# if address@hidden@ _GL_FUNCDECL_SYS (rintl, long double, (long double x)); -# endif +# endif _GL_CXXALIAS_SYS (rintl, long double, (long double x)); +# endif _GL_CXXALIASWARN (rintl); #elif defined GNULIB_POSIXCHECK # undef rintl diff --git a/m4/math_h.m4 b/m4/math_h.m4 index bbbe5d4..3d5af84 100644 --- a/m4/math_h.m4 +++ b/m4/math_h.m4 @@ -1,4 +1,4 @@ -# math_h.m4 serial 118 +# math_h.m4 serial 119 dnl Copyright (C) 2007-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -320,6 +320,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS], REPLACE_REMAINDER=0; AC_SUBST([REPLACE_REMAINDER]) REPLACE_REMAINDERF=0; AC_SUBST([REPLACE_REMAINDERF]) REPLACE_REMAINDERL=0; AC_SUBST([REPLACE_REMAINDERL]) + REPLACE_RINTL=0; AC_SUBST([REPLACE_RINTL]) REPLACE_ROUND=0; AC_SUBST([REPLACE_ROUND]) REPLACE_ROUNDF=0; AC_SUBST([REPLACE_ROUNDF]) REPLACE_ROUNDL=0; AC_SUBST([REPLACE_ROUNDL]) diff --git a/m4/rintl.m4 b/m4/rintl.m4 index fc40a5b..6683119 100644 --- a/m4/rintl.m4 +++ b/m4/rintl.m4 @@ -1,4 +1,4 @@ -# rintl.m4 serial 4 +# rintl.m4 serial 5 dnl Copyright (C) 2011-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -14,9 +14,61 @@ AC_DEFUN([gl_FUNC_RINTL], dnl Determine RINTL_LIBM. gl_MATHFUNC([rintl], [long double], [(long double)]) - if test $gl_cv_func_rintl_no_libm = no \ - && test $gl_cv_func_rintl_in_libm = no; then + if test $gl_cv_func_rintl_no_libm = yes \ + || test $gl_cv_func_rintl_in_libm = yes; then + if test $REPLACE_RINTL = 0; then + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether rintl works], + [gl_cv_func_rintl_works], + [ + save_LIBS="$LIBS" + LIBS="$LIBS $RINTL_LIBM" + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include