diff --git a/darwin/Platform.c b/darwin/Platform.c index 1e4bd8540..84ebc3951 100644 --- a/darwin/Platform.c +++ b/darwin/Platform.c @@ -148,14 +148,11 @@ const MeterClass* const Platform_meterTypes[] = { NULL }; -static double Platform_nanosecondsPerMachTick = 1.0; - static double Platform_nanosecondsPerSchedulerTick = -1; static mach_port_t iokit_port; // the mach port used to initiate communication with IOKit bool Platform_init(void) { - Platform_nanosecondsPerMachTick = Platform_calculateNanosecondsPerMachTick(); // Determine the number of scheduler clock ticks per second errno = 0; diff --git a/darwin/PlatformHelpers.c b/darwin/PlatformHelpers.c index 03b9bffe1..3e539a2aa 100644 --- a/darwin/PlatformHelpers.c +++ b/darwin/PlatformHelpers.c @@ -86,37 +86,3 @@ bool Platform_isRunningTranslated(void) { } return ret; } - -double Platform_calculateNanosecondsPerMachTick(void) { - // Check if we can determine the timebase used on this system. - // If the API is unavailable assume we get our timebase in nanoseconds. -#ifndef HAVE_MACH_TIMEBASE_INFO - return 1.0; -#else - mach_timebase_info_data_t info; - - /* WORKAROUND for `mach_timebase_info` giving incorrect values on M1 under Rosetta 2. - * rdar://FB9546856 https://openradar.appspot.com/radar?id=5055988478509056 - * - * We don't know exactly what feature/attribute of the M1 chip causes this mistake under Rosetta 2. - * Until we have more Apple ARM chips to compare against, the best we can do is special-case - * the "Apple M1" chip specifically when running under Rosetta 2. - */ - - bool isRunningUnderRosetta2 = Platform_isRunningTranslated(); - - // Kernel version 20.0.0 is macOS 11.0 (Big Sur) - bool isBuggedVersion = Platform_KernelVersionIsBetween((KernelVersion) {20, 0, 0}, (KernelVersion) {999, 999, 999}); - - if (isRunningUnderRosetta2 && isBuggedVersion) { - // In this case `mach_timebase_info` provides the wrong value, so we hard-code the correct factor, - // as determined from `mach_timebase_info` when the process running natively. - info = (mach_timebase_info_data_t) { .numer = 125, .denom = 3 }; - } else { - // No workarounds needed, use the OS-provided value. - mach_timebase_info(&info); - } - - return (double)info.numer / (double)info.denom; -#endif -} diff --git a/darwin/PlatformHelpers.h b/darwin/PlatformHelpers.h index 45aea1a74..7331b4da2 100644 --- a/darwin/PlatformHelpers.h +++ b/darwin/PlatformHelpers.h @@ -29,12 +29,8 @@ int Platform_CompareKernelVersion(KernelVersion v); // lowerBound <= currentVersion < upperBound bool Platform_KernelVersionIsBetween(KernelVersion lowerBound, KernelVersion upperBound); -double Platform_calculateNanosecondsPerMachTick(void); - void Platform_getCPUBrandString(char* cpuBrandString, size_t cpuBrandStringSize); bool Platform_isRunningTranslated(void); -double Platform_calculateNanosecondsPerMachTick(void); - #endif