#include <sys/time.h>

sys/time.h Kernel.framework

includes: sys/cdefs.h, sys/_types.h, machine/types.h, Kernel/stdint.h, sys/_types/_fd_def.h, Kernel/sys/_types/_timespec.h, Kernel/sys/_types/_timeval.h, Kernel/sys/_types/_timeval64.h, sys/_types/_user_timespec.h, sys/_types/_user32_timespec.h, sys/_types/_user64_timespec.h, sys/_types/_user_timeval.h, sys/_types/_user32_timeval.h, sys/_types/_user64_timeval.h, sys/_types/_user32_itimerval.h, sys/_types/_user64_itimerval.h, Kernel/sys/_types/_time_t.h, Kernel/sys/_types/_suseconds_t.h, Kernel/sys/_types/_fd_setsize.h, Kernel/sys/_types/_fd_set.h, Kernel/sys/_types/_fd_clr.h, Kernel/sys/_types/_fd_isset.h, Kernel/sys/_types/_fd_zero.h, Kernel/sys/_types/_fd_copy.h
8 functions · 5 macros

macroTIMEVAL64_TO_TIMESPEC

#define TIMEVAL64_TO_TIMESPEC(tv, ts) {
	(ts)->tv_sec = (time_t)((tv)->tv_sec);
	(ts)->tv_nsec = (tv)->tv_usec * 1000;
}

functionmicrotime

void microtime(struct timeval *tv)
claude-fable-5, 2026-08-23 · not from Apple sources · verified against xnu bsd/kern/kern_time.c
Returns the best possible estimate of the current calendar (wall clock) time in the timeval to which tv points, with microsecond resolution; wraps clock_get_calendar_microtime().

functionmicrotime_with_abstime

void microtime_with_abstime(struct timeval *tv, uint64_t *abstime)
claude-fable-5, 2026-08-23 · not from Apple sources · verified against xnu bsd/kern/kern_time.c
As microtime(), but additionally returns in *abstime the mach_absolute_time() value sampled atomically with the calendar time, allowing the caller to correlate wall clock time with the absolute timebase.

functionmicrouptime

void microuptime(struct timeval *tv)
claude-fable-5, 2026-08-23 · not from Apple sources · verified against xnu bsd/kern/kern_time.c
Returns the time elapsed since boot, excluding time the system slept, in the timeval to which tv points, with microsecond resolution; wraps clock_get_system_microtime().

macrogetmicrotime

#define getmicrotime(a) microtime(a)

macrogetmicrouptime

#define getmicrouptime(a) microuptime(a)

functionnanotime

void nanotime(struct timespec *ts)
claude-fable-5, 2026-08-23 · not from Apple sources · verified against xnu bsd/kern/kern_time.c
Returns the current calendar (wall clock) time in the timespec to which ts points, with nanosecond resolution; wraps clock_get_calendar_nanotime().

functionnanouptime

void nanouptime(struct timespec *ts)
claude-fable-5, 2026-08-23 · not from Apple sources · verified against xnu bsd/kern/kern_time.c
Returns the time elapsed since boot, excluding time the system slept, in the timespec to which ts points, with nanosecond resolution; wraps clock_get_system_nanotime().

macrogetnanotime

#define getnanotime(a) nanotime(a)

macrogetnanouptime

#define getnanouptime(a) nanouptime(a)

functiontimevaladd

void timevaladd(struct timeval *t1, struct timeval *t2)
claude-fable-5, 2026-08-23 · not from Apple sources · verified against xnu bsd/kern/kern_time.c
Adds timeval t2 to t1 in place, then normalizes the result with timevalfix() so tv_usec lies in [0, 1000000).

functiontimevalsub

void timevalsub(struct timeval *t1, struct timeval *t2)
claude-fable-5, 2026-08-23 · not from Apple sources · verified against xnu bsd/kern/kern_time.c
Subtracts timeval t2 from t1 in place, then normalizes the result with timevalfix(). The source cautions that results preceding the epoch (negative results) are not handled sensibly.

functiontimevalfix

void timevalfix(struct timeval *t1)
claude-fable-5, 2026-08-23 · not from Apple sources · verified against xnu bsd/kern/kern_time.c
Normalizes a timeval after arithmetic: if tv_usec is negative or at least 1000000, adjusts tv_sec and tv_usec by one second's worth of microseconds so that tv_usec lies in [0, 1000000).