[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gnulib-bug
Subject:    alarm() on latest mingw
From:       Eric Blake <eblake () redhat ! com>
Date:       2013-03-11 19:32:41
Message-ID: 513E3159.9080905 () redhat ! com
[Download RAW message or body]


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:#ifdef
__USE_MINGW_ALARM
/usr/i686-w64-mingw32/sys-root/mingw/include/signal.h-#define	SIGALRM
14	/* alarm clock */
/usr/i686-w64-mingw32/sys-root/mingw/include/signal.h-#endif
--
/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);
/usr/i686-w64-mingw32/sys-root/mingw/include/io.h-#endif


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


["signature.asc" (application/pgp-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic