diff --git a/CMakeLists.txt b/CMakeLists.txt index 8f2382dcb..59a3b34f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,7 +104,7 @@ if(MSVC_TOOLSET_VERSION GREATER_EQUAL 142 AND ARCH STREQUAL "arm64") endif() endif() -# HACK: MinGW does not have `timespec_get` +# HACK: MinGW and macOS <10.15 does not have `timespec_get` include(CheckSymbolExists) check_symbol_exists(timespec_get time.h HAS_TIMESPEC_GET) if(HAS_TIMESPEC_GET) diff --git a/src/thread.c b/src/thread.c index 8dd321c88..d95c337d1 100644 --- a/src/thread.c +++ b/src/thread.c @@ -6,10 +6,6 @@ #include <86box/86box.h> #include <86box/plat.h> -#ifndef HAS_TIMESPEC_GET -# define timespec_get(ts, _) clock_gettime(CLOCK_REALTIME, ts) -#endif - typedef struct event_pthread_t { @@ -105,7 +101,11 @@ thread_wait_event(event_t *handle, int timeout) event_pthread_t *event = (event_pthread_t *)handle; struct timespec abstime; +#ifdef HAS_TIMESPEC_GET timespec_get(&abstime, TIME_UTC); +#else + clock_gettime(CLOCK_REALTIME, &abstime); +#endif abstime.tv_nsec += (timeout % 1000) * 1000000; abstime.tv_sec += (timeout / 1000); if (abstime.tv_nsec > 1000000000) {