#include <mach/port_obj.h> not included by <mach/mach.h> — include it explicitly

mach/port_obj.h

Define a service to map from a kernel-generated port name to server-defined "type" and "value" data to be associated with the port.
4 macros · 2 variables · 1 struct · 1 function

macroPORT_OBJ_H

#define PORT_OBJ_H 

structport_obj_tentry

size 16, align 8
void *pos_value
intpos_type

functionport_obj_init

extern void port_obj_init(int)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu libsyscall/mach/port_obj.c, libsyscall/mach/mach/port_obj.h
Initializes the port_obj facility, a service that maps a kernel-generated port name to server-defined type and value data. Allocates the global port_obj_table with vm_allocate, sized for maxsize port_obj_tentry entries (the default table size is 64K entries); calls panic if the allocation fails. Entries are indexed by MACH_PORT_INDEX of the port name and accessed through the port_set_obj_value_type, port_get_obj_value, and port_get_obj_type macros, which invoke port_obj_init lazily on first use.

variableport_obj_table

extern struct port_obj_tentry *port_obj_table

variableport_obj_table_size

extern int port_obj_table_size

macroport_set_obj_value_type

#define port_set_obj_value_type(pname, value, type) do {
	int ndx;

	if (!port_obj_table)
	        port_obj_init(port_obj_table_size);
	ndx = MACH_PORT_INDEX(pname);
	port_obj_table[ndx].pos_value = (value);
	port_obj_table[ndx].pos_type = (type);
} while (0)

macroport_get_obj_value

#define port_get_obj_value(pname) (port_obj_table[MACH_PORT_INDEX(pname)].pos_value)

macroport_get_obj_type

#define port_get_obj_type(pname) (port_obj_table[MACH_PORT_INDEX(pname)].pos_type)