Optimized timer code for macOS (#576)

This commit is contained in:
Tillsunset 2022-12-15 03:28:44 -06:00 committed by GitHub
parent fcab8f8f1a
commit 058d11b49b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 9 deletions

View file

@ -1,9 +1,14 @@
#include <stdint.h>
#include <time.h>
#include <cstdint>
#include <ctime>
uint32_t GetTickCount()
{
struct timespec ts;
#if BOOST_OS_LINUX
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
return (1000 * ts.tv_sec + ts.tv_nsec / 1000000);
return (1000 * ts.tv_sec + ts.tv_nsec / 1000000);
#elif BOOST_OS_MACOS
return clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW) / 1000000;
#endif
}