diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ae90dd69..887cdfbe3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1007,7 +1007,7 @@ if(USE_CONSOLE) ${READLINE_LIBRARIES} ) endif() -if(UNIX) +if(UNIX AND NOT APPLE) target_link_libraries(c4group rt) target_link_libraries(c4script rt) target_link_libraries(netpuncher rt) diff --git a/src/platform/GetTime.cpp b/src/platform/GetTime.cpp index bb660df14..d64d7938d 100644 --- a/src/platform/GetTime.cpp +++ b/src/platform/GetTime.cpp @@ -30,14 +30,26 @@ unsigned int GetTime() #else +#ifdef __APPLE__ +#include +#else #include +#endif unsigned int GetTime() { +#ifdef __APPLE__ + static time_t sec_offset; + timeval tv; + gettimeofday(&tv, 0); + if (!sec_offset) sec_offset = tv.tv_sec; + return (tv.tv_sec - sec_offset) * 1000 + tv.tv_usec / 1000; +#else timespec tv; clock_gettime(CLOCK_MONOTONIC, &tv); static time_t sec_offset = tv.tv_sec; return (tv.tv_sec - sec_offset) * 1000 + tv.tv_nsec / 1000000; +#endif } #endif