Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
byte_order.cpp File Reference
#include "precompiled.h"
#include "lib/byte_order.h"
#include "lib/bits.h"
#include <cstring>
Include dependency graph for byte_order.cpp:

Functions

u16 swap16 (const u16 x)
 
u32 swap32 (const u32 x)
 
u64 swap64 (const u64 x)
 
u16 read_le16 (const void *p)
 read a little-endian number from memory into native byte order. More...
 
u32 read_le32 (const void *p)
 
u64 read_le64 (const void *p)
 see read_le16 More...
 
u16 read_be16 (const void *p)
 see read_le16 More...
 
u32 read_be32 (const void *p)
 
u64 read_be64 (const void *p)
 see read_be16 More...
 
void write_le16 (void *p, u16 x)
 see read_be16 More...
 
void write_le32 (void *p, u32 x)
 
void write_le64 (void *p, u64 x)
 see write_le16 More...
 
void write_be16 (void *p, u16 x)
 see write_le16 More...
 
void write_be32 (void *p, u32 x)
 
void write_be64 (void *p, u64 x)
 see write_be16 More...
 
u64 movzx_le64 (const u8 *p, size_t size_bytes)
 see write_be16 More...
 
u64 movzx_be64 (const u8 *p, size_t size_bytes)
 
static i64 SignExtend (u64 bits, size_t size_bytes)
 
i64 movsx_le64 (const u8 *p, size_t size_bytes)
 sign-extend <size> (truncated to 8) bytes of little-endian data to i64, starting at address <p> (need not be aligned). More...
 
i64 movsx_be64 (const u8 *p, size_t size_bytes)
 

Function Documentation

◆ movsx_be64()

i64 movsx_be64 ( const u8 p,
size_t  size_bytes 
)

◆ movsx_le64()

i64 movsx_le64 ( const u8 p,
size_t  size_bytes 
)

sign-extend <size> (truncated to 8) bytes of little-endian data to i64, starting at address <p> (need not be aligned).

◆ movzx_be64()

u64 movzx_be64 ( const u8 p,
size_t  size_bytes 
)

◆ movzx_le64()

u64 movzx_le64 ( const u8 p,
size_t  size 
)

see write_be16

zero-extend <size> (truncated to 8) bytes of little-endian data to u64, starting at address <p> (need not be aligned).

◆ read_be16()

u16 read_be16 ( const void *  p)

see read_le16

read a big-endian number from memory into native byte order.

◆ read_be32()

u32 read_be32 ( const void *  p)

◆ read_be64()

u64 read_be64 ( const void *  p)

see read_be16

◆ read_le16()

u16 read_le16 ( const void *  p)

read a little-endian number from memory into native byte order.

◆ read_le32()

u32 read_le32 ( const void *  p)

◆ read_le64()

u64 read_le64 ( const void *  p)

see read_le16

◆ SignExtend()

static i64 SignExtend ( u64  bits,
size_t  size_bytes 
)
inlinestatic

◆ swap16()

u16 swap16 ( const u16  x)

◆ swap32()

u32 swap32 ( const u32  x)

◆ swap64()

u64 swap64 ( const u64  x)

◆ write_be16()

void write_be16 ( void *  p,
u16  x 
)

see write_le16

write a big-endian number to memory in native byte order.

◆ write_be32()

void write_be32 ( void *  p,
u32  x 
)

◆ write_be64()

void write_be64 ( void *  p,
u64  x 
)

see write_be16

◆ write_le16()

void write_le16 ( void *  p,
u16  x 
)

see read_be16

write a little-endian number to memory in native byte order.

◆ write_le32()

void write_le32 ( void *  p,
u32  x 
)

◆ write_le64()

void write_le64 ( void *  p,
u64  x 
)

see write_le16