]> Savannah Git Hosting - gnulib.git/commitdiff
logbl: Work around endless loop on OpenBSD 7.3/mips64.
authorBruno Haible <bruno@clisp.org>
Sat, 19 Aug 2023 22:45:05 +0000 (00:45 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 30 Aug 2023 09:49:50 +0000 (11:49 +0200)
* 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
doc/posix-functions/logbl.texi
m4/logbl.m4

index e8e8174254e42cb4f59c92e8568813ed902b4693..92c799520dca4495852b7d006e8fb5fe790fb059 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2023-08-19  Bruno Haible  <bruno@clisp.org>
+
+       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  <bruno@clisp.org>
 
        thrd: Work around thrd_join bug on AIX 7.3.1.
index 92bf4873242356262204d9306f165e69ceef4857..1aa377b25c606a1a2e67f3b3359cdd5ee258237d 100644 (file)
@@ -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.
index ef38e80ba3f6510084be457a56258ef67bf4b56b..9da87d08883b7585831a28a1d0a836230f756d7f 100644 (file)
@@ -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 <float.h>
 #include <math.h>
+#include <signal.h> /* for signal */
+#ifdef SIGALRM
+# include <unistd.h> /* for alarm, _exit */
+static void quit (int sig) { _exit (sig + 128); }
+#endif
 /* Override the values of <float.h>, 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)