mirror of https://github.com/OpenRCT2/OpenRCT2.git
Cache mach_base_info
This commit is contained in:
parent
3d6f13da13
commit
f8b79a4a3f
|
@ -81,6 +81,11 @@ static float _gestureRadius;
|
||||||
|
|
||||||
static void platform_create_window();
|
static void platform_create_window();
|
||||||
|
|
||||||
|
#if defined(__APPLE__) && !defined(MACOS_SIERRA_ONWARDS)
|
||||||
|
mach_timebase_info_data_t mach_base_info = { 0 };
|
||||||
|
bool mach_info_initialised = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
static sint32 resolution_sort_func(const void *pa, const void *pb)
|
static sint32 resolution_sort_func(const void *pa, const void *pb)
|
||||||
{
|
{
|
||||||
const resolution_t *a = (resolution_t*)pa;
|
const resolution_t *a = (resolution_t*)pa;
|
||||||
|
@ -776,14 +781,15 @@ uint32 platform_get_ticks()
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
return GetTickCount();
|
return GetTickCount();
|
||||||
#elif defined(__APPLE__) && !defined(MACOS_SIERRA_ONWARDS)
|
#elif defined(__APPLE__) && !defined(MACOS_SIERRA_ONWARDS)
|
||||||
mach_timebase_info_data_t mach_base_info;
|
if (!mach_info_initialised) {
|
||||||
kern_return_t ret = mach_timebase_info(&mach_base_info);
|
kern_return_t ret = mach_timebase_info(&mach_base_info);
|
||||||
if (ret == 0) {
|
if (ret != 0) {
|
||||||
return (uint32)(((mach_absolute_time() * mach_base_info.numer) / mach_base_info.denom) / 1000000);
|
log_fatal("Unable to get mach_timebase_info.");
|
||||||
} else {
|
exit(-1);
|
||||||
log_fatal("Unable to get mach_timebase_info.");
|
}
|
||||||
exit(-1);
|
mach_info_initialised = true;
|
||||||
}
|
}
|
||||||
|
return (uint32)(((mach_absolute_time() * mach_base_info.numer) / mach_base_info.denom) / 1000000);
|
||||||
#else
|
#else
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) {
|
if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) {
|
||||||
|
|
Loading…
Reference in New Issue