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

mach/mig.h

Mach MIG Subsystem Interfaces
12 typedefs · 7 functions · 4 macros · 3 structs

typedefmig_stub_routine_t

Definition for MIG-generated server stub routines. These routines unpack the request message, call the server procedure, and pack the reply message.
typedef void (*)(mach_msg_header_t *, mach_msg_header_t *) mig_stub_routine_t;

typedefmig_routine_t

typedef mig_stub_routine_t mig_routine_t

typedefmig_server_routine_t

Definition for MIG-generated server routine. This routine takes a message, and returns the appropriate stub function for handling that message.
typedef mig_routine_t (*mig_server_routine_t) (mach_msg_header_t *InHeadP)

typedefmig_impl_routine_t

Generic definition for implementation routines. These routines do the real work associated with this request. This generic type is used for keeping the pointers in the subsystem array.
typedef kern_return_t (*mig_impl_routine_t)(void)

typedefroutine_arg_descriptor

typedef mach_msg_type_descriptor_t routine_arg_descriptor

typedefroutine_arg_descriptor_t

typedef mach_msg_type_descriptor_t *routine_arg_descriptor_t

typedefmig_routine_arg_descriptor_t

typedef mach_msg_type_descriptor_t *mig_routine_arg_descriptor_t

macroMIG_ROUTINE_ARG_DESCRIPTOR_NULL

#define MIG_ROUTINE_ARG_DESCRIPTOR_NULL ((mig_routine_arg_descriptor_t)0)

structroutine_descriptor

size 40, align 8
mig_impl_routine_timpl_routineServer work func pointer
mig_stub_routine_tstub_routineUnmarshalling func pointer
unsigned intargcNumber of argument words
unsigned intdescr_countNumber complex descriptors
routine_arg_descriptor_targ_descrpointer to descriptor array
unsigned intmax_reply_msgMax size for reply msg

typedefroutine_descriptor_t

typedef struct routine_descriptor *routine_descriptor_t

typedefmig_routine_descriptor

typedef struct routine_descriptor mig_routine_descriptor

typedefmig_routine_descriptor_t

typedef mig_routine_descriptor *mig_routine_descriptor_t

macroMIG_ROUTINE_DESCRIPTOR_NULL

#define MIG_ROUTINE_DESCRIPTOR_NULL ((mig_routine_descriptor_t)0)

structmig_subsystem

size 72, align 8
mig_server_routine_tserverpointer to demux routine
mach_msg_id_tstartMin routine number
mach_msg_id_tendMax routine number + 1
mach_msg_size_tmaxsizeMax reply message size
vm_address_treservedreserved for MIG use
mig_routine_descriptor[1]routineRoutine descriptor array

typedefmig_subsystem_t

typedef struct mig_subsystem * mig_subsystem_t;

macroMIG_SUBSYSTEM_NULL

#define MIG_SUBSYSTEM_NULL ((mig_subsystem_t)0)

structmig_symtab

size 24, align 8
char *ms_routine_name
intms_routine_number
void (*)(void)ms_routineSince the functions in the symbol table have unknown signatures, this is the best we can do...

typedefmig_symtab_t

typedef struct mig_symtab mig_symtab_t;

macroMIG_SERVER_ROUTINE

A compiler attribute for annotating all MIG server routines and other functions that should behave similarly. Allows the compiler to perform additional static bug-finding over them.
#define MIG_SERVER_ROUTINE __attribute__((mig_server_routine))

functionmig_get_reply_port

extern mach_port_t mig_get_reply_port(void)
Client side reply port allocate

functionmig_dealloc_reply_port

extern void mig_dealloc_reply_port(mach_port_t reply_port)
Client side reply port deallocate

functionmig_put_reply_port

extern void mig_put_reply_port(mach_port_t reply_port)
Client side reply port "deallocation"

functionmig_strncpy

extern int mig_strncpy(char *dest, const char *src, int len)
Bounded string copy

functionmig_strncpy_zerofill

extern int mig_strncpy_zerofill(char *dest, const char *src, int len)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu libsyscall/mach/mig_strncpy.c
Bounded string copy, a variant of mig_strncpy used by MIG-generated stubs. Copies the null-terminated string src into dest, a buffer of len bytes, guaranteeing null termination and truncating if necessary; unlike mig_strncpy, any bytes of dest remaining after the terminator are zero-filled. Returns the number of bytes copied including the trailing null, or 0 if len is nonpositive or dest is null. A null src yields a fully zeroed buffer and a return of 0. Declared weak_import in some headers so callers can test for its presence at run time.

functionmig_allocate

extern void mig_allocate(vm_address_t *, vm_size_t)
Allocate memory for out-of-line mig structures

functionmig_deallocate

extern void mig_deallocate(vm_address_t, vm_size_t)
Deallocate memory used for out-of-line mig structures