This commit is contained in:
OBattler
2021-09-18 21:33:22 +02:00
2 changed files with 5 additions and 5 deletions

View File

@@ -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)

View File

@@ -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) {