apfelkern

C API documentation extracted from the local macOS SDK headers (arm64, userspace and kernel configurations).

Why make this? Well, have you tried reading the official Apple documentation? To give you an example, try to figure out what mach_vm_map does.

If we look at the header files (no it's not in /usr/include) it turns out that they contain a lot of useful information that their documentation generation system ignores.

If you want me to add more components (Frameworks, XNU kernel parts), feel free to message me.

Guides

Mach

The Mach microkernel interface: tasks, threads, ports, messages, virtual memory, exceptions.

Tasks & threads

Ports & messages

Virtual memory

Host & processors

Exceptions

Vouchers & misc

Architecture

BSD / POSIX

The BSD layer and POSIX system interface: files, processes, signals, sockets, memory, terminals, sysctl, and friends.

Types & conventions

_types.herrno.hinttypes.hlimits.hstdint.hsys/__endian.hsys/_endian.hsys/_select.hsys/_types.hsys/_types/_blkcnt_t.hsys/_types/_blksize_t.hsys/_types/_caddr_t.hsys/_types/_clock_t.hsys/_types/_ct_rune_t.hsys/_types/_dev_t.hsys/_types/_errno_t.hsys/_types/_fd_clr.hsys/_types/_fd_copy.hsys/_types/_fd_def.hsys/_types/_fd_isset.hsys/_types/_fd_set.hsys/_types/_fd_setsize.hsys/_types/_fd_zero.hsys/_types/_filesec_t.hsys/_types/_fsblkcnt_t.hsys/_types/_fsfilcnt_t.hsys/_types/_fsid_t.hsys/_types/_fsobj_id_t.hsys/_types/_gid_t.hsys/_types/_graftdmg_un.hsys/_types/_guid_t.hsys/_types/_id_t.hsys/_types/_in_addr_t.hsys/_types/_in_port_t.hsys/_types/_ino64_t.hsys/_types/_ino_t.hsys/_types/_int16_t.hsys/_types/_int32_t.hsys/_types/_int64_t.hsys/_types/_int8_t.hsys/_types/_intptr_t.hsys/_types/_iovec_t.hsys/_types/_key_t.hsys/_types/_mach_port_t.hsys/_types/_mbstate_t.hsys/_types/_mode_t.hsys/_types/_mount_t.hsys/_types/_nlink_t.hsys/_types/_null.hsys/_types/_o_dsync.hsys/_types/_o_sync.hsys/_types/_off_t.hsys/_types/_offsetof.hsys/_types/_os_inline.hsys/_types/_pid_t.hsys/_types/_posix_vdisable.hsys/_types/_ptrdiff_t.hsys/_types/_rsize_t.hsys/_types/_rune_t.hsys/_types/_s_ifmt.hsys/_types/_sa_family_t.hsys/_types/_seek_set.hsys/_types/_sigaltstack.hsys/_types/_sigset_t.hsys/_types/_size_t.hsys/_types/_socklen_t.hsys/_types/_ssize_t.hsys/_types/_suseconds_t.hsys/_types/_time_t.hsys/_types/_timespec.hsys/_types/_timeval.hsys/_types/_timeval32.hsys/_types/_timeval64.hsys/_types/_u_char.hsys/_types/_u_int.hsys/_types/_u_int16_t.hsys/_types/_u_int32_t.hsys/_types/_u_int64_t.hsys/_types/_u_int8_t.hsys/_types/_u_short.hsys/_types/_ucontext.hsys/_types/_ucontext64.hsys/_types/_uid_t.hsys/_types/_uintptr_t.hsys/_types/_useconds_t.hsys/_types/_uuid_t.hsys/_types/_va_list.hsys/_types/_vnode_t.hsys/_types/_wchar_t.hsys/_types/_wint_t.hsys/cdefs.hsys/endian.hsys/errno.hsys/param.hsys/syslimits.hsys/types.hsysexits.h

Threads & scheduling

Memory & IPC

Strings & text

Atomics, byte order & libkern

Data structures

Events & kqueue

Files & directories

Processes & signals

Networking

Time

Terminals

Audit (BSM)

Tracing & debugging

Misc

Kernel (KEXT)

The in-kernel API from Kernel.framework, as seen by kernel extensions: kern/ primitives, kernel-side sys/ and mach/, BSD KPIs, libkern, and the C surface of IOKit. Compiled with KERNEL defined, arm64. C++ classes (IOKit/libkern C++) are not yet extracted.

kern/ primitives

Mach (kernel)

BSD (kernel)

miscfs/devfs/devfs.hmiscfs/fifofs/fifo.hmiscfs/specfs/specdev.hmiscfs/union/union.hsys/__endian.hsys/_endian.hsys/_structs.hsys/_types.hsys/_types/_caddr_t.hsys/_types/_fd_def.hsys/_types/_null.hsys/_types/_offsetof.hsys/_types/_ptrdiff_t.hsys/_types/_rsize_t.hsys/_types/_size_t.hsys/_types/_uintptr_t.hsys/_types/_user32_itimerval.hsys/_types/_user32_ntptimeval.hsys/_types/_user32_timespec.hsys/_types/_user32_timeval.hsys/_types/_user32_timex.hsys/_types/_user64_itimerval.hsys/_types/_user64_ntptimeval.hsys/_types/_user64_timespec.hsys/_types/_user64_timeval.hsys/_types/_user64_timex.hsys/_types/_user_timespec.hsys/_types/_user_timeval.hsys/_types/_va_list.hsys/_types/_wchar_t.hsys/appleapiopts.hsys/attr.hsys/cdefs.hsys/commpage.hsys/conf.hsys/constrained_ctypes.hsys/dir.hsys/dirent.hsys/disk.hsys/dkstat.hsys/domain.hsys/errno.hsys/ev.hsys/event.hsys/fcntl.hsys/file.hsys/imgact.hsys/ioctl.hsys/ipc.hsys/kauth.hsys/kdebug.hsys/kdebug_kernel.hsys/kdebug_private.hsys/kern_control.hsys/kern_event.hsys/kernel.hsys/kernel_types.hsys/kpi_mbuf.hsys/kpi_socket.hsys/kpi_socketfilter.hsys/lock.hsys/malloc.hsys/mbuf.hsys/md5.hsys/mman.hsys/mount.hsys/msg.hsys/namei.hsys/param.hsys/proc.hsys/random.hsys/resource.hsys/resource_private.hsys/select.hsys/sem.hsys/shm.hsys/signal.hsys/socket.hsys/socketvar.hsys/sockio.hsys/stat.hsys/stdio.hsys/sysctl.hsys/syslog.hsys/systm.hsys/time.hsys/timex.hsys/ttycom.hsys/types.hsys/ubc.hsys/ucontext.hsys/ucred.hsys/uio.hsys/un.hsys/unicode.hsys/unistd.hsys/utfconv.hsys/vm.hsys/vmparam.hsys/vnode.hsys/vnode_if.hsys/wait.hsys/xattr.huuid/uuid.hvfs/vfs_support.h

Networking KPIs

libkern & os

IOKit

IOKit/AppleBasebandBridgeKeys.hIOKit/IOBSD.hIOKit/IOBufferMemoryDescriptor.hIOKit/IOCatalogue.hIOKit/IOCircularDataQueue.hIOKit/IOCircularDataQueueImplementation.hIOKit/IOCommand.hIOKit/IOCommandGate.hIOKit/IOCommandPool.hIOKit/IOConditionLock.hIOKit/IODMACommand.hIOKit/IODMAController.hIOKit/IODMAEventSource.hIOKit/IODataQueue.hIOKit/IODataQueueShared.hIOKit/IODeviceMemory.hIOKit/IODeviceTreeSupport.hIOKit/IOEventSource.hIOKit/IOFilterInterruptEventSource.hIOKit/IOGuardPageMemoryDescriptor.hIOKit/IOInterleavedMemoryDescriptor.hIOKit/IOInterruptController.hIOKit/IOInterruptEventSource.hIOKit/IOInterrupts.hIOKit/IOKernelReportStructs.hIOKit/IOKitDebug.hIOKit/IOKitKeys.hIOKit/IOKitServer.hIOKit/IOLib.hIOKit/IOLocks.hIOKit/IOMapTypes.hIOKit/IOMapper.hIOKit/IOMemoryCursor.hIOKit/IOMemoryDescriptor.hIOKit/IOMessage.hIOKit/IOMultiMemoryDescriptor.hIOKit/IONVRAM.hIOKit/IONotifier.hIOKit/IOPlatformExpert.hIOKit/IOProviderPropertyMerger.hIOKit/IORPC.hIOKit/IORangeAllocator.hIOKit/IORegistryEntry.hIOKit/IOReportMacros.hIOKit/IOReportTypes.hIOKit/IOReturn.hIOKit/IOService.hIOKit/IOServicePM.hIOKit/IOServiceStateNotificationEventSource.hIOKit/IOSharedDataQueue.hIOKit/IOSharedLock.hIOKit/IOSubMemoryDescriptor.hIOKit/IOTimeStamp.hIOKit/IOTimerEventSource.hIOKit/IOTypes.hIOKit/IOUserClient.hIOKit/IOUserServer.hIOKit/IOWorkLoop.hIOKit/OSMessageNotification.hIOKit/PassthruInterruptController.hIOKit/acpi/IOACPIPlatformDevice.hIOKit/acpi/IOACPIPlatformExpert.hIOKit/acpi/IOACPITypes.hIOKit/assert.hIOKit/ata/ATADeviceNub.hIOKit/ata/ATATimerEventSource.hIOKit/ata/IOATABusCommand.hIOKit/ata/IOATABusInfo.hIOKit/ata/IOATACommand.hIOKit/ata/IOATAController.hIOKit/ata/IOATADevConfig.hIOKit/ata/IOATADevice.hIOKit/ata/IOATATypes.hIOKit/ata/IOPCIATA.hIOKit/audio/BigNum128.hIOKit/audio/IOAudioBlitterLibDispatch.hIOKit/audio/IOAudioControl.hIOKit/audio/IOAudioControlUserClient.hIOKit/audio/IOAudioDebug.hIOKit/audio/IOAudioDefines.hIOKit/audio/IOAudioDevice.hIOKit/audio/IOAudioEngine.hIOKit/audio/IOAudioEngineUserClient.hIOKit/audio/IOAudioLevelControl.hIOKit/audio/IOAudioPort.hIOKit/audio/IOAudioSelectorControl.hIOKit/audio/IOAudioStream.hIOKit/audio/IOAudioTimeIntervalFilter.hIOKit/audio/IOAudioToggleControl.hIOKit/audio/IOAudioTypes.hIOKit/avc/IOFireWireAVCCommand.hIOKit/avc/IOFireWireAVCConsts.hIOKit/avc/IOFireWireAVCRequestSpace.hIOKit/avc/IOFireWireAVCTargetSpace.hIOKit/avc/IOFireWireAVCUnit.hIOKit/avc/IOFireWireAVCUserClientCommon.hIOKit/avc/IOFireWirePCRSpace.hIOKit/bluetooth/Bluetooth.hIOKit/bluetooth/BluetoothAssignedNumbers.hIOKit/bluetooth/IOBluetoothTypes.hIOKit/firewire/IOConfigDirectory.hIOKit/firewire/IOFWAddressSpace.hIOKit/firewire/IOFWCommand.hIOKit/firewire/IOFWDCL.hIOKit/firewire/IOFWDCLPool.hIOKit/firewire/IOFWDCLProgram.hIOKit/firewire/IOFWDCLTranslator.hIOKit/firewire/IOFWIsochChannel.hIOKit/firewire/IOFWIsochPort.hIOKit/firewire/IOFWLocalIsochPort.hIOKit/firewire/IOFWPHYPacketListener.hIOKit/firewire/IOFWPhysicalAddressSpace.hIOKit/firewire/IOFWPseudoAddressSpace.hIOKit/firewire/IOFWRegs.hIOKit/firewire/IOFWSimpleContiguousPhysicalAddressSpace.hIOKit/firewire/IOFWSimplePhysicalAddressSpace.hIOKit/firewire/IOFWSyncer.hIOKit/firewire/IOFWUserObjectExporter.hIOKit/firewire/IOFWUtils.hIOKit/firewire/IOFireWireBus.hIOKit/firewire/IOFireWireController.hIOKit/firewire/IOFireWireDevice.hIOKit/firewire/IOFireWireFamilyCommon.hIOKit/firewire/IOFireWireIRMAllocation.hIOKit/firewire/IOFireWireLocalNode.hIOKit/firewire/IOFireWireMultiIsochReceive.hIOKit/firewire/IOFireWireNub.hIOKit/firewire/IOFireWirePowerManager.hIOKit/firewire/IOFireWireUnit.hIOKit/firewire/IOLocalConfigDirectory.hIOKit/graphics/IOAccelClientConnect.hIOKit/graphics/IOAccelSurfaceConnect.hIOKit/graphics/IOAccelTypes.hIOKit/graphics/IOAccelerator.hIOKit/graphics/IODisplay.hIOKit/graphics/IOFramebuffer.hIOKit/graphics/IOFramebufferShared.hIOKit/graphics/IOGraphicsDevice.hIOKit/graphics/IOGraphicsEngine.hIOKit/graphics/IOGraphicsInterfaceTypes.hIOKit/graphics/IOGraphicsTypes.hIOKit/hidsystem/IOHIDDescriptorParser.hIOKit/hidsystem/IOHIDParameter.hIOKit/hidsystem/IOHIDShared.hIOKit/hidsystem/IOHIDSystem.hIOKit/hidsystem/IOHIDTypes.hIOKit/hidsystem/IOHIDUsageTables.hIOKit/hidsystem/IOHIDWorkLoop.hIOKit/hidsystem/IOHIDevice.hIOKit/hidsystem/IOHIKeyboard.hIOKit/hidsystem/IOHIKeyboardMapper.hIOKit/hidsystem/IOHIPointing.hIOKit/hidsystem/IOLLEvent.hIOKit/hidsystem/ev_keymap.hIOKit/i2c/IOI2CInterface.hIOKit/ndrvsupport/IOMacOSTypes.hIOKit/ndrvsupport/IOMacOSVideo.hIOKit/ndrvsupport/IONDRVFramebuffer.hIOKit/ndrvsupport/IONDRVLibraries.hIOKit/ndrvsupport/IONDRVSupport.hIOKit/network/IOBasicOutputQueue.hIOKit/network/IOEthernetController.hIOKit/network/IOEthernetInterface.hIOKit/network/IOEthernetStats.hIOKit/network/IOGatedOutputQueue.hIOKit/network/IOKernelDebugger.hIOKit/network/IOMbufMemoryCursor.hIOKit/network/IONetworkController.hIOKit/network/IONetworkData.hIOKit/network/IONetworkInterface.hIOKit/network/IONetworkMedium.hIOKit/network/IONetworkStats.hIOKit/network/IOOutputQueue.hIOKit/network/IOPacketQueue.hIOKit/nvram/IONVRAMController.hIOKit/pci/IOAGPDevice.hIOKit/pci/IOPCIBridge.hIOKit/pci/IOPCIDevice.hIOKit/pci/IOPCIFamilyDefinitions.hIOKit/platform/AppleMacIO.hIOKit/platform/AppleMacIODevice.hIOKit/platform/AppleNMI.hIOKit/platform/ApplePlatformExpert.hIOKit/platform/IOPlatformIO.hIOKit/power/IOPwrController.hIOKit/pwr_mgt/IOPM.hIOKit/pwr_mgt/IOPMLibDefs.hIOKit/pwr_mgt/IOPMPowerSource.hIOKit/pwr_mgt/IOPMPowerSourceList.hIOKit/pwr_mgt/IOPMpowerState.hIOKit/pwr_mgt/IOPowerConnection.hIOKit/pwr_mgt/RootDomain.hIOKit/rtc/IORTCController.hIOKit/sbp2/IOFireWireSBP2LSIWorkaroundDescriptor.hIOKit/sbp2/IOFireWireSBP2LUN.hIOKit/sbp2/IOFireWireSBP2Login.hIOKit/sbp2/IOFireWireSBP2ManagementORB.hIOKit/sbp2/IOFireWireSBP2ORB.hIOKit/sbp2/IOFireWireSBP2Target.hIOKit/sbp2/IOFireWireSBP2UserClient.hIOKit/sbp2/IOFireWireSBP2UserClientCommon.hIOKit/sbp2/IOFireWireSerialBusProtocolTransport.hIOKit/scsi/IOBDServices.hIOKit/scsi/IOBlockStorageServices.hIOKit/scsi/IOCompactDiscServices.hIOKit/scsi/IODVDServices.hIOKit/scsi/IOReducedBlockServices.hIOKit/scsi/IOSCSIBlockCommandsDevice.hIOKit/scsi/IOSCSIMultimediaCommandsDevice.hIOKit/scsi/IOSCSIPeripheralDeviceNub.hIOKit/scsi/IOSCSIPeripheralDeviceType00.hIOKit/scsi/IOSCSIPeripheralDeviceType05.hIOKit/scsi/IOSCSIPeripheralDeviceType07.hIOKit/scsi/IOSCSIPeripheralDeviceType0E.hIOKit/scsi/IOSCSIPrimaryCommandsDevice.hIOKit/scsi/IOSCSIProtocolInterface.hIOKit/scsi/IOSCSIProtocolServices.hIOKit/scsi/IOSCSIReducedBlockCommandsDevice.hIOKit/scsi/SCSICmds_INQUIRY_Definitions.hIOKit/scsi/SCSICmds_MODE_Definitions.hIOKit/scsi/SCSICmds_READ_CAPACITY_Definitions.hIOKit/scsi/SCSICmds_REPORT_LUNS_Definitions.hIOKit/scsi/SCSICmds_REQUEST_SENSE_Defs.hIOKit/scsi/SCSICommandDefinitions.hIOKit/scsi/SCSICommandOperationCodes.hIOKit/scsi/SCSIPort.hIOKit/scsi/SCSITask.hIOKit/scsi/spi/IOSCSIParallelControllerCharacteristics.hIOKit/scsi/spi/IOSCSIParallelInterfaceController.hIOKit/storage/IOAppleLabelScheme.hIOKit/storage/IOApplePartitionScheme.hIOKit/storage/IOBDBlockStorageDevice.hIOKit/storage/IOBDBlockStorageDriver.hIOKit/storage/IOBDMedia.hIOKit/storage/IOBDMediaBSDClient.hIOKit/storage/IOBDTypes.hIOKit/storage/IOBlockStorageDevice.hIOKit/storage/IOBlockStorageDriver.hIOKit/storage/IOCDBlockStorageDevice.hIOKit/storage/IOCDBlockStorageDriver.hIOKit/storage/IOCDMedia.hIOKit/storage/IOCDMediaBSDClient.hIOKit/storage/IOCDPartitionScheme.hIOKit/storage/IOCDTypes.hIOKit/storage/IODVDBlockStorageDevice.hIOKit/storage/IODVDBlockStorageDriver.hIOKit/storage/IODVDMedia.hIOKit/storage/IODVDMediaBSDClient.hIOKit/storage/IODVDTypes.hIOKit/storage/IOFDiskPartitionScheme.hIOKit/storage/IOFilterScheme.hIOKit/storage/IOFireWireStorageCharacteristics.hIOKit/storage/IOGUIDPartitionScheme.hIOKit/storage/IOMedia.hIOKit/storage/IOMediaBSDClient.hIOKit/storage/IOPartitionScheme.hIOKit/storage/IOStorage.hIOKit/storage/IOStorageCardCharacteristics.hIOKit/storage/IOStorageControllerCharacteristics.hIOKit/storage/IOStorageDeviceCharacteristics.hIOKit/storage/IOStorageProtocolCharacteristics.hIOKit/storage/ata/IOATAPIProtocolTransport.hIOKit/storage/ata/IOATAStorageDefines.hIOKit/stream/IOStream.hIOKit/stream/IOStreamFamily.hIOKit/stream/IOStreamShared.hIOKit/stream/IOStreamUserClient.hIOKit/system.hIOKit/system_management/IOWatchDogTimer.hIOKit/usb/AppleUSBDefinitions.hIOKit/usb/IOUSBHostControllerInterfaceDefinitions.hIOKit/usb/IOUSBHostControllerInterfaceHelpers.hIOKit/usb/IOUSBHostDevice.hIOKit/usb/IOUSBHostFamily.hIOKit/usb/IOUSBHostFamilyDefinitions.hIOKit/usb/IOUSBHostIOSource.hIOKit/usb/IOUSBHostInterface.hIOKit/usb/IOUSBHostPipe.hIOKit/usb/IOUSBHostStream.hIOKit/usb/StandardUSB.hIOKit/usb/USB.hIOKit/usb/USBSpec.hIOKit/video/IOVideoControlDictionary.hIOKit/video/IOVideoDevice.hIOKit/video/IOVideoDeviceClientInit.hIOKit/video/IOVideoDeviceShared.hIOKit/video/IOVideoDeviceUserClient.hIOKit/video/IOVideoStream.hIOKit/video/IOVideoStreamDictionary.hIOKit/video/IOVideoStreamFormatDictionary.hIOKit/video/IOVideoTypes.h

VM & pexpert

Architecture

Mach-O

The Mach-O object file format (load commands, symbol tables, fat binaries, chained fixups) and the dyld runtime interface.

File format

Runtime & dyld

Architecture

XPC

The C XPC API: typed serializable objects, connections, listeners, sessions, and activities.

Hypervisor

Hypervisor.framework: the arm64 virtualization C API — VMs, vCPUs, the GIC, and guest memory.

Dispatch

libdispatch (Grand Central Dispatch): queues, groups, sources, semaphores, workloops, dispatch I/O and data objects.

os/

The os/ userspace primitives: unified logging and signposts, unfair locks, workgroups, clocks, atomics and overflow-checked arithmetic.

EndpointSecurity

The EndpointSecurity C API: subscribing to and authorizing security-relevant kernel events (exec, open, signals, mounts, ...).

CommonCrypto

CommonCrypto: digests, HMAC, symmetric ciphers, key derivation, random bytes and key wrapping.

About & caveats

apfelkern hosts C API documentation generated from the macOS SDK headers installed on my own machine. It is not affiliated with, endorsed by, or reviewed by Apple.

Build environment:

macOS26.4.1
SDK26.4 (MacOSX.sdk, Command Line Tools)
architecturearm64; Intel-only headers and preprocessor branches are excluded
configurationuserspace corpora: default userspace preprocessor context; Kernel (KEXT) corpus: -DKERNEL
compilerApple clang version 21.0.0 (clang-2100.0.123.102)
xnu source used for verificationapple-oss-distributions/xnu @ f6217f8 (2025-10-16)
generated2026-09-08

Unless specified otherwise, descriptions are extracted from macOS header comments, MIG .defs files and SDK man pages.

CMU/MIT Mach reference: Where applicable, description and notes from the Carnegie Mellon Mach kernel (CMU Mach) interface manual pages (fetched from <web.mit.edu/darwin/src/modules>) are supplied. This data is licensed under the free-use license (© Carnegie Mellon University) and may not apply to XNU.

GNU Mach reference: Where applicable, description and notes from the GNU Mach Reference Manual (fetched from http://gnu.org/software/hurd/gnumach-doc/) are supplied. This data is licensed under the GNU Free Documentation License 1.2+ (© Free Software Foundation) and may not apply to XNU.

LLVM project source: Selected LLDB debugserver source files (https://github.com/llvm/llvm-project). Licensed under the Apache License v2.0 with LLVM Exceptions.

Generated descriptions: Functions with no documentation in any of these sources have an LLM-generated description shown below them showing the XNU source files consulted. These descriptions are unreviewed and may contain errors.

Build diagnostics — 33 error / 3 warning lines from the last build (mostly SDK headers that don't compile standalone; skipped).