comparison m4/frexp.m4 @ 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 328819af1c02
children 8250f2777afc
comparison
equal deleted inserted replaced
15963:1b99dc961823 15964:916745fe55a6
1 # frexp.m4 serial 12 1 # frexp.m4 serial 13
2 dnl Copyright (C) 2007-2011 Free Software Foundation, Inc. 2 dnl Copyright (C) 2007-2011 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation 3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it, 4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved. 5 dnl with or without modifications, as long as this notice is preserved.
6 6
91 dnl and on negative zero (this fails e.g. on NetBSD 4.99 and mingw). 91 dnl and on negative zero (this fails e.g. on NetBSD 4.99 and mingw).
92 AC_DEFUN([gl_FUNC_FREXP_WORKS], 92 AC_DEFUN([gl_FUNC_FREXP_WORKS],
93 [ 93 [
94 AC_REQUIRE([AC_PROG_CC]) 94 AC_REQUIRE([AC_PROG_CC])
95 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 95 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
96 AC_CHECK_FUNCS_ONCE([alarm])
96 AC_CACHE_CHECK([whether frexp works], [gl_cv_func_frexp_works], 97 AC_CACHE_CHECK([whether frexp works], [gl_cv_func_frexp_works],
97 [ 98 [
98 AC_RUN_IFELSE( 99 AC_RUN_IFELSE(
99 [AC_LANG_SOURCE([[ 100 [AC_LANG_SOURCE([[
100 #include <float.h> 101 #include <float.h>
101 #include <math.h> 102 #include <math.h>
102 #include <string.h> 103 #include <string.h>
104 #if HAVE_ALARM
105 # include <unistd.h>
106 #endif
103 /* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0. 107 /* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0.
104 ICC 10.0 has a bug when optimizing the expression -zero. 108 ICC 10.0 has a bug when optimizing the expression -zero.
105 The expression -DBL_MIN * DBL_MIN does not work when cross-compiling 109 The expression -DBL_MIN * DBL_MIN does not work when cross-compiling
106 to PowerPC on MacOS X 10.5. */ 110 to PowerPC on MacOS X 10.5. */
107 #if defined __hpux || defined __sgi || defined __ICC 111 #if defined __hpux || defined __sgi || defined __ICC
118 { 122 {
119 int result = 0; 123 int result = 0;
120 int i; 124 int i;
121 volatile double x; 125 volatile double x;
122 double zero = 0.0; 126 double zero = 0.0;
127 #if HAVE_ALARM
128 /* NeXTstep 3.3 frexp() runs into an endless loop when called on an infinite
129 number. Let the test fail in this case. */
130 alarm (5);
131 #endif
123 /* Test on denormalized numbers. */ 132 /* Test on denormalized numbers. */
124 for (i = 1, x = 1.0; i >= DBL_MIN_EXP; i--, x *= 0.5) 133 for (i = 1, x = 1.0; i >= DBL_MIN_EXP; i--, x *= 0.5)
125 ; 134 ;
126 if (x > 0.0) 135 if (x > 0.0)
127 { 136 {