Mercurial > gnulib
comparison tests/test-regex.c @ 17355: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 | a9f418d6d676 |
children | 2f5f50211fb5 |
comparison
equal
deleted
inserted
replaced
17354:a154fccd3b21 | 17355:9855b352e525 |
---|---|
19 #include "regex.h" | 19 #include "regex.h" |
20 | 20 |
21 #include <locale.h> | 21 #include <locale.h> |
22 #include <limits.h> | 22 #include <limits.h> |
23 #include <string.h> | 23 #include <string.h> |
24 #if HAVE_ALARM | 24 #if HAVE_DECL_ALARM |
25 # include <unistd.h> | 25 # include <unistd.h> |
26 # include <signal.h> | 26 # include <signal.h> |
27 #endif | 27 #endif |
28 | 28 |
29 int | 29 int |
34 unsigned char folded_chars[UCHAR_MAX + 1]; | 34 unsigned char folded_chars[UCHAR_MAX + 1]; |
35 int i; | 35 int i; |
36 const char *s; | 36 const char *s; |
37 struct re_registers regs; | 37 struct re_registers regs; |
38 | 38 |
39 #if HAVE_ALARM | 39 #if HAVE_DECL_ALARM |
40 /* Some builds of glibc go into an infinite loop on this test. */ | 40 /* Some builds of glibc go into an infinite loop on this test. */ |
41 int alarm_value = 2; | 41 int alarm_value = 2; |
42 signal (SIGALRM, SIG_DFL); | 42 signal (SIGALRM, SIG_DFL); |
43 alarm (alarm_value); | 43 alarm (alarm_value); |
44 #endif | 44 #endif |