#include <mach/mach_traps.h> also included by <mach/mach.h>

mach/mach_traps.h

39 functions

functionclock_sleep_trap

extern kern_return_t clock_sleep_trap(
	mach_port_name_t clock_name,
	sleep_type_t sleep_type,
	int sleep_sec,
	int sleep_nsec,
	mach_timespec_t *wakeup_time
)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/clock_oldops.c
Sleeps the calling thread on a clock. Trap form underlying the libmach clock_sleep call, which splits its mach_timespec_t argument into the sleep_sec and sleep_nsec words. sleep_type is TIME_ABSOLUTE or TIME_RELATIVE; clock_name of MACH_PORT_NULL means the system clock, and only the system clock is accepted (KERN_FAILURE otherwise). A malformed sleep time returns KERN_INVALID_VALUE. On success the time of wakeup is copied out through wakeup_time. The wait is abortable; thread_abort causes KERN_ABORTED.

function_kernelrpc_mach_vm_allocate_trap

extern kern_return_t _kernelrpc_mach_vm_allocate_trap(
	mach_port_name_t target,
	mach_vm_offset_t *addr,
	mach_vm_size_t size,
	int flags
)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/ipc/mach_kernelrpc.c
Trap fast path of the MIG routine mach_vm_allocate: allocates a zero-filled region of size bytes in the task's address space, copying the chosen address back through addr. target must name the current task, else MACH_SEND_INVALID_DEST; flags are as for mach_vm_allocate (VM_FLAGS_ANYWHERE, VM_FLAGS_FIXED, tag values). See mach_vm_allocate for the full contract.

function_kernelrpc_mach_vm_deallocate_trap

extern kern_return_t _kernelrpc_mach_vm_deallocate_trap(
	mach_port_name_t target,
	mach_vm_address_t address,
	mach_vm_size_t size
)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/ipc/mach_kernelrpc.c
Trap fast path of the MIG routine mach_vm_deallocate: deallocates the specified range of the task's address space. target must name the current task, else MACH_SEND_INVALID_DEST. See mach_vm_deallocate.

functiontask_dyld_process_info_notify_get

extern kern_return_t task_dyld_process_info_notify_get(
	mach_port_name_array_t names_addr,
	natural_t *names_count_addr
)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/ipc/mach_kernelrpc.c (task_dyld_process_info_notify_get_trap)
Returns the names of the active dyld notifier ports registered for the calling task, copying up to *names_count_addr port names into the caller-allocated array at names_addr and setting *names_count_addr to the number actually returned (possibly zero). The caller owns the returned send rights and must deallocate them. Returns KERN_NO_SPACE if the supplied array is too small (or the in-count is zero), KERN_INVALID_ARGUMENT for null addresses, and KERN_MEMORY_ERROR class failures for bad copyio. Used by dyld's process-info notification machinery.

function_kernelrpc_mach_vm_protect_trap

extern kern_return_t _kernelrpc_mach_vm_protect_trap(
	mach_port_name_t target,
	mach_vm_address_t address,
	mach_vm_size_t size,
	boolean_t set_maximum,
	vm_prot_t new_protection
)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/ipc/mach_kernelrpc.c
Trap fast path of the MIG routine mach_vm_protect: sets the current (or, with set_maximum, the maximum) protection of the specified address range to new_protection. target must name the current task, else MACH_SEND_INVALID_DEST. See mach_vm_protect.

function_kernelrpc_mach_vm_map_trap

extern kern_return_t _kernelrpc_mach_vm_map_trap(
	mach_port_name_t target,
	mach_vm_offset_t *address,
	mach_vm_size_t size,
	mach_vm_offset_t mask,
	int flags,
	vm_prot_t cur_protection
)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/ipc/mach_kernelrpc.c
Trap fast path of the MIG routine mach_vm_map, restricted to anonymous memory: maps zero-filled memory (no memory object may be supplied) of the given size at an address constrained by mask and flags, with cur_protection as the initial protection, VM_PROT_ALL maximum, and VM_INHERIT_DEFAULT inheritance. The chosen address is copied back through address. target must name the current task, else MACH_SEND_INVALID_DEST. See mach_vm_map for the general routine.

