#include <mach/mach_time.h> not included by <mach/mach.h> — include it explicitly
mach/mach_time.h
structmach_timebase_info
| uint32_t | numer | |
| uint32_t | denom |
typedefmach_timebase_info_t
typedef struct mach_timebase_info *mach_timebase_info_t
typedefmach_timebase_info_data_t
typedef struct mach_timebase_info mach_timebase_info_data_t
functionmach_timebase_info
kern_return_t mach_timebase_info(mach_timebase_info_t info)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu libsyscall/wrappers/mach_timebase_info.c
Returns the scale factor used to convert mach absolute time units to nanoseconds, as a numerator/denominator pair: nanoseconds = ticks * numer / denom. Applies to values from mach_absolute_time, mach_approximate_time, mach_continuous_time, and deadlines passed to mach_wait_until. The result of mach_timebase_info_trap is cached in the library after the first successful call. Returns KERN_SUCCESS, or the trap's error if the first query fails.
functionmach_wait_until
kern_return_t mach_wait_until(uint64_t deadline)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/clock.c (mach_wait_until_trap)
Suspends execution of the calling thread until the specified deadline, expressed in mach absolute time units (the mach_absolute_time timebase), has passed. A deadline already in the past returns immediately. The wait uses standard user timeout urgency with no additional leeway and is abort-safe: KERN_ABORTED is returned if the wait is interrupted (e.g. thread_abort), otherwise KERN_SUCCESS. Because the deadline is on the mach_absolute_time clock, time the system spends asleep does not count toward it; use continuous-time based waits when sleep must be included.
functionmach_absolute_time
uint64_t mach_absolute_time(void)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu libsyscall/wrappers/mach_absolute_time.s, osfmk/kern/clock.c
Returns the current value of the system's monotonic clock in mach absolute time units (ticks); convert to nanoseconds with the fraction returned by mach_timebase_info. Implemented in the commpage from the hardware time base without a system call. The value increases monotonically, starts near zero at boot, and is unaffected by calendar clock adjustments, but it does not include time the system spends asleep: mach_continuous_time is defined in the kernel as mach_absolute_time plus the accumulated sleep time (mach_absolutetime_asleep), so intervals measured with mach_absolute_time exclude sleep while mach_continuous_time intervals include it. Values are meaningful only within a single boot session.
functionmach_approximate_time
__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0)
uint64_t mach_approximate_time(void)▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu libsyscall/wrappers/mach_approximate_time.c, libsyscall/wrappers/mach_approximate_time.s
Returns an approximation of mach_absolute_time, in the same mach absolute time units. When the commpage advertises APPROX_TIME_SUPPORTED, the value is read from a periodically updated commpage field, avoiding the cost of reading the hardware time base; the result may therefore lag the precise clock slightly. On configurations without commpage support the call falls back to mach_absolute_time exactly. Like mach_absolute_time, the clock does not advance while the system is asleep; mach_continuous_approximate_time is the variant that does.
functionmach_continuous_time
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0)
uint64_t mach_continuous_time(void)like mach_absolute_time, but advances during sleep
functionmach_continuous_approximate_time
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0)
uint64_t mach_continuous_approximate_time(void)like mach_approximate_time, but advances during sleep