#include <kern/locks.h>
kern/locks.h
macrodecl_lck_spin_data
#define decl_lck_spin_data(class, name) class lck_spin_t name
functionlck_spin_alloc_init
extern lck_spin_t *lck_spin_alloc_init(lck_grp_t *grp, lck_attr_t *attr)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm/locks_arm.c
Allocates a spin lock and initializes it in the manner of lck_spin_init with the given group and attributes. The result is freed with lck_spin_free.
functionlck_spin_init
extern void lck_spin_init(lck_spin_t *lck, lck_grp_t *grp, lck_attr_t *attr)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm/locks_arm.c
Initializes a spin lock, associating it with the given lock group (attributes are currently unused). Spin locks busy-wait with preemption disabled and are suitable for short critical sections, including ones taken from interrupt context; depending on platform configuration they are implemented as ticket locks.
functionlck_spin_lock
extern void lck_spin_lock(lck_spin_t *lck)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm/locks_arm.c
Locks the spin lock, disabling preemption and busy-waiting until it is available. Recursive acquisition by the holder is a deadlock; timeouts on the underlying hardware lock panic on time-limit exceeded.
functionlck_spin_lock_grp
extern void lck_spin_lock_grp(lck_spin_t *lck, lck_grp_t *grp)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm/locks_arm.c
As lck_spin_lock, but attributes the acquisition (for lock statistics) to the given lock group. Functionally identical to lck_spin_lock when statistics are not enabled.
functionlck_spin_unlock
extern void lck_spin_unlock(lck_spin_t *lck)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm/locks_arm.c
Unlocks the spin lock and re-enables preemption.
functionlck_spin_destroy
extern void lck_spin_destroy(lck_spin_t *lck, lck_grp_t *grp)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm/locks_arm.c
Destroys a spin lock initialized with lck_spin_init, marking it unusable and dropping its reference on the lock group. Does not free the memory; for locks obtained from lck_spin_alloc_init use lck_spin_free.
functionlck_spin_free
extern void lck_spin_free(lck_spin_t *lck, lck_grp_t *grp)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/arm/locks_arm.c
Destroys a spin lock allocated by lck_spin_alloc_init and frees its memory.
functionlck_spin_sleep
extern wait_result_t lck_spin_sleep( lck_spin_t *lck, lck_sleep_action_t lck_sleep_action, event_t event, wait_interrupt_t interruptible )
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/locks.c
Atomically releases the spin lock and waits for the specified event; on wakeup the lock is re-acquired unless LCK_SLEEP_UNLOCK is set in lck_sleep_action. Returns the wait result per the interruptible argument (THREAD_AWAKENED, THREAD_INTERRUPTED, ...). Panics on invalid action bits. Spin-mode-only actions such as LCK_SLEEP_SPIN do not apply.
functionlck_spin_sleep_grp
extern wait_result_t lck_spin_sleep_grp( lck_spin_t *lck, lck_sleep_action_t lck_sleep_action, event_t event, wait_interrupt_t interruptible, lck_grp_t *grp )
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/locks.c
As lck_spin_sleep, but attributes the re-acquisition of the lock to the given lock group for statistics purposes.
functionlck_spin_sleep_deadline
extern wait_result_t lck_spin_sleep_deadline( lck_spin_t *lck, lck_sleep_action_t lck_sleep_action, event_t event, wait_interrupt_t interruptible, uint64_t deadline )
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/locks.c
As lck_spin_sleep, but the wait is bounded by an absolute deadline in mach_absolute_time units (via assert_wait_deadline); the wait result is THREAD_TIMED_OUT if the deadline expires before wakeup.
macroLCK_SPIN_ASSERT
#define LCK_SPIN_ASSERT(lck, type)
macroLCK_SPIN_ASSERT_DEBUG
#define LCK_SPIN_ASSERT_DEBUG(lck, type)
macroLCK_ASSERT_OWNED
#define LCK_ASSERT_OWNED 1
macroLCK_ASSERT_NOTOWNED
#define LCK_ASSERT_NOTOWNED 2