function_kernelrpc_mach_vm_purgable_control_trap

extern kern_return_t _kernelrpc_mach_vm_purgable_control_trap(
	mach_port_name_t target,
	mach_vm_offset_t address,
	vm_purgable_t control,
	int *state
)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/ipc/mach_kernelrpc.c
Trap fast path of the MIG routine mach_vm_purgable_control: queries or changes the purgeability state of the purgable memory object backing the given address. control is VM_PURGABLE_SET_STATE or VM_PURGABLE_GET_STATE; state is an in/out word (VM_PURGABLE_NONVOLATILE, VM_PURGABLE_VOLATILE, VM_PURGABLE_EMPTY). target must name the current task, else MACH_SEND_INVALID_DEST. See mach_vm_purgable_control.

function_kernelrpc_mach_port_allocate_trap

extern kern_return_t _kernelrpc_mach_port_allocate_trap(
	mach_port_name_t target,
	mach_port_right_t right,
	mach_port_name_t *name
)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/ipc/mach_kernelrpc.c
Trap fast path of the MIG routine mach_port_allocate: creates a new right of the given kind (MACH_PORT_RIGHT_RECEIVE, MACH_PORT_RIGHT_PORT_SET, MACH_PORT_RIGHT_DEAD_NAME) in the task's port name space, copying the new name out through name. target must name the current task, else MACH_SEND_INVALID_DEST. See mach_port_allocate.

function_kernelrpc_mach_port_deallocate_trap

extern kern_return_t _kernelrpc_mach_port_deallocate_trap(
	mach_port_name_t target,
	mach_port_name_t name
)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/ipc/mach_kernelrpc.c
Trap fast path of the MIG routine mach_port_deallocate: releases one user reference for the send, send-once, or dead-name right named by name. target must name the current task, else MACH_SEND_INVALID_DEST. See mach_port_deallocate.

function_kernelrpc_mach_port_mod_refs_trap

extern kern_return_t _kernelrpc_mach_port_mod_refs_trap(
	mach_port_name_t target,
	mach_port_name_t name,
	mach_port_right_t right,
	mach_port_delta_t delta
)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/ipc/mach_kernelrpc.c
Trap fast path of the MIG routine mach_port_mod_refs: modifies by delta the user-reference count of the right of type right named by name. target must name the current task, else MACH_SEND_INVALID_DEST. See mach_port_mod_refs.

function_kernelrpc_mach_port_move_member_trap

extern kern_return_t _kernelrpc_mach_port_move_member_trap(
	mach_port_name_t target,
	mach_port_name_t member,
	mach_port_name_t after
)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/ipc/mach_kernelrpc.c
Trap fast path of the MIG routine mach_port_move_member: moves the receive right member into the port set after, removing it from any set it currently belongs to; after of MACH_PORT_NULL removes it from all sets. target must name the current task, else MACH_SEND_INVALID_DEST. See mach_port_move_member.

function_kernelrpc_mach_port_insert_right_trap

extern kern_return_t _kernelrpc_mach_port_insert_right_trap(
	mach_port_name_t target,
	mach_port_name_t name,
	mach_port_name_t poly,
	mach_msg_type_name_t polyPoly
)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/ipc/mach_kernelrpc.c
Trap fast path of the MIG routine mach_port_insert_right: inserts into the task's name space, under the name name, the right carried by local name poly with disposition polyPoly. The common case name == poly with MACH_MSG_TYPE_MAKE_SEND or MACH_MSG_TYPE_COPY_SEND (adding a send right under the same name as the receive right) takes an additional fast path. target must name the current task, else MACH_SEND_INVALID_DEST. See mach_port_insert_right.

function_kernelrpc_mach_port_get_attributes_trap

