diff options
| author | RilleP <rikkypikki@hotmail.com> | 2024-04-10 19:10:33 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-10 19:10:33 +0200 |
| commit | 95a38d5a96322cd9adbb03bd5b7425b93469e62f (patch) | |
| tree | 8cdc3b962506ddc4b7b1883f0e2ecb9dce54e2f9 /src/timings.cpp | |
| parent | 239d4e10762a12e96280bd91003acbf2170cadf2 (diff) | |
| parent | 13e459980b0143b49762cdfd04dd5cf1bbf83daa (diff) | |
Merge branch 'master' into parsing-package-fixes
Diffstat (limited to 'src/timings.cpp')
| -rw-r--r-- | src/timings.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/timings.cpp b/src/timings.cpp index baa8b80da..712e804cb 100644 --- a/src/timings.cpp +++ b/src/timings.cpp @@ -33,22 +33,23 @@ gb_internal u64 win32_time_stamp__freq(void) { #include <mach/mach_time.h> +gb_internal mach_timebase_info_data_t osx_init_timebase_info(void) { + mach_timebase_info_data_t data; + data.numer = 0; + data.denom = 0; + kern_return_t r = mach_timebase_info(&data); + GB_ASSERT(r == KERN_SUCCESS); + + return data; +} + gb_internal u64 osx_time_stamp_time_now(void) { return mach_absolute_time(); } gb_internal u64 osx_time_stamp__freq(void) { - mach_timebase_info_data_t data; - data.numer = 0; - data.denom = 0; - mach_timebase_info(&data); -#if defined(GB_CPU_ARM) - // NOTE(bill, 2021-02-25): M1 Chip seems to have a different freq count - // TODO(bill): Is this truly correct? - return (1000000llu * cast(u64)data.numer) / cast(u64)data.denom; -#else - return (1000000000llu * cast(u64)data.numer) / cast(u64)data.denom; -#endif + gb_local_persist mach_timebase_info_data_t data = osx_init_timebase_info(); + return 1000000000ull * cast(u64)data.denom / cast(u64)data.numer; } #elif defined(GB_SYSTEM_UNIX) |