Mercurial > hg > octave-lojdl > gnulib-hg
diff m4/mktime.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 | a4a11de07980 |
line wrap: on
line diff
--- a/m4/mktime.m4 +++ b/m4/mktime.m4 @@ -1,4 +1,4 @@ -# serial 24 +# serial 25 dnl Copyright (C) 2002-2003, 2005-2007, 2009-2013 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation @@ -14,7 +14,7 @@ dnl We don't use AC_FUNC_MKTIME any more, because it is no longer maintained dnl in Autoconf and because it invokes AC_LIBOBJ. AC_CHECK_HEADERS_ONCE([unistd.h]) - AC_CHECK_FUNCS_ONCE([alarm]) + AC_CHECK_DECLS_ONCE([alarm]) AC_REQUIRE([gl_MULTIARCH]) if test $APPLE_UNIVERSAL_BUILD = 1; then # A universal build on Apple Mac OS X platforms. @@ -34,8 +34,8 @@ # include <unistd.h> #endif -#ifndef HAVE_ALARM -# define alarm(X) /* empty */ +#ifndef HAVE_DECL_ALARM +# include <signal.h> #endif /* Work around redefinition to rpl_putenv by other config tests. */ @@ -171,10 +171,13 @@ int time_t_signed_magnitude = (time_t) ~ (time_t) 0 < (time_t) -1; int time_t_signed = ! ((time_t) 0 < (time_t) -1); +#if HAVE_DECL_ALARM /* This test makes some buggy mktime implementations loop. Give up after 60 seconds; a mktime slower than that isn't worth using anyway. */ + signal (SIGALRM, SIG_DFL); alarm (60); +#endif time_t_max = (! time_t_signed ? (time_t) -1