extern kern_return_t _kernelrpc_mach_port_get_attributes_trap(
	mach_port_name_t target,
	mach_port_name_t name,
	mach_port_flavor_t flavor,
	mach_port_info_t port_info_out,
	mach_msg_type_number_t *port_info_outCnt
)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/ipc/mach_kernelrpc.c
Trap fast path of the MIG routine mach_port_get_attributes: returns attributes of the named port according to flavor (MACH_PORT_LIMITS_INFO, MACH_PORT_RECEIVE_STATUS, MACH_PORT_DNREQUESTS_SIZE, ...). port_info_outCnt is in/out: on entry the capacity of the caller's buffer, on return the number of integer_t elements written; requests larger than the kernel maximum are truncated. target must name the current task, else MACH_SEND_INVALID_DEST. See mach_port_get_attributes.

function_kernelrpc_mach_port_insert_member_trap

extern kern_return_t _kernelrpc_mach_port_insert_member_trap(
	mach_port_name_t target,
	mach_port_name_t name,
	mach_port_name_t pset
)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/ipc/mach_kernelrpc.c
Trap fast path of the MIG routine mach_port_insert_member: adds the receive right name to the port set pset; a receive right may belong to multiple port sets. target must name the current task, else MACH_SEND_INVALID_DEST. See mach_port_insert_member.

function_kernelrpc_mach_port_extract_member_trap

extern kern_return_t _kernelrpc_mach_port_extract_member_trap(
	mach_port_name_t target,
	mach_port_name_t name,
	mach_port_name_t pset
)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/ipc/mach_kernelrpc.c
Trap fast path of the MIG routine mach_port_extract_member: removes the receive right name from the port set pset. target must name the current task, else MACH_SEND_INVALID_DEST. See mach_port_extract_member.

function_kernelrpc_mach_port_construct_trap

extern kern_return_t _kernelrpc_mach_port_construct_trap(
	mach_port_name_t target,
	mach_port_options_t *options,
	uint64_t context,
	mach_port_name_t *name
)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/ipc/mach_kernelrpc.c
Trap fast path of the MIG routine mach_port_construct: creates a receive right configured according to the mach_port_options_t copied in from options (flags such as MPO_CONTEXT_AS_GUARD, MPO_QLIMIT, MPO_INSERT_SEND_RIGHT; context supplies the guard value when guarded), copying the new name out through name. target must name the current task, else MACH_SEND_INVALID_DEST. See mach_port_construct.

function_kernelrpc_mach_port_destruct_trap

extern kern_return_t _kernelrpc_mach_port_destruct_trap(
	mach_port_name_t target,
	mach_port_name_t name,
	mach_port_delta_t srdelta,
	uint64_t guard
)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/ipc/mach_kernelrpc.c
Trap fast path of the MIG routine mach_port_destruct: destroys the receive right name after unguarding it with guard and applying srdelta to its send-right reference count; the inverse of mach_port_construct. target must name the current task, else MACH_SEND_INVALID_DEST. See mach_port_destruct.

function_kernelrpc_mach_port_guard_trap

extern kern_return_t _kernelrpc_mach_port_guard_trap(
	mach_port_name_t target,
	mach_port_name_t name,
	uint64_t guard,
	boolean_t strict
)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/ipc/mach_kernelrpc.c
Trap fast path of the MIG routine mach_port_guard: guards the receive right name with the value guard; subsequent destruction or mod_refs operations must present the guard. With strict, unguard requests must match exactly. Guard violations raise a mach port guard exception. target must name the current task, else MACH_SEND_INVALID_DEST. See mach_port_guard.

function_kernelrpc_mach_port_unguard_trap

extern kern_return_t _kernelrpc_mach_port_unguard_trap(
	mach_port_name_t target,
	mach_port_name_t name,
	uint64_t guard
)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/ipc/mach_kernelrpc.c
Trap fast path of the MIG routine mach_port_unguard: removes the guard from the receive right name; guard must match the value previously established, else a guard exception is raised. target must name the current task, else MACH_SEND_INVALID_DEST. See mach_port_unguard.

