#include <mach/port.h>

mach/port.h Kernel.framework

NOTICE: This file was modified by McAfee Research in 2004 to introduce support for mandatory and extensible security protections. This notice is included in support of clause 2.2 (b) of the Apple Public License, Version 2.0.
includes: sys/cdefs.h, Kernel/stdint.h, Kernel/mach/boolean.h, Kernel/mach/machine/vm_types.h
10 macros · 5 typedefs · 1 function

macroxnu_static_assert_struct_size_kernel_user

64-bit kernel build
#define xnu_static_assert_struct_size_kernel_user(name, expected_kernel_size, expected_user_size) xnu_static_assert_struct_size(name, expected_kernel_size)

macroxnu_static_assert_struct_size_kernel_user64_user32

#define xnu_static_assert_struct_size_kernel_user64_user32(name, expected_kernel_size, _u64_size, _u32_size) xnu_static_assert_struct_size(name, expected_kernel_size)

typedefipc_port_t

typedef struct ipc_port *ipc_port_t

macroIPC_PORT_NULL

#define IPC_PORT_NULL __unsafe_forge_single(ipc_port_t, NULL)

macroIPC_PORT_DEAD

#define IPC_PORT_DEAD __unsafe_forge_single(ipc_port_t, ~0UL)

macroIPC_PORT_VALID

#define IPC_PORT_VALID(port) ipc_port_valid(port)

functionipc_port_valid

static inline boolean_t ipc_port_valid(ipc_port_t port)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu osfmk/mach/port.h
Returns TRUE if the port pointer denotes a usable port: neither IPC_PORT_NULL nor IPC_PORT_DEAD. Inline predicate behind the IPC_PORT_VALID macro.

typedefmach_port_t

typedef ipc_port_t mach_port_t

macroCAST_MACH_PORT_TO_NAME

#define CAST_MACH_PORT_TO_NAME(x) ((mach_port_name_t)(uintptr_t)(x))

macroCAST_MACH_NAME_TO_PORT

#define CAST_MACH_NAME_TO_PORT(x) ((x) == MACH_PORT_DEAD ? (mach_port_t)IPC_PORT_DEAD : (mach_port_t)(uintptr_t)(x))

typedefport_t

Mach 3.0 renamed everything to have mach_ in front of it. These types and macros are provided for backward compatibility but are deprecated.
typedef mach_port_t port_t

typedefport_name_t

typedef mach_port_name_t port_name_t

typedefport_name_array_t

typedef mach_port_name_t *port_name_array_t

macroPORT_NULL

#define PORT_NULL ((port_t) 0)

macroPORT_DEAD

#define PORT_DEAD ((port_t) ~0)

macroPORT_VALID

#define PORT_VALID(name) ((port_t)(name) != PORT_NULL && (port_t)(name) != PORT_DEAD)