From 08ff353a203c18c76cc05d5bb77a50792a854fad Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 20 Aug 2023 00:45:05 +0200 Subject: [PATCH] logbl: Work around endless loop on OpenBSD 7.3/mips64. * m4/logbl.m4 (gl_FUNC_LOGBL_WORKS): Terminate the test program if it takes longer than 5 seconds. * doc/posix-functions/logbl.texi: Mention the OpenBSD bug. --- ChangeLog | 7 +++++++ doc/posix-functions/logbl.texi | 5 +++++ m4/logbl.m4 | 11 ++++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index e8e8174254..92c799520d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2023-08-19 Bruno Haible + + logbl: Work around endless loop on OpenBSD 7.3/mips64. + * m4/logbl.m4 (gl_FUNC_LOGBL_WORKS): Terminate the test program if it + takes longer than 5 seconds. + * doc/posix-functions/logbl.texi: Mention the OpenBSD bug. + 2023-08-18 Bruno Haible thrd: Work around thrd_join bug on AIX 7.3.1. diff --git a/doc/posix-functions/logbl.texi b/doc/posix-functions/logbl.texi index 92bf487324..1aa377b25c 100644 --- a/doc/posix-functions/logbl.texi +++ b/doc/posix-functions/logbl.texi @@ -12,6 +12,11 @@ Portability problems fixed by Gnulib: 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, older IRIX 6.5, Solaris 9, Cygwin 1.7.x, MSVC 9, Android 4.2. @item +This function goes into an endless loop for arguments such as +@code{1.6810515715560467531313389086608763012990396724232e-4932L} +on some platforms: +OpenBSD 7.3/mips64. +@item This function produces wrong results for subnormal numbers on some platforms: glibc 2.11/powerpc, glibc 2.7/sparc, glibc 2.7/hppa, Solaris 11.4, glibc 2.23/powerpc64le. diff --git a/m4/logbl.m4 b/m4/logbl.m4 index ef38e80ba3..9da87d0888 100644 --- a/m4/logbl.m4 +++ b/m4/logbl.m4 @@ -1,4 +1,4 @@ -# logbl.m4 serial 5 +# logbl.m4 serial 5.1 dnl Copyright (C) 2012-2023 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -69,6 +69,11 @@ AC_DEFUN([gl_FUNC_LOGBL_WORKS], [AC_LANG_SOURCE([[ #include #include +#include /* for signal */ +#ifdef SIGALRM +# include /* for alarm, _exit */ +static void quit (int sig) { _exit (sig + 128); } +#endif /* Override the values of , like done in float.in.h. */ #if defined __i386__ && (defined __BEOS__ || defined __OpenBSD__) # undef LDBL_MIN_EXP @@ -92,6 +97,10 @@ volatile long double x; int main () { int i; +#ifdef SIGALRM + signal (SIGALRM, quit); + alarm (5); +#endif for (i = 1, x = 1.0L; i >= LDBL_MIN_EXP - 54; i--, x *= 0.5L) /* Either x = 2^(i-1) or x = 0.0. */ if ((i == LDBL_MIN_EXP - 1 || i == LDBL_MIN_EXP - 54) -- 2.39.5