functionmach_generate_activity_id

extern kern_return_t mach_generate_activity_id(
	mach_port_name_t target,
	int count,
	uint64_t *activity_id
)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/ipc/ipc_voucher.c
Atomically reserves count system-wide voucher activity identifiers, copying the first id of the reserved range out through activity_id. count must be between 1 and MACH_ACTIVITY_ID_COUNT_MAX, else KERN_INVALID_ARGUMENT. Used by libtrace/os_activity to stamp activities carried in vouchers.

functionmacx_swapon

extern kern_return_t macx_swapon(uint64_t filename, int flags, int size, int priority)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu bsd/vm/dp_backing_file.c
Obsolete. Formerly added a file to the default pager's backing store (dynamic_pager). With the removal of the external default pager in favor of the in-kernel compressor and swap, the trap is a stub returning ENOTSUP.

functionmacx_swapoff

extern kern_return_t macx_swapoff(uint64_t filename, int flags)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu bsd/vm/dp_backing_file.c
Obsolete. Formerly removed a file from the default pager's backing store. Now a stub returning ENOTSUP; swap files are managed entirely by the kernel compressor.

functionmacx_triggers

extern kern_return_t macx_triggers(
	int hi_water,
	int low_water,
	int flags,
	mach_port_t alert_port
)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu bsd/vm/dp_backing_file.c
Mostly obsolete. Formerly registered the dynamic pager's high/low water mark alert port. The only remaining function is flag SWAP_COMPACT_DISABLE or SWAP_COMPACT_ENABLE, which turns swap-space compaction off or on (used across shutdown/restart so swap files about to be deleted are not compacted); this path requires superuser. All other flag combinations return ENOTSUP; hi_water, low_water and alert_port are ignored.

functionmacx_backing_store_suspend

extern kern_return_t macx_backing_store_suspend(boolean_t suspend)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu bsd/vm/dp_backing_file.c
Obsolete. Formerly stopped new demand for backing store when backing store was low. Now a stub returning ENOTSUP.

functionmacx_backing_store_recovery

extern kern_return_t macx_backing_store_recovery(int pid)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu bsd/vm/dp_backing_file.c
Obsolete. Formerly marked a task privileged so it was not subject to macx_backing_store_suspend. Now a stub returning ENOTSUP.

functionswtch_pri

extern boolean_t swtch_pri(int pri)
GNU Mach reference · 7.1.6.2 Hand-Off Scheduling · © FSF, GFDL
boolean_t swtch_pri(int priority)
The system trap swtch_pri attempts to switch the current thread off the processor as swtch does, but depressing the priority of the thread to the minimum possible value during the time. priority is not used currently. The return value is as for swtch.

functionswtch

extern boolean_t swtch(void)
GNU Mach reference · 7.1.6.2 Hand-Off Scheduling · © FSF, GFDL
boolean_t swtch()
The system trap swtch attempts to switch the current thread off the processor. The return value indicates if more than the current thread is running in the processor set. This is useful for lock management routines. The call returns FALSE if the thread is justified in becoming a resource hog by continuing to spin because there's nothing else useful that the processor could do. TRUE is returned if the thread should make one more check on the lock and then be a good citizen and really suspend.

functionthread_switch

