|
OSByteOrder.h |
Includes: |
<stdint.h> <libkern/_OSByteOrder.h> <libkern/ppc/OSByteOrder.h> <libkern/i386/OSByteOrder.h> <libkern/arm/OSByteOrder.h> <libkern/machine/OSByteOrder.h> <libkern/machine/OSByteOrder.h> |
This header provides functions and mmacros for byte swapping between little endian or big endian and host byte order.
For the kernel-space version of this header, see
OSByteOrder.h (Kernel Framework)
Reads a 16-bit big-endian integer.
Reads a 32-bit big-endian integer.
Reads a 64-bit big-endian integer.
Writes a 16-bit big-endian integer.
Writes a 32-bit big-endian integer.
Writes a 64-bit big-endian integer.
Returns the byte order of the host.
_OSReadInt16 |
Reads a 16-bit big-endian integer.
OS_INLINE uint16_t _OSReadInt16( const volatile void * base, uintptr_t byteOffset )
base
An address at or below the address of the integer to be read.
byteOffset
The offset from base
(in bytes)
of the start of the integer to be read.
_OSReadInt32 |
Reads a 32-bit big-endian integer.
OS_INLINE uint32_t _OSReadInt32( const volatile void * base, uintptr_t byteOffset )
base
An address at or below the address of the integer to be read.
byteOffset
The offset from base
(in bytes)
of the start of the integer to be read.
_OSReadInt64 |
Reads a 64-bit big-endian integer.
OS_INLINE uint64_t _OSReadInt64( const volatile void * base, uintptr_t byteOffset )
base
An address at or below the address of the integer to be read.
byteOffset
The offset from base
(in bytes)
of the start of the integer to be read.
_OSWriteInt16 |
Writes a 16-bit big-endian integer.
OS_INLINE void _OSWriteInt16( volatile void *base, uintptr_t byteOffset, uint16_t data )
base
An address at or below the address of the integer to be written.
byteOffset
The offset from base
(in bytes)
of the start of the integer to be written.
data
The value to write (in host byte order).
_OSWriteInt32 |
Writes a 32-bit big-endian integer.
OS_INLINE void _OSWriteInt32( volatile void *base, uintptr_t byteOffset, uint32_t data )
base
An address at or below the address of the integer to be written.
byteOffset
The offset from base
(in bytes)
of the start of the integer to be written.
data
The value to write (in host byte order).
_OSWriteInt64 |
Writes a 64-bit big-endian integer.
OS_INLINE void _OSWriteInt64( volatile void *base, uintptr_t byteOffset, uint64_t data )
base
An address at or below the address of the integer to be written.
byteOffset
The offset from base
(in bytes)
of the start of the integer to be written.
data
The value to write (in host byte order).
OSHostByteOrder |
Returns the byte order of the host.
OS_INLINE int32_t OSHostByteOrder( void)
Returns one of the constants defined by
Byte order constants
.
Byte order constants.
Byte order constants |
Byte order constants.
enum { OSUnknownByteOrder, OSLittleEndian, OSBigEndian };
These constants are returned by OSHostByteOrder
.
Reads a 32-bit big-endian integer.
Reads a 16-bit big endian integer and swaps to host byte order.
Reads a 32-bit big endian integer and swaps to host byte order.
Reads a 64-bit big endian integer and swaps to host byte order.
Reads a 32-bit little-endian integer.
Reads a 16-bit little endian integer and swaps to host byte order.
Reads a 32-bit little endian integer and swaps to host byte order.
Reads a 64-bit little endian integer and swaps to host byte order.
Converts a 16-bit big endian constant to host byte order.
Converts a 32-bit big endian constant to host byte order.
Converts a 64-bit big endian constant to host byte order.
Swaps a 32-bit integer from big endian to host byte order.
Converts a 16-bit big endian integer to host byte order.
Converts a 32-bit big endian integer to host byte order.
Converts a 64-bit big endian integer to host byte order.
Byte swaps a 16-bit constant.
Byte swaps a 32-bit constant.
Byte swaps a 64-bit constant.
Converts a 16-bit host endian constant to big endian.
Converts a 32-bit host endian constant to big endian.
Converts a 64-bit host endian constant to big endian.
Swaps a 32-bit integer from host byte order to big endian.
Converts a 16-bit host endian integer to big endian.
Converts a 32-bit host endian integer to big endian.
Converts a 64-bit host endian integer to big endian.
Converts a 16-bit host endian constant to little endian.
Converts a 32-bit host endian constant to little endian.
Converts a 64-bit host endian constant to little endian.
Swaps a 32-bit integer from host byte order to little endian.
Converts a 16-bit host endian integer to little endian.
Converts a 32-bit host endian integer to little endian.
Converts a 64-bit host endian integer to little endian.
Converts a 16-bit little endian constant to host byte order.
Converts a 32-bit little endian constant to host byte order.
Converts a 64-bit little endian constant to host byte order.
Swaps a 32-bit integer from little endian to host byte order.
Converts a 16-bit little endian integer to host byte order.
Converts a 32-bit little endian integer to host byte order.
Converts a 64-bit little endian integer to host byte order.
Writes a 32-bit big-endian integer.
Writes a 16-bit big endian integer and swaps from host byte order.
Writes a 32-bit big endian integer and swaps from host byte order.
Writes a 64-bit big endian integer and swaps from host byte order.
Writes a 32-bit little-endian integer.
Writes a 16-bit little endian integer and swaps from host byte order.
Writes a 32-bit little endian integer and swaps from host byte order.
Writes a 64-bit little endian integer and swaps from host byte order.
OSReadBigInt |
Reads a 32-bit big-endian integer.
#define OSReadBigInt(x, y) OSReadBigInt32(x, y)
See documentation for OSReadBigInt32
.
OSReadBigInt16 |
Reads a 16-bit big endian integer and swaps to host byte order.
#define OSReadBigInt16(base, byteOffset) OSReadSwapInt16(base, byteOffset)
base
An address at or below the address of the integer to be read.
byteOffset
The offset from base
(in bytes)
of the start of the integer to be read.
OSReadBigInt32 |
Reads a 32-bit big endian integer and swaps to host byte order.
#define OSReadBigInt32(base, byteOffset) OSReadSwapInt32(base, byteOffset)
base
An address at or below the address of the integer to be read.
byteOffset
The offset from base
(in bytes)
of the start of the integer to be read.
OSReadBigInt64 |
Reads a 64-bit big endian integer and swaps to host byte order.
#define OSReadBigInt64(base, byteOffset) OSReadSwapInt64(base, byteOffset)
base
An address at or below the address of the integer to be read.
byteOffset
The offset from base
(in bytes)
of the start of the integer to be read.
OSReadLittleInt |
Reads a 32-bit little-endian integer.
#define OSReadLittleInt(x, y) OSReadLittleInt32(x, y)
See documentation for OSReadLittleInt32
.
OSReadLittleInt16 |
Reads a 16-bit little endian integer and swaps to host byte order.
#define OSReadLittleInt16(base, byteOffset) _OSReadInt16(base, byteOffset)
base
An address at or below the address of the integer to be read.
byteOffset
The offset from base
(in bytes)
of the start of the integer to be read.
OSReadLittleInt32 |
Reads a 32-bit little endian integer and swaps to host byte order.
#define OSReadLittleInt32(base, byteOffset) _OSReadInt32(base, byteOffset)
base
An address at or below the address of the integer to be read.
byteOffset
The offset from base
(in bytes)
of the start of the integer to be read.
OSReadLittleInt64 |
Reads a 64-bit little endian integer and swaps to host byte order.
#define OSReadLittleInt64(base, byteOffset) _OSReadInt64(base, byteOffset)
base
An address at or below the address of the integer to be read.
byteOffset
The offset from base
(in bytes)
of the start of the integer to be read.
OSSwapBigToHostConstInt16 |
Converts a 16-bit big endian constant to host byte order.
#define OSSwapBigToHostConstInt16(x) __DARWIN_OSSwapConstInt16(x)
x
The constant to convert.
OSSwapBigToHostConstInt32 |
Converts a 32-bit big endian constant to host byte order.
#define OSSwapBigToHostConstInt32(x) __DARWIN_OSSwapConstInt32(x)
x
The constant to convert.
OSSwapBigToHostConstInt64 |
Converts a 64-bit big endian constant to host byte order.
#define OSSwapBigToHostConstInt64(x) __DARWIN_OSSwapConstInt64(x)
x
The constant to convert.
OSSwapBigToHostInt |
Swaps a 32-bit integer from big endian to host byte order.
#define OSSwapBigToHostInt(x) OSSwapBigToHostInt32(x)
See documentation for OSSwapBigToHostInt32
.
OSSwapBigToHostInt16 |
Converts a 16-bit big endian integer to host byte order.
#define OSSwapBigToHostInt16(x) OSSwapInt16(x)
x
The integer to convert.
OSSwapBigToHostInt32 |
Converts a 32-bit big endian integer to host byte order.
#define OSSwapBigToHostInt32(x) OSSwapInt32(x)
x
The integer to convert.
OSSwapBigToHostInt64 |
Converts a 64-bit big endian integer to host byte order.
#define OSSwapBigToHostInt64(x) OSSwapInt64(x)
x
The integer to convert.
OSSwapConstInt16 |
Byte swaps a 16-bit constant.
#define OSSwapConstInt16(x) __DARWIN_OSSwapConstInt16(x)
OSSwapConstInt32 |
Byte swaps a 32-bit constant.
#define OSSwapConstInt32(x) __DARWIN_OSSwapConstInt32(x)
OSSwapConstInt64 |
Byte swaps a 64-bit constant.
#define OSSwapConstInt64(x) __DARWIN_OSSwapConstInt64(x)
OSSwapHostToBigConstInt16 |
Converts a 16-bit host endian constant to big endian.
#define OSSwapHostToBigConstInt16(x) __DARWIN_OSSwapConstInt16(x)
x
The constant value to convert.
OSSwapHostToBigConstInt32 |
Converts a 32-bit host endian constant to big endian.
#define OSSwapHostToBigConstInt32(x) __DARWIN_OSSwapConstInt32(x)
x
The constant value to convert.
OSSwapHostToBigConstInt64 |
Converts a 64-bit host endian constant to big endian.
#define OSSwapHostToBigConstInt64(x) __DARWIN_OSSwapConstInt64(x)
x
The constant value to convert.
OSSwapHostToBigInt |
Swaps a 32-bit integer from host byte order to big endian.
#define OSSwapHostToBigInt(x) OSSwapHostToBigInt32(x)
See documentation for OSSwapHostToBigInt32
.
OSSwapHostToBigInt16 |
Converts a 16-bit host endian integer to big endian.
#define OSSwapHostToBigInt16(x) OSSwapInt16(x)
x
The integer to convert.
OSSwapHostToBigInt32 |
Converts a 32-bit host endian integer to big endian.
#define OSSwapHostToBigInt32(x) OSSwapInt32(x)
x
The integer to convert.
OSSwapHostToBigInt64 |
Converts a 64-bit host endian integer to big endian.
#define OSSwapHostToBigInt64(x) OSSwapInt64(x)
x
The integer to convert.
OSSwapHostToLittleConstInt16 |
Converts a 16-bit host endian constant to little endian.
#define OSSwapHostToLittleConstInt16(x)
x
The constant to convert.
OSSwapHostToLittleConstInt32 |
Converts a 32-bit host endian constant to little endian.
#define OSSwapHostToLittleConstInt32(x)
x
The constant to convert.
OSSwapHostToLittleConstInt64 |
Converts a 64-bit host endian constant to little endian.
#define OSSwapHostToLittleConstInt64(x)
x
The constant to convert.
OSSwapHostToLittleInt |
Swaps a 32-bit integer from host byte order to little endian.
#define OSSwapHostToLittleInt(x) OSSwapHostToLittleInt32(x)
See documentation for OSSwapHostToLittleInt32
.
OSSwapHostToLittleInt16 |
Converts a 16-bit host endian integer to little endian.
#define OSSwapHostToLittleInt16(x)
x
The integer to convert.
OSSwapHostToLittleInt32 |
Converts a 32-bit host endian integer to little endian.
#define OSSwapHostToLittleInt32(x)
x
The integer to convert.
OSSwapHostToLittleInt64 |
Converts a 64-bit host endian integer to little endian.
#define OSSwapHostToLittleInt64(x)
x
The integer to convert.
OSSwapLittleToHostConstInt16 |
Converts a 16-bit little endian constant to host byte order.
#define OSSwapLittleToHostConstInt16(x)
x
The constant to convert.
OSSwapLittleToHostConstInt32 |
Converts a 32-bit little endian constant to host byte order.
#define OSSwapLittleToHostConstInt32(x)
x
The constant to convert.
OSSwapLittleToHostConstInt64 |
Converts a 64-bit little endian constant to host byte order.
#define OSSwapLittleToHostConstInt64(x)
x
The constant to convert.
OSSwapLittleToHostInt |
Swaps a 32-bit integer from little endian to host byte order.
#define OSSwapLittleToHostInt(x) OSSwapLittleToHostInt32(x)
See documentation for OSSwapLittleToHostInt32
.
OSSwapLittleToHostInt16 |
Converts a 16-bit little endian integer to host byte order.
#define OSSwapLittleToHostInt16(x)
x
The integer to convert.
OSSwapLittleToHostInt32 |
Converts a 32-bit little endian integer to host byte order.
#define OSSwapLittleToHostInt32(x)
x
The integer to convert.
OSSwapLittleToHostInt64 |
Converts a 64-bit little endian integer to host byte order.
#define OSSwapLittleToHostInt64(x)
x
The integer to convert.
OSWriteBigInt |
Writes a 32-bit big-endian integer.
#define OSWriteBigInt(x, y, z) OSWriteBigInt32(x, y, z)
See documentation for OSWriteBigInt32
.
OSWriteBigInt16 |
Writes a 16-bit big endian integer and swaps from host byte order.
#define OSWriteBigInt16(base, byteOffset, data) OSWriteSwapInt16(base, byteOffset, data)
base
An address at or below the address of the integer to be written.
byteOffset
The offset from base
(in bytes)
of the start of the integer to be written.
data
The value to write (in host byte order).
OSWriteBigInt32 |
Writes a 32-bit big endian integer and swaps from host byte order.
#define OSWriteBigInt32(base, byteOffset, data) OSWriteSwapInt32(base, byteOffset, data)
base
An address at or below the address of the integer to be written.
byteOffset
The offset from base
(in bytes)
of the start of the integer to be written.
data
The value to write (in host byte order).
OSWriteBigInt64 |
Writes a 64-bit big endian integer and swaps from host byte order.
#define OSWriteBigInt64(base, byteOffset, data) OSWriteSwapInt64(base, byteOffset, data)
base
An address at or below the address of the integer to be written.
byteOffset
The offset from base
(in bytes)
of the start of the integer to be written.
data
The value to write (in host byte order).
OSWriteLittleInt |
Writes a 32-bit little-endian integer.
#define OSWriteLittleInt(x, y, z) OSWriteLittleInt32(x, y, z)
See documentation for OSWriteLittleInt32
.
OSWriteLittleInt16 |
Writes a 16-bit little endian integer and swaps from host byte order.
#define OSWriteLittleInt16(base, byteOffset, data) _OSWriteInt16(base, byteOffset, data)
base
An address at or below the address of the integer to be read.
byteOffset
The offset from base
(in bytes)
of the start of the integer to be read.
data
The value to write (in host byte order).
OSWriteLittleInt32 |
Writes a 32-bit little endian integer and swaps from host byte order.
#define OSWriteLittleInt32(base, byteOffset, data) _OSWriteInt32(base, byteOffset, data)
base
An address at or below the address of the integer to be read.
byteOffset
The offset from base
(in bytes)
of the start of the integer to be read.
data
The value to write (in host byte order).
OSWriteLittleInt64 |
Writes a 64-bit little endian integer and swaps from host byte order.
#define OSWriteLittleInt64(base, byteOffset, data) _OSWriteInt64(base, byteOffset, data)
base
An address at or below the address of the integer to be read.
byteOffset
The offset from base
(in bytes)
of the start of the integer to be read.
data
The value to write (in host byte order).
Last Updated: 2009-10-15