#include <libkern/OSByteOrder.h>

libkern/OSByteOrder.h

includes: sys/_types.h, libkern/arm/_OSByteOrder.h, stdint.h, libkern/_OSByteOrder.h, libkern/arm/OSByteOrder.h
50 macros · 7 functions · 1 enum

macroOSSwapConstInt16

Macros for swapping constant values in the preprocessing stage.
#define OSSwapConstInt16(x) __DARWIN_OSSwapConstInt16(x)

macroOSSwapConstInt32

#define OSSwapConstInt32(x) __DARWIN_OSSwapConstInt32(x)

macroOSSwapConstInt64

#define OSSwapConstInt64(x) __DARWIN_OSSwapConstInt64(x)

macroOSSwapInt16

#define OSSwapInt16(x) __DARWIN_OSSwapInt16(x)

macroOSSwapInt32

#define OSSwapInt32(x) __DARWIN_OSSwapInt32(x)

macroOSSwapInt64

#define OSSwapInt64(x) __DARWIN_OSSwapInt64(x)

enum(anonymous)

underlying type unsigned int
OSUnknownByteOrder0
OSLittleEndian1
OSBigEndian2

functionOSHostByteOrder

__DARWIN_OS_INLINE
int32_t OSHostByteOrder(void)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu libkern/libkern/OSByteOrder.h
Returns the byte order of the host: OSLittleEndian on little-endian machines, OSBigEndian on big-endian machines, OSUnknownByteOrder otherwise. All current Darwin targets are little-endian. Evaluated at compile time; useful for code shared with byte-order-dependent formats.

macroOSReadBigInt

#define OSReadBigInt(x, y) OSReadBigInt32(x, y)

macroOSWriteBigInt

#define OSWriteBigInt(x, y, z) OSWriteBigInt32(x, y, z)

macroOSSwapBigToHostInt

#define OSSwapBigToHostInt(x) OSSwapBigToHostInt32(x)

macroOSSwapHostToBigInt

#define OSSwapHostToBigInt(x) OSSwapHostToBigInt32(x)

macroOSReadLittleInt

#define OSReadLittleInt(x, y) OSReadLittleInt32(x, y)

macroOSWriteLittleInt

#define OSWriteLittleInt(x, y, z) OSWriteLittleInt32(x, y, z)

macroOSSwapHostToLittleInt

#define OSSwapHostToLittleInt(x) OSSwapHostToLittleInt32(x)

macroOSSwapLittleToHostInt

#define OSSwapLittleToHostInt(x) OSSwapLittleToHostInt32(x)

function_OSReadInt16

__DARWIN_OS_INLINE
uint16_t _OSReadInt16(const volatile void * base, uintptr_t byteOffset)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu libkern/libkern/OSByteOrder.h
Returns the 16-bit integer at address base + byteOffset in native (host) byte order, read through a volatile pointer. Underlying primitive of the OSReadLittleInt16/OSReadBigInt16 macros on the matching-endian side; no byte swap is performed.

function_OSReadInt32

__DARWIN_OS_INLINE
uint32_t _OSReadInt32(const volatile void * base, uintptr_t byteOffset)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu libkern/libkern/OSByteOrder.h
Returns the 32-bit integer at address base + byteOffset in native (host) byte order, read through a volatile pointer. Underlying primitive of the OSReadLittleInt32/OSReadBigInt32 macros on the matching-endian side; no byte swap is performed.

function_OSReadInt64

__DARWIN_OS_INLINE
uint64_t _OSReadInt64(const volatile void * base, uintptr_t byteOffset)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu libkern/libkern/OSByteOrder.h
Returns the 64-bit integer at address base + byteOffset in native (host) byte order, read through a volatile pointer. Underlying primitive of the OSReadLittleInt64/OSReadBigInt64 macros on the matching-endian side; no byte swap is performed.

function_OSWriteInt16

__DARWIN_OS_INLINE
void _OSWriteInt16(volatile void * base, uintptr_t byteOffset, uint16_t data)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu libkern/libkern/OSByteOrder.h
Stores the 16-bit value data at address base + byteOffset in native (host) byte order, through a volatile pointer. Underlying primitive of the OSWriteLittleInt16/OSWriteBigInt16 macros on the matching-endian side; no byte swap is performed.

function_OSWriteInt32

__DARWIN_OS_INLINE
void _OSWriteInt32(volatile void * base, uintptr_t byteOffset, uint32_t data)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu libkern/libkern/OSByteOrder.h
Stores the 32-bit value data at address base + byteOffset in native (host) byte order, through a volatile pointer. Underlying primitive of the OSWriteLittleInt32/OSWriteBigInt32 macros on the matching-endian side; no byte swap is performed.

function_OSWriteInt64