extern kern_return_t thread_switch(
	mach_port_name_t thread_name,
	int option,
	mach_msg_timeout_t option_time
)
CMU/MIT Mach reference · manual page · © Carnegie Mellon
Cause context switch with options.
The thread_switch function provides low-level access to the scheduler's context switching code. new_thread is a hint that implements hand-off scheduling. The operating system will attempt to switch directly to the new thread (bypassing the normal logic that selects the next thread to run) if possible. Since this is a hint, it may be incorrect; it is ignored if it doesn't specify a thread on the same host as the current thread or if the scheduler cannot switch to that thread (i.e., not runable or already running on another processor). In this case, the normal logic to select the next thread to run is used; the current thread may continue running if there is no other appropriate thread to run. The option argument specifies the interpretation and use of time. The possible values (from \*L \*O) are: SWITCH_OPTION_NONE The time argument is ignored. SWITCH_OPTION_WAIT The thread is blocked for the specified time. This wait cannot be canceled by thread_resume; only thread_abort can terminate this wait. SWITCH_OPTION_DEPRESS The thread's scheduling attributes are temporarily set so as to provide it with the lowest possible service for duration time. The scheduling depression is aborted when time has passed, when the current thread is next run (either via hand-off scheduling or because the processor set has nothing better to do), or when thread_abort or thread_depress_abort is applied to the current thread. Changing the thread's scheduling attributes (via thread_policy) will not affect this depression. SWITCH_OPTION_IDLE This option is similar to SWITCH_OPTION_DEPRESS however, the thread's scheduling attributes are temporarily set so as to place it at a service level that is below all runnable threads for duration time. The scheduling depression is aborted when time has passed, when the current thread is next run (either via hand-off scheduling or because the processor set has nothing better to do), or when thread_abort or thread_depress_abort is applied to the current thread. Changing the thread's scheduling attributes (via thread_policy) will not affect this depression. The minimum time and units of time can be obtained as the min_timeout value from the HOST_SCHED_INFO flavor of host_info.
Notes. thread_switch is often called when the current thread can proceed no further for some reason; the various options and arguments allow information about this reason to be transmitted to the kernel. The new_thread argument (hand-off scheduling) is useful when the identity of the thread that must make progress before the current thread runs again is known. The SWITCH_OPTION_WAIT option is used when the amount of time that the current thread must wait before it can do anything useful can be estimated and is fairly short, especially when the identity of the thread for which this thread must wait is not known.
Cautions. Users should beware of calling thread_switch with an invalid hint (e.g., THREAD_NULL) and no option. Because the time-sharing scheduler varies the priority of threads based on usage, this may result in a waste of CPU time if the thread that must be run is of lower priority. The use of the SWITCH_OPTION_DEPRESS option in this situation is highly recommended. thread_switch ignores policies. Users relying on the preemption semantics of a fixed time policy should be aware that thread_switch ignores these semantics; it will run the specified new_thread independent of its scheduling attributes and those of any threads that could run instead.
GNU Mach reference · 7.1.6.2 Hand-Off Scheduling · © FSF, GFDL
kern_return_t thread_switch(thread_t new_thread, int option, int time)
The function thread_switch provides low-level access to the scheduler's context switching code. new_thread is a hint that implements hand-off scheduling. The operating system will attempt to switch directly to the new thread (bypassing the normal logic that selects the next thread to run) if possible. Since this is a hint, it may be incorrect; it is ignored if it doesn't specify a thread on the same host as the current thread or if that thread can't be switched to (i.e., not runnable or already running on another processor or giving a plainly invalid hint, such as MACH_PORT_NULL). In this case, the normal logic to select the next thread to run is used; the current thread may continue running if there is no other appropriate thread to run. Options for option are defined in mach/thread_switch.h and specify the interpretation of time. The possible values for option are: SWITCH_OPTION_NONENo options, the time argument is ignored. SWITCH_OPTION_WAITThe thread is blocked for the specified time (in milliseconds; specifying 0 will wait for the next tick). This can be aborted by thread_abort. SWITCH_OPTION_DEPRESSThe thread's priority is depressed to the lowest possible value for the specified time. This can be aborted by thread_depress_abort. This depression is independent of operations that change the thread's priority (e.g. thread_priority will not abort the depression). The minimum time and units of time can be obtained as the min_timeout value from host_info. The depression is also aborted when the current thread is next run (either via hand-off scheduling or because the processor set has nothing better to do). thread_switch is often called when the current thread can proceed no further for some reason; the various options and arguments allow information about this reason to be transmitted to the kernel. The new_thread argument (handoff scheduling) is useful when the identity of the thread that must make progress before the current thread runs again is known. The WAIT option is used when the amount of time that the current thread must wait before it can do anything useful can be estimated and is fairly long. The DEPRESS option is used when the amount of time that must be waited is fairly short, especially when the identity of the thread that is being waited for is not known. Users should beware of calling thread_switch with an invalid hint (e.g. MACH_PORT_NULL) and no option. Because the time-sharing scheduler varies the priority of threads based on usage, this may result in a waste of cpu time if the thread that must be run is of lower priority. The use of the DEPRESS option in this situation is highly recommended. thread_switch ignores policies. Users relying on the preemption semantics of a fixed time policy should be aware that thread_switch ignores these semantics; it will run the specified new_thread independent of its priority and the priority of any other threads that could be run instead. The function returns KERN_SUCCESS if the call succeeded, KERN_INVALID_ARGUMENT if thread is not a thread or option is not a recognized option, and KERN_FAILURE if kern_depress_abort failed because the thread was not depressed.

