#include <kern/clock.h>
kern/clock.h
typedefclock_sec_t
typedef unsigned long clock_sec_t
typedefclock_usec_t
typedef unsigned int clock_usec_t
typedefclock_nsec_t
typedef unsigned int clock_usec_t, clock_nsec_t
functionclock_get_calendar_microtime
extern void clock_get_calendar_microtime(clock_sec_t *secs, clock_usec_t *microsecs)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/clock.c
Returns the current calendar (wall clock) value, microseconds as the fraction. The calendar clock is the POSIX time-of-day maintained relative to the setting made through the settimeofday interfaces; it advances across sleep and may jump when the time is adjusted. Equivalent to clock_get_calendar_absolute_and_microtime with a NULL abstime argument.
functionclock_get_calendar_absolute_and_microtime
extern void clock_get_calendar_absolute_and_microtime( clock_sec_t *secs, clock_usec_t *microsecs, uint64_t *abstime )
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/clock.c
Returns the current calendar value, microseconds as the fraction, and additionally returns the matching mach_absolute_time value if abstime is not NULL. Both values are sampled under the clock lock, so the calendar time and absolute time are consistent with each other.
functionclock_get_calendar_nanotime
extern void clock_get_calendar_nanotime(clock_sec_t *secs, clock_nsec_t *nanosecs)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/clock.c
Returns the current calendar value, nanoseconds as the fraction. Since there is no interface to set the calendar with resolution greater than a microsecond, the value honors that resolution.
functionclock_get_system_microtime
extern void clock_get_system_microtime(clock_sec_t *secs, clock_usec_t *microsecs)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/i386/rtclock.c, osfmk/arm/rtclock.c
Returns the current system (uptime) clock value decomposed into whole seconds and residual microseconds. The system clock is mach_absolute_time converted to clock units; it starts at boot, never jumps, and unlike the calendar clock is unaffected by time-of-day adjustments.
functionclock_get_system_nanotime
extern void clock_get_system_nanotime(clock_sec_t *secs, clock_nsec_t *nanosecs)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/i386/rtclock.c, osfmk/arm/rtclock.c
Returns the current system (uptime) clock value decomposed into whole seconds and residual nanoseconds. The system clock is mach_absolute_time converted to clock units; it starts at boot and is unaffected by calendar adjustments.
functionclock_timebase_info
extern void clock_timebase_info(mach_timebase_info_t info)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/i386/rtclock.c, osfmk/arm/rtclock.c
Returns the mach_timebase_info numer/denom pair for converting absolute-time units to nanoseconds (nanoseconds = abstime * numer / denom). On Intel both are 1, absolute time being nanoseconds; on ARM the pair reflects the hardware timebase frequency.
functionclock_get_uptime
extern void clock_get_uptime(uint64_t *result)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/clock.c
Returns the current value of the system absolute-time clock in result; identical to mach_absolute_time(). The value is in absolute-time units, counts from boot, and does not include time spent asleep (see mach_continuous_time).
functionclock_interval_to_deadline
extern void clock_interval_to_deadline( uint32_t interval, uint32_t scale_factor, uint64_t *result )
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/clock.c
Converts an interval, expressed as a count of scale_factor-nanosecond units (scale_factor is typically NSEC_PER_SEC, NSEC_PER_MSEC, or NSEC_PER_USEC), to absolute-time units and adds the current mach_absolute_time, producing a deadline suitable for the timeout and thread_call interfaces. Saturates at UINT64_MAX on overflow.
functionnanoseconds_to_deadline
extern void nanoseconds_to_deadline(uint64_t interval, uint64_t *result)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/clock.c
Converts an interval in nanoseconds to absolute-time units and adds the current mach_absolute_time, producing a deadline. Saturates at UINT64_MAX on overflow.
functionclock_interval_to_absolutetime_interval
extern void clock_interval_to_absolutetime_interval( uint32_t interval, uint32_t scale_factor, uint64_t *result )
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/i386/rtclock.c, osfmk/arm/rtclock.c
Converts an interval, expressed as a count of scale_factor-nanosecond units, to an interval in absolute-time units (interval * scale_factor nanoseconds scaled by the timebase). scale_factor is typically NSEC_PER_SEC, NSEC_PER_MSEC, or NSEC_PER_USEC.
functionclock_absolutetime_interval_to_deadline
extern void clock_absolutetime_interval_to_deadline(uint64_t abstime, uint64_t *result)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/clock.c
Adds an interval already expressed in absolute-time units to the current mach_absolute_time, producing a deadline. Saturates at UINT64_MAX on overflow.
functionclock_continuoustime_interval_to_deadline
extern void clock_continuoustime_interval_to_deadline(uint64_t abstime, uint64_t *result)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/clock.c
Adds an interval expressed in absolute-time units to the current mach_continuous_time, producing a deadline on the continuous timebase, which unlike the absolute timebase keeps advancing while the system sleeps. Saturates at UINT64_MAX on overflow.
functionclock_delay_until
extern void clock_delay_until(uint64_t deadline)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/clock.c
Delays the calling thread until the specified mach_absolute_time deadline; returns immediately if the deadline has passed. For short intervals (per ml_delay_should_spin), or when called with preemption disabled or interrupts disabled, the delay spins via machine_delay_until; otherwise the thread blocks uninterruptibly on the deadline (assert_wait_deadline, thread_block). See also delay_for_interval.
functionabsolutetime_to_nanoseconds
extern void absolutetime_to_nanoseconds(uint64_t abstime, uint64_t *result)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/i386/rtclock.c, osfmk/arm/rtclock.c
Converts abstime, in absolute-time (mach_absolute_time) units, to nanoseconds. The identity conversion on Intel, where absolute time is nanoseconds; on ARM the value is scaled by the hardware timebase. Inverse of nanoseconds_to_absolutetime.
functionnanoseconds_to_absolutetime
extern void nanoseconds_to_absolutetime(uint64_t nanoseconds, uint64_t *result)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/i386/rtclock.c, osfmk/arm/rtclock.c
Converts a duration in nanoseconds to absolute-time (mach_absolute_time) units. The identity conversion on Intel; on ARM the value is scaled by the hardware timebase. Inverse of absolutetime_to_nanoseconds.
functionabsolutetime_to_microtime
extern void absolutetime_to_microtime( uint64_t abstime, clock_sec_t *secs, clock_usec_t *microsecs )
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/i386/rtclock.c, osfmk/arm/rtclock.c
Decomposes an absolute-time value into whole seconds and residual microseconds.
functionabsolutetime_to_continuoustime
extern uint64_t absolutetime_to_continuoustime(uint64_t abstime)
Absolute <-> Continuous Time conversion routines
It is the caller's responsibility to ensure that these functions are
synchronized with respect to updates to the continuous timebase. The
returned value is only valid until the next update to the continuous
timebase.
If the value to be returned by continuoustime_to_absolutetime would be
negative, zero is returned. This occurs when the provided continuous time
is less the amount of the time the system spent asleep and /must/ be
handled.
functioncontinuoustime_to_absolutetime
extern uint64_t continuoustime_to_absolutetime(uint64_t conttime)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/clock.c
Converts a mach_continuous_time value to the corresponding mach_absolute_time value by subtracting the accumulated sleep time (mach_absolutetime_asleep); returns 0 if conttime falls at or before that boundary. Must be called with interrupts disabled, and the result is valid only until the next update of mach_continuous_time.
variablemach_absolutetime_asleep
extern uint64_t mach_absolutetime_asleep
variablemach_absolutetime_last_sleep
extern uint64_t mach_absolutetime_last_sleep