Mercurial > hg > octave-lojdl > gnulib-hg
comparison m4/frexp.m4 @ 17366:9855b352e525
regex: port to mingw's recent addition of undeclared alarm
On mingw (at least, when cross-compiling with Fedora 18's
mingw32-headers-2.0.999-0.15.trunk.20121110.fc18.noarch build),
compilation of test-regex fails:
test-regex.c: In function 'main':
test-regex.c:42:11: error: 'SIGALRM' undeclared (first use in this function)
test-regex.c:42:11: note: each undeclared identifier is reported only
once for each function it appears in
test-regex.c:43:3: warning: implicit declaration of function 'alarm'
It turns out that recent mingw64 added an export of alarm() and
SIGALRM, but guarded their declarations behind __USE_MINGW_ALARM
(default off, and with alarm() only in the non-standard <io.h>);
so the m4 tests were setting HAVE_ALARM to 1 based on link success
but then failing to compile.
* doc/posix-functions/alarm.texi (alarm): Document that alarm
exists but still doesn't work in newer mingw.
* m4/frexp.m4 (gl_FUNC_FREXP_WORKS): Check for alarm declaration,
not existence. Ensure SIGALRM is not trapped.
* m4/mktime.m4 (gl_FUNC_MKTIME): Likewise.
* m4/regex.m4 (gl_REGEX): Likewise.
* m4/remainderf.m4 (gl_FUNC_REMAINDERF_WORKS): Likewise.
* tests/test-regex.c (main): Use correct probe for alarm.
Signed-off-by: Eric Blake <eblake@redhat.com>
author | Eric Blake <eblake@redhat.com> |
---|---|
date | Mon, 11 Mar 2013 14:51:33 -0600 |
parents | e542fd46ad6f |
children |
comparison
equal
deleted
inserted
replaced
17365:a154fccd3b21 | 17366:9855b352e525 |
---|---|
1 # frexp.m4 serial 14 | 1 # frexp.m4 serial 15 |
2 dnl Copyright (C) 2007-2013 Free Software Foundation, Inc. | 2 dnl Copyright (C) 2007-2013 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_CHECK_DECLS_ONCE([alarm]) |
97 AC_CACHE_CHECK([whether frexp works], [gl_cv_func_frexp_works], | 97 AC_CACHE_CHECK([whether frexp works], [gl_cv_func_frexp_works], |
98 [ | 98 [ |
99 AC_RUN_IFELSE( | 99 AC_RUN_IFELSE( |
100 [AC_LANG_SOURCE([[ | 100 [AC_LANG_SOURCE([[ |
101 #include <float.h> | 101 #include <float.h> |
102 #include <math.h> | 102 #include <math.h> |
103 #include <string.h> | 103 #include <string.h> |
104 #if HAVE_ALARM | 104 #if HAVE_DECL_ALARM |
105 # include <signal.h> | |
105 # include <unistd.h> | 106 # include <unistd.h> |
106 #endif | 107 #endif |
107 /* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0. | 108 /* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0. |
108 ICC 10.0 has a bug when optimizing the expression -zero. | 109 ICC 10.0 has a bug when optimizing the expression -zero. |
109 The expression -DBL_MIN * DBL_MIN does not work when cross-compiling | 110 The expression -DBL_MIN * DBL_MIN does not work when cross-compiling |
122 { | 123 { |
123 int result = 0; | 124 int result = 0; |
124 int i; | 125 int i; |
125 volatile double x; | 126 volatile double x; |
126 double zero = 0.0; | 127 double zero = 0.0; |
127 #if HAVE_ALARM | 128 #if HAVE_DECL_ALARM |
128 /* NeXTstep 3.3 frexp() runs into an endless loop when called on an infinite | 129 /* NeXTstep 3.3 frexp() runs into an endless loop when called on an infinite |
129 number. Let the test fail in this case. */ | 130 number. Let the test fail in this case. */ |
131 signal (SIGALRM, SIG_DFL); | |
130 alarm (5); | 132 alarm (5); |
131 #endif | 133 #endif |
132 /* Test on denormalized numbers. */ | 134 /* Test on denormalized numbers. */ |
133 for (i = 1, x = 1.0; i >= DBL_MIN_EXP; i--, x *= 0.5) | 135 for (i = 1, x = 1.0; i >= DBL_MIN_EXP; i--, x *= 0.5) |
134 ; | 136 ; |