functiontask_self_trap

extern mach_port_name_t task_self_trap(void)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/kern/ipc_tt.c
Returns a name for send rights to the calling task's own task (control) port; the trap behind mach_task_self. Returns MACH_PORT_NULL on resource failure or other error.

functionhost_create_mach_voucher_trap

extern kern_return_t host_create_mach_voucher_trap(
	mach_port_name_t host,
	mach_voucher_attr_raw_recipe_array_t recipes,
	int recipes_size,
	mach_port_name_t *voucher
)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/ipc/mach_kernelrpc.c
Trap fast path of the MIG routine host_create_mach_voucher: creates a Mach voucher from the array of attribute recipes copied in from recipes (recipes_size bytes, at most MACH_VOUCHER_ATTR_MAX_RAW_RECIPE_ARRAY_SIZE, else MIG_ARRAY_TOO_LARGE), returning a send right for the new voucher through voucher. An invalid host port returns MACH_SEND_INVALID_DEST; a negative size KERN_INVALID_ARGUMENT. See host_create_mach_voucher.

functionmach_voucher_extract_attr_recipe_trap

extern kern_return_t mach_voucher_extract_attr_recipe_trap(
	mach_port_name_t voucher_name,
	mach_voucher_attr_key_t key,
	mach_voucher_attr_raw_recipe_t recipe,
	mach_msg_type_number_t *recipe_size
)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/ipc/mach_kernelrpc.c
Trap fast path of the MIG routine mach_voucher_extract_attr_recipe: extracts from the voucher named by voucher_name the recipe for the attribute keyed by key, copying it out to recipe. recipe_size is in/out: the caller's buffer size on entry (at most MACH_VOUCHER_ATTR_MAX_RAW_RECIPE_ARRAY_SIZE, else MIG_ARRAY_TOO_LARGE), the recipe size on return. An invalid voucher name returns MACH_SEND_INVALID_DEST. See mach_voucher_extract_attr_recipe.

function_kernelrpc_mach_port_type_trap

extern kern_return_t _kernelrpc_mach_port_type_trap(
	ipc_space_t task,
	mach_port_name_t name,
	mach_port_type_t *ptype
)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/ipc/mach_kernelrpc.c
Trap fast path of the MIG routine mach_port_type: returns through ptype the MACH_PORT_TYPE_* bits describing the rights held under the given name in the task's port name space. task must name the current task, else MACH_SEND_INVALID_DEST. See mach_port_type.

function_kernelrpc_mach_port_request_notification_trap

extern kern_return_t _kernelrpc_mach_port_request_notification_trap(
	ipc_space_t task,
	mach_port_name_t name,
	mach_msg_id_t msgid,
	mach_port_mscount_t sync,
	mach_port_name_t notify,
	mach_msg_type_name_t notifyPoly,
	mach_port_name_t *previous
)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/ipc/mach_kernelrpc.c
Trap fast path of the MIG routine mach_port_request_notification: registers the send-once right notify (disposition notifyPoly, which must translate to MACH_MSG_TYPE_PORT_SEND_ONCE) to receive the notification msgid (MACH_NOTIFY_PORT_DESTROYED, MACH_NOTIFY_DEAD_NAME, MACH_NOTIFY_NO_SENDERS, with sync as the sync/mscount value) for the right name. The name of the previously registered notify port, or MACH_PORT_NULL, is copied out through previous. task must name the current task, else MACH_SEND_INVALID_DEST. See mach_port_request_notification.

