diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2023-09-25 01:46:36 +0300 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2023-10-22 18:59:45 +0300 |
commit | c57858b60e186d020b2dbaf7aabd9b32c71da824 (patch) | |
tree | 9c53c5d91eb48e9a4ed86e7b1ba3da220541ab6a /src/xz/mytime.c | |
parent | mythread.h: Make MYTHREAD_POSIX compatible with MinGW-w64's winpthreads. (diff) | |
download | xz-c57858b60e186d020b2dbaf7aabd9b32c71da824.tar.xz |
xz/Windows: Allow clock_gettime with POSIX threads.
If winpthreads are used for threading, it's OK to use clock_gettime()
from winpthreads too.
Diffstat (limited to '')
-rw-r--r-- | src/xz/mytime.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/xz/mytime.c b/src/xz/mytime.c index 4d8da513..602e897e 100644 --- a/src/xz/mytime.c +++ b/src/xz/mytime.c @@ -14,7 +14,8 @@ #if defined(MYTHREAD_VISTA) || defined(_MSC_VER) // Nothing -#elif defined(HAVE_CLOCK_GETTIME) && !defined(__MINGW32__) +#elif defined(HAVE_CLOCK_GETTIME) \ + && (!defined(__MINGW32__) || defined(MYTHREAD_POSIX)) # include <time.h> #else # include <sys/time.h> @@ -59,9 +60,11 @@ mytime_now(void) // there's no reason to avoid a WinVista API here either. return GetTickCount64(); -#elif defined(HAVE_CLOCK_GETTIME) && !defined(__MINGW32__) +#elif defined(HAVE_CLOCK_GETTIME) \ + && (!defined(__MINGW32__) || defined(MYTHREAD_POSIX)) // MinGW-w64: clock_gettime() is defined in winpthreads but we need - // nothing else from winpthreads. By avoiding clock_gettime(), we + // nothing else from winpthreads (unless, for some odd reason, POSIX + // threading has been selected). By avoiding clock_gettime(), we // avoid the dependency on libwinpthread-1.dll or the need to link // against the static version. The downside is that the fallback // method, gettimeofday(), doesn't provide monotonic time. |