diff options
author | Eric Blake <eblake@redhat.com> | 2010-06-02 11:08:06 -0600 |
---|---|---|
committer | Eric Blake <eblake@redhat.com> | 2010-06-02 14:12:18 -0600 |
commit | df6774c09485e6b0f31f4659eb55d50c68c008a8 (patch) | |
tree | 0e506564b8d6f58d55f66474b922f9957e56ae71 /lib | |
parent | 2988c8c21303fdadb3a9efe321870d96f6bdc668 (diff) | |
download | gnulib-df6774c09485e6b0f31f4659eb55d50c68c008a8.tar.gz |
time: work with mingw + pthreads-win32 library
When using the pthreads-win32 library with mingw, struct timespec
is available in <pthread.h>. Meanwhile, that header has some
rather buggy macros for localtime_r and gmtime_r that interfere
with proper gnulib replacement header actions.
Tested in a cross-compilation environment: Fedora 13 with mingw32-gcc
and mingw32-pthreads installed.
* m4/time_h.m4 (gl_CHECK_TYPE_STRUCT_TIMESPEC): Set new variable
if timespec is defined only in pthread.h.
* modules/time (Makefile.am): Substitute it.
* lib/time.in.h (!TIME_H_DEFINES_STRUCT_TIMESPEC): Include
<pthread.h>, when needed.
(GNULIB_TIME_R): Undefine broken localtime_r and gmtime_r macros
from the library.
Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/time.in.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/time.in.h b/lib/time.in.h index 98314442c3..6d2b818024 100644 --- a/lib/time.in.h +++ b/lib/time.in.h @@ -48,10 +48,13 @@ /* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3). Or they define it with the wrong member names or define it in <sys/time.h> - (e.g., FreeBSD circa 1997). */ + (e.g., FreeBSD circa 1997). Stock Mingw does not define it, but the + pthreads-win32 library defines it in <pthread.h>. */ # if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@ # if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@ # include <sys/time.h> +# elif @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@ +# include <pthread.h> # else # ifdef __cplusplus @@ -128,6 +131,7 @@ _GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer, struct tm *restrict __result)); # else # if ! @HAVE_LOCALTIME_R@ +# undef localtime_r _GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer, struct tm *restrict __result) _GL_ARG_NONNULL ((1, 2))); @@ -148,6 +152,7 @@ _GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer, struct tm *restrict __result)); # else # if ! @HAVE_LOCALTIME_R@ +# undef gmtime_r _GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer, struct tm *restrict __result) _GL_ARG_NONNULL ((1, 2))); |