functiontask_for_pid

extern kern_return_t task_for_pid(
	mach_port_name_t target_tport,
	int pid,
	mach_port_name_t *t
)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu bsd/kern/kern_proc.c
Returns through t a send right to the task control port of the process with the given pid, in the caller's name space. Heavily restricted: pid 0 always fails; the caller must pass the task_for_pid policy checks -- root or an appropriately entitled process, posix credential checks, MACF mac_proc_check_get_task, and, where a task access port is registered, authorization by the task access server (taskgated). Denial returns KERN_FAILURE (MACH_PORT_NULL is copied out). target_tport is the caller's task port; audit records are generated. See also task_name_for_pid, debug_control_port_for_pid, pid_for_task.

functiontask_name_for_pid

extern kern_return_t task_name_for_pid(
	mach_port_name_t target_tport,
	int pid,
	mach_port_name_t *tn
)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu bsd/kern/kern_proc.c
Returns through tn a send right to the task name port -- an unprivileged handle usable for identity and basic task_info only -- of the process with the given pid. Permitted for root, for processes with matching effective and real user IDs, or with the com.apple.system-task-ports.name.safe entitlement, subject to MACF mac_proc_check_get_task with TASK_FLAVOR_NAME. Failure returns KERN_FAILURE and copies out MACH_PORT_NULL. See task_for_pid.

functionpid_for_task

extern kern_return_t pid_for_task(mach_port_name_t t, int *x)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu bsd/kern/kern_proc.c
Returns through x the BSD process ID of the task named by port t (a task, task name, or related port). For a corpse task the corpse's pid is returned. Copies -1 and returns KERN_FAILURE if the port does not name a task with an associated process. Inverse of task_for_pid.

functiondebug_control_port_for_pid

extern kern_return_t debug_control_port_for_pid(
	mach_port_name_t target_tport,
	int pid,
	mach_port_name_t *t
)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu bsd/kern/kern_proc.c
Returns through t a send right to the debug control port of the process with the given pid. Requires the debug-port entitlement, or passage of the task_for_pid-style checks (MACF mac_proc_check_get_task with TASK_FLAVOR_CONTROL, posix checks, task access server upcall where registered; KERN_PROTECTION_FAILURE if the access port is dead). pid 0 and corpse tasks fail with KERN_FAILURE. See task_for_pid.

functionmach_vm_reclaim_update_kernel_accounting_trap

extern mach_error_t mach_vm_reclaim_update_kernel_accounting_trap(
	mach_port_name_t target_tport,
	uint64_t *bytes_reclaimed,
	uint64_t *next_deadline
)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/ipc/mach_kernelrpc.c
Forces the kernel to update its accounting for the target task's deferred-reclamation (mach_vm_reclaim) ring, copying the number of bytes reclaimed out through bytes_reclaimed. target_tport must name the current task, else MACH_SEND_INVALID_DEST; a null bytes_reclaimed pointer returns KERN_INVALID_ARGUMENT. Returns KERN_NOT_SUPPORTED on kernels built without CONFIG_DEFERRED_RECLAIM. Part of the libmalloc deferred memory reclamation interface.

functionthread_set_x86_64_compat

extern kern_return_t thread_set_x86_64_compat(uint32_t enable)
claude-fable-5, 2026-08-24 · not from Apple sources
Implementation not present in this xnu checkout (the trap slot is retired). Per the declaration, takes a single enable word and returns kern_return_t; the name indicates it configured x86-64 compatibility (32-bit code segment) execution for the calling thread on Intel systems. Specific semantics unverified.