On OpenBSD 7.3/mips64, the configure test
  checking whether logbl works...
goes into an endless loop, already during the first logbl() invocation.

This can also be seen by running this test program:
===============================================================================
#include <math.h>
#include <stdio.h>
long double volatile x = 
1.6810515715560467531313389086608763012990396724232e-4932L;
int main ()
{
  printf ("%Lg\n", logbl (x));
  return 0;
}
===============================================================================

This patch provides a workaround.


2023-08-19  Bruno Haible  <[email protected]>

        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.

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 @@
 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 74884a1ad8..be5ddbd009 100644
--- a/m4/logbl.m4
+++ b/m4/logbl.m4
@@ -1,4 +1,4 @@
-# logbl.m4 serial 6
+# logbl.m4 serial 7
 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 @@ AC_DEFUN([gl_FUNC_LOGBL_WORKS]
 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)




Reply via email to