changeset 15964:916745fe55a6

Support for old NeXTstep 3.3 frexp(). * m4/frexp.m4 (gl_FUNC_FREXP_WORKS): Check for alarm. Limit the execution time of the test to 5 seconds. Reported by Daniel Richard G. <skunk@iskunk.org>.
author Bruno Haible <bruno@clisp.org>
date Wed, 19 Oct 2011 11:09:37 +0200
parents 1b99dc961823
children d646eaed80e3
files ChangeLog m4/frexp.m4
diffstat 2 files changed, 17 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-10-19  Bruno Haible  <bruno@clisp.org>
+
+	Support for old NeXTstep 3.3 frexp().
+	* m4/frexp.m4 (gl_FUNC_FREXP_WORKS): Check for alarm. Limit the
+	execution time of the test to 5 seconds.
+	Reported by Daniel Richard G. <skunk@iskunk.org>.
+
 2011-10-19  Bruno Haible  <bruno@clisp.org>
 
 	Support for old NeXTstep 3.3 sed.
--- a/m4/frexp.m4
+++ b/m4/frexp.m4
@@ -1,4 +1,4 @@
-# frexp.m4 serial 12
+# frexp.m4 serial 13
 dnl Copyright (C) 2007-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -93,6 +93,7 @@
 [
   AC_REQUIRE([AC_PROG_CC])
   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_CHECK_FUNCS_ONCE([alarm])
   AC_CACHE_CHECK([whether frexp works], [gl_cv_func_frexp_works],
     [
       AC_RUN_IFELSE(
@@ -100,6 +101,9 @@
 #include <float.h>
 #include <math.h>
 #include <string.h>
+#if HAVE_ALARM
+# include <unistd.h>
+#endif
 /* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0.
    ICC 10.0 has a bug when optimizing the expression -zero.
    The expression -DBL_MIN * DBL_MIN does not work when cross-compiling
@@ -120,6 +124,11 @@
   int i;
   volatile double x;
   double zero = 0.0;
+#if HAVE_ALARM
+  /* NeXTstep 3.3 frexp() runs into an endless loop when called on an infinite
+     number.  Let the test fail in this case.  */
+  alarm (5);
+#endif
   /* Test on denormalized numbers.  */
   for (i = 1, x = 1.0; i >= DBL_MIN_EXP; i--, x *= 0.5)
     ;