Skip to content

gmain: fix fetching timebase on non-Intel Darwin

gmain's monotonic time function currently makes an incorrect assumption about the values of mach_absolute_time units. On Intel Mac OS, this value is coincidentally the same as seconds, but on ARM and PowerPC Mac OS and ARM iOS, it's a CPU-dependent value. Apple's documentation instructs developers to use mach_timebase_info to fetch values to use to convert that CPU-dependent value into seconds.

This is going to come up on the upcoming ARM-based Macs. Without this patch, programs will abort on startup with a message about Got weird mach timebase info. See #858 (closed) for details; this was originally reported on PowerPC Mac OS X in 2014, and the same issue should also occur on ARM macOS.

I wrote the original patch, and this improved version was authored by holin on Bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=728123 I've taken that patch and updated it for code style as flagged by the pipeline.

Fixes #858 (closed).

Merge request reports