[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

alarm() on latest mingw

From: Eric Blake
Subject: alarm() on latest mingw
Date: Mon, 11 Mar 2013 13:32:41 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130219 Thunderbird/17.0.3

test-regex currently fails to compile on mingw, when using the mingw64
32-bit cross-compiler shipped in cygwin:

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 mingw has started conditionally providing alarm() and
SIGALRM, but declared things in the wrong header (io.h instead of
unistd.h), and the support is only present if __USE_MINGW_ALARM (not
turned on in a default compile).

$ find /usr/i686-w64-mingw32/sys-root/mingw/include/ -type f \
   |xargs grep -C2 MINGW_ALARM
/usr/i686-w64-mingw32/sys-root/mingw/include/signal.h-#define   SIGSYS  12
/* bad argument to system call */
/usr/i686-w64-mingw32/sys-root/mingw/include/signal.h-#define   SIGPIPE
13      /* write on a pipe with no one to read it */
/usr/i686-w64-mingw32/sys-root/mingw/include/signal.h-#define   SIGALRM
14      /* alarm clock */
/usr/i686-w64-mingw32/sys-root/mingw/include/io.h-/* Misc stuff */
/usr/i686-w64-mingw32/sys-root/mingw/include/io.h-char *getlogin(void);
/usr/i686-w64-mingw32/sys-root/mingw/include/io.h:#ifdef __USE_MINGW_ALARM
/usr/i686-w64-mingw32/sys-root/mingw/include/io.h-unsigned int
alarm(unsigned int seconds);

The fix is to use HAVE_DECL_ALARM instead of HAVE_ALARM as the key on
whether to trust alarm().  I'm auditing gnulib to see if anything else
besides test-regex falls prey to this portability issue.

Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]