__DARWIN_OS_INLINE
void _OSWriteInt64(volatile void * base, uintptr_t byteOffset, uint64_t data)
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu libkern/libkern/OSByteOrder.h
Stores the 64-bit value data at address base + byteOffset in native (host) byte order, through a volatile pointer. Underlying primitive of the OSWriteLittleInt64/OSWriteBigInt64 macros on the matching-endian side; no byte swap is performed.

macroOSReadBigInt16

#define OSReadBigInt16(base, byteOffset) OSReadSwapInt16(base, byteOffset)

macroOSReadBigInt32

#define OSReadBigInt32(base, byteOffset) OSReadSwapInt32(base, byteOffset)

macroOSReadBigInt64

#define OSReadBigInt64(base, byteOffset) OSReadSwapInt64(base, byteOffset)

macroOSWriteBigInt16

#define OSWriteBigInt16(base, byteOffset, data) OSWriteSwapInt16(base, byteOffset, data)

macroOSWriteBigInt32

#define OSWriteBigInt32(base, byteOffset, data) OSWriteSwapInt32(base, byteOffset, data)

macroOSWriteBigInt64

#define OSWriteBigInt64(base, byteOffset, data) OSWriteSwapInt64(base, byteOffset, data)

macroOSReadLittleInt16

#define OSReadLittleInt16(base, byteOffset) _OSReadInt16(base, byteOffset)

macroOSReadLittleInt32

#define OSReadLittleInt32(base, byteOffset) _OSReadInt32(base, byteOffset)

macroOSReadLittleInt64

#define OSReadLittleInt64(base, byteOffset) _OSReadInt64(base, byteOffset)

macroOSWriteLittleInt16

#define OSWriteLittleInt16(base, byteOffset, data) _OSWriteInt16(base, byteOffset, data)

macroOSWriteLittleInt32

#define OSWriteLittleInt32(base, byteOffset, data) _OSWriteInt32(base, byteOffset, data)

macroOSWriteLittleInt64

#define OSWriteLittleInt64(base, byteOffset, data) _OSWriteInt64(base, byteOffset, data)

macroOSSwapHostToBigConstInt16

#define OSSwapHostToBigConstInt16(x) OSSwapConstInt16(x)

macroOSSwapHostToBigConstInt32

#define OSSwapHostToBigConstInt32(x) OSSwapConstInt32(x)

macroOSSwapHostToBigConstInt64

#define OSSwapHostToBigConstInt64(x) OSSwapConstInt64(x)

macroOSSwapHostToBigInt16

#define OSSwapHostToBigInt16(x) OSSwapInt16(x)

macroOSSwapHostToBigInt32

#define OSSwapHostToBigInt32(x) OSSwapInt32(x)

macroOSSwapHostToBigInt64

#define OSSwapHostToBigInt64(x) OSSwapInt64(x)

macroOSSwapHostToLittleConstInt16

#define OSSwapHostToLittleConstInt16(x) ((uint16_t)(x))

macroOSSwapHostToLittleConstInt32

#define OSSwapHostToLittleConstInt32(x) ((uint32_t)(x))

macroOSSwapHostToLittleConstInt64

#define OSSwapHostToLittleConstInt64(x) ((uint64_t)(x))

macroOSSwapHostToLittleInt16

#define OSSwapHostToLittleInt16(x) ((uint16_t)(x))

macroOSSwapHostToLittleInt32

#define OSSwapHostToLittleInt32(x) ((uint32_t)(x))

macroOSSwapHostToLittleInt64

#define OSSwapHostToLittleInt64(x) ((uint64_t)(x))

macroOSSwapBigToHostConstInt16

#define OSSwapBigToHostConstInt16(x) OSSwapConstInt16(x)

macroOSSwapBigToHostConstInt32

#define OSSwapBigToHostConstInt32(x) OSSwapConstInt32(x)

macroOSSwapBigToHostConstInt64

#define OSSwapBigToHostConstInt64(x) OSSwapConstInt64(x)

macroOSSwapBigToHostInt16

#define OSSwapBigToHostInt16(x) OSSwapInt16(x)

macroOSSwapBigToHostInt32

#define OSSwapBigToHostInt32(x) OSSwapInt32(x)

macroOSSwapBigToHostInt64

#define OSSwapBigToHostInt64(x) OSSwapInt64(x)

macroOSSwapLittleToHostConstInt16

#define OSSwapLittleToHostConstInt16(x) ((uint16_t)(x))

macroOSSwapLittleToHostConstInt32

#define OSSwapLittleToHostConstInt32(x) ((uint32_t)(x))

macroOSSwapLittleToHostConstInt64

#define OSSwapLittleToHostConstInt64(x) ((uint64_t)(x))

macroOSSwapLittleToHostInt16

#define OSSwapLittleToHostInt16(x) ((uint16_t)(x))

macroOSSwapLittleToHostInt32

#define OSSwapLittleToHostInt32(x) ((uint32_t)(x))

macroOSSwapLittleToHostInt64

#define OSSwapLittleToHostInt64(x) ((uint64_t)(x))