nl:: Weave:: Encoding:: BigEndian
This namespace provides functions for:
Summary
- Performing byte reordering, relative to the host system, by value of big endian byte ordered values for 16-, 32-, and 64-bit types.
- Safely performing simple, efficient memory-mapped accesses, potentially to unaligned memory locations, with or without byte reordering, to 8-, 16-, 32-, and 64-bit big endian byte ordered quantities, both with and without pointer management.
On big endian host systems no actual byte reordering will occur. On other systems, byte reordering is peformed as appropriate.
Functions |
|
---|---|
Get16(const uint8_t *p)
|
uint16_t
Perform a, potentially unaligned, memory read of the big endian byte ordered 16-bit value from the specified pointer address, perform byte reordering, as necessary, for the target system to put the value in target system byte ordering.
|
Get32(const uint8_t *p)
|
uint32_t
Perform a, potentially unaligned, memory read of the big endian byte ordered 32-bit value from the specified pointer address, perform byte reordering, as necessary, for the target system to put the value in target system byte ordering.
|
Get64(const uint8_t *p)
|
uint64_t
Perform a, potentially unaligned, memory read of the big endian byte ordered 64-bit value from the specified pointer address, perform byte reordering, as necessary, for the target system to put the value in target system byte ordering.
|
HostSwap16(uint16_t v)
|
uint16_t
This conditionally performs, as necessary for the target system, a byte order swap by value of the specified 16-bit value, presumed to be in big endian byte ordering to the target system (i.e.
|
HostSwap32(uint32_t v)
|
uint32_t
This conditionally performs, as necessary for the target system, a byte order swap by value of the specified 32-bit value, presumed to be in big endian byte ordering to the target system (i.e.
|
HostSwap64(uint64_t v)
|
uint64_t
This conditionally performs, as necessary for the target system, a byte order swap by value of the specified 64-bit value, presumed to be in big endian byte ordering to the target system (i.e.
|
Put16(uint8_t *p, uint16_t v)
|
void
Perform a, potentially unaligned, memory write of the target system byte ordered 16-bit value to the specified pointer address, perform byte reordering, as necessary, for the target system to put the value in big endian byte ordering.
|
Put32(uint8_t *p, uint32_t v)
|
void
Perform a, potentially unaligned, memory write of the target system byte ordered 32-bit value to the specified pointer address, perform byte reordering, as necessary, for the target system to put the value in big endian byte ordering.
|
Put64(uint8_t *p, uint64_t v)
|
void
Perform a, potentially unaligned, memory write of the target system byte ordered 64-bit value to the specified pointer address, perform byte reordering, as necessary, for the target system to put the value in big endian byte ordering.
|
Read16(uint8_t *& p)
|
uint16_t
Perform a, potentially unaligned, memory read of the big endian byte ordered 16-bit value from the specified pointer address, perform byte reordering, as necessary, for the target system to put the value in target system byte ordering, and increment the pointer by 16-bits (2 bytes).
|
Read16(const uint8_t *& p)
|
uint16_t
Perform a, potentially unaligned, memory read of the big endian byte ordered 16-bit value from the specified pointer address, perform byte reordering, as necessary, for the target system to put the value in target system byte ordering, and increment the pointer by 16-bits (2 bytes).
|
Read32(uint8_t *& p)
|
uint32_t
Perform a, potentially unaligned, memory read of the big endian byte ordered 32-bit value from the specified pointer address, perform byte reordering, as necessary, for the target system to put the value in target system byte ordering, and increment the pointer by 32-bits (4 bytes).
|
Read32(const uint8_t *& p)
|
uint32_t
Perform a, potentially unaligned, memory read of the big endian byte ordered 32-bit value from the specified pointer address, perform byte reordering, as necessary, for the target system to put the value in target system byte ordering, and increment the pointer by 32-bits (4 bytes).
|
Read64(uint8_t *& p)
|
uint64_t
Perform a, potentially unaligned, memory read of the big endian byte ordered 64-bit value from the specified pointer address, perform byte reordering, as necessary, for the target system to put the value in target system byte ordering, and increment the pointer by 64-bits (8 bytes).
|
Read64(const uint8_t *& p)
|
uint64_t
Perform a, potentially unaligned, memory read of the big endian byte ordered 64-bit value from the specified pointer address, perform byte reordering, as necessary, for the target system to put the value in target system byte ordering, and increment the pointer by 64-bits (8 bytes).
|
Write16(uint8_t *& p, uint16_t v)
|
void
Perform a, potentially unaligned, memory write of the target system byte ordered 16-bit value to the specified pointer address, perform byte reordering, as necessary, for the target system to put the value in big endian byte ordering.
|
Write32(uint8_t *& p, uint32_t v)
|
void
Perform a, potentially unaligned, memory write of the target system byte ordered 32-bit value to the specified pointer address, perform byte reordering, as necessary, for the target system to put the value in big endian byte ordering.
|
Write64(uint8_t *& p, uint64_t v)
|
void
Perform a, potentially unaligned, memory write of the target system byte ordered 64-bit value to the specified pointer address, perform byte reordering, as necessary, for the target system to put the value in big endian byte ordering.
|
Functions
Get16
uint16_t Get16( const uint8_t *p )
Perform a, potentially unaligned, memory read of the big endian byte ordered 16-bit value from the specified pointer address, perform byte reordering, as necessary, for the target system to put the value in target system byte ordering.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
The 16-bit value at the specified pointer address, if necessary, byte reordered.
|
Get32
uint32_t Get32( const uint8_t *p )
Perform a, potentially unaligned, memory read of the big endian byte ordered 32-bit value from the specified pointer address, perform byte reordering, as necessary, for the target system to put the value in target system byte ordering.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
The 32-bit value at the specified pointer address, if necessary, byte reordered.
|
Get64
uint64_t Get64( const uint8_t *p )
Perform a, potentially unaligned, memory read of the big endian byte ordered 64-bit value from the specified pointer address, perform byte reordering, as necessary, for the target system to put the value in target system byte ordering.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
The 64-bit value at the specified pointer address, if necessary, byte reordered.
|
HostSwap16
uint16_t HostSwap16( uint16_t v )
This conditionally performs, as necessary for the target system, a byte order swap by value of the specified 16-bit value, presumed to be in big endian byte ordering to the target system (i.e.
host) byte ordering.
Consequently, on bit endian target systems, this is a no-op and on big endian target systems, this performs a reordering.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
The input value, if necessary, byte order swapped.
|
HostSwap32
uint32_t HostSwap32( uint32_t v )
This conditionally performs, as necessary for the target system, a byte order swap by value of the specified 32-bit value, presumed to be in big endian byte ordering to the target system (i.e.
host) byte ordering.
Consequently, on bit endian target systems, this is a no-op and on big endian target systems, this performs a reordering.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
The input value, if necessary, byte order swapped.
|
HostSwap64
uint64_t HostSwap64( uint64_t v )
This conditionally performs, as necessary for the target system, a byte order swap by value of the specified 64-bit value, presumed to be in big endian byte ordering to the target system (i.e.
host) byte ordering.
Consequently, on bit endian target systems, this is a no-op and on big endian target systems, this performs a reordering.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
The input value, if necessary, byte order swapped.
|
Put16
void Put16( uint8_t *p, uint16_t v )
Perform a, potentially unaligned, memory write of the target system byte ordered 16-bit value to the specified pointer address, perform byte reordering, as necessary, for the target system to put the value in big endian byte ordering.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
Put32
void Put32( uint8_t *p, uint32_t v )
Perform a, potentially unaligned, memory write of the target system byte ordered 32-bit value to the specified pointer address, perform byte reordering, as necessary, for the target system to put the value in big endian byte ordering.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
Put64
void Put64( uint8_t *p, uint64_t v )
Perform a, potentially unaligned, memory write of the target system byte ordered 64-bit value to the specified pointer address, perform byte reordering, as necessary, for the target system to put the value in big endian byte ordering.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
Read16
uint16_t Read16( uint8_t *& p )
Perform a, potentially unaligned, memory read of the big endian byte ordered 16-bit value from the specified pointer address, perform byte reordering, as necessary, for the target system to put the value in target system byte ordering, and increment the pointer by 16-bits (2 bytes).
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
The 16-bit value at the specified pointer address, if necessary, byte order swapped.
|
Read16
uint16_t Read16( const uint8_t *& p )
Perform a, potentially unaligned, memory read of the big endian byte ordered 16-bit value from the specified pointer address, perform byte reordering, as necessary, for the target system to put the value in target system byte ordering, and increment the pointer by 16-bits (2 bytes).
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
The 16-bit value at the specified pointer address, if necessary, byte order swapped.
|
Read32
uint32_t Read32( uint8_t *& p )
Perform a, potentially unaligned, memory read of the big endian byte ordered 32-bit value from the specified pointer address, perform byte reordering, as necessary, for the target system to put the value in target system byte ordering, and increment the pointer by 32-bits (4 bytes).
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
The 32-bit value at the specified pointer address, if necessary, byte order swapped.
|
Read32
uint32_t Read32( const uint8_t *& p )
Perform a, potentially unaligned, memory read of the big endian byte ordered 32-bit value from the specified pointer address, perform byte reordering, as necessary, for the target system to put the value in target system byte ordering, and increment the pointer by 32-bits (4 bytes).
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
The 32-bit value at the specified pointer address, if necessary, byte order swapped.
|
Read64
uint64_t Read64( uint8_t *& p )
Perform a, potentially unaligned, memory read of the big endian byte ordered 64-bit value from the specified pointer address, perform byte reordering, as necessary, for the target system to put the value in target system byte ordering, and increment the pointer by 64-bits (8 bytes).
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
The 64-bit value at the specified pointer address, if necessary, byte order swapped.
|
Read64
uint64_t Read64( const uint8_t *& p )
Perform a, potentially unaligned, memory read of the big endian byte ordered 64-bit value from the specified pointer address, perform byte reordering, as necessary, for the target system to put the value in target system byte ordering, and increment the pointer by 64-bits (8 bytes).
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
The 64-bit value at the specified pointer address, if necessary, byte order swapped.
|
Write16
void Write16( uint8_t *& p, uint16_t v )
Perform a, potentially unaligned, memory write of the target system byte ordered 16-bit value to the specified pointer address, perform byte reordering, as necessary, for the target system to put the value in big endian byte ordering.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
Write32
void Write32( uint8_t *& p, uint32_t v )
Perform a, potentially unaligned, memory write of the target system byte ordered 32-bit value to the specified pointer address, perform byte reordering, as necessary, for the target system to put the value in big endian byte ordering.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
Write64
void Write64( uint8_t *& p, uint64_t v )
Perform a, potentially unaligned, memory write of the target system byte ordered 64-bit value to the specified pointer address, perform byte reordering, as necessary, for the target system to put the value in big endian byte ordering.
Details | |||||
---|---|---|---|---|---|
Parameters |
|