On 01/22/2014 09:27 AM, Daniel P. Berrange wrote:
I'm attempting to make libvirt capable of building with mingw64
toolchain's
pthread.h, instead of directly using Windows thread primitives.
When attempting to build though I see failures
CC util/libvirt_util_la-virerror.lo
In file included from /usr/i686-w64-mingw32/sys-root/mingw/include/sys/time.h:10:0,
from ../gnulib/lib/sys/time.h:39,
from ../gnulib/lib/sys/select.h:117,
from util/virutil.h:31,
from util/virerror.c:35:
../gnulib/lib/time.h:468:21: error: expected identifier or '(' before '{'
token
_GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
^
The problem appears to be that mingw64's pthread.h has the following
craziness:
/* Recursive API emulation. */
#undef localtime_r
#define localtime_r(_Time, _Tm) ({ struct tm *___tmp_tm; \
Yep, that's broken. But new enough mingw now provides 'struct timespec'
via <time.h> (or rather, mingw + winpthreads provides pthread_time.h
which gets included by both <time.h> and <pthread.h>), whereas the
broken localtime_r is only provided by <pthread.h>.
I think the time.h checks are just fine, and what we really need to do
is to provide a wrapper <pthread.h> header that undoes the damage
directly when pthread.h is included, rather than indirectly via time.h.
Now that I've reproduced the problem myself, I hope to come up with a
solution soon.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library
http://libvirt.org