Adding Spectre/System/ByteOrder
This commit is contained in:
parent
396f47cc22
commit
58513d70c0
3 changed files with 36 additions and 0 deletions
20
source/System/ByteOrder.cpp
Normal file
20
source/System/ByteOrder.cpp
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
#include <Spectre/System/ByteOrder.h>
|
||||
|
||||
namespace sp { namespace system
|
||||
{
|
||||
|
||||
uint16_t ltoh16(const uint8_t* bytes)
|
||||
{
|
||||
return bytes[0] | (bytes[1] << 8);
|
||||
}
|
||||
|
||||
uint32_t ltoh32(const uint8_t* bytes)
|
||||
{
|
||||
return bytes[0]
|
||||
| (bytes[1] << 8)
|
||||
| (bytes[2] << 16)
|
||||
| (bytes[3] << 24);
|
||||
}
|
||||
|
||||
} } // namespace sp::system
|
||||
Loading…
Add table
Add a link
Reference in a new issue