RetroArch
Macros | Functions
retro_endianness.h File Reference
#include <retro_inline.h>
#include <stdint.h>
#include <stdlib.h>
Include dependency graph for retro_endianness.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define SWAP16(x)
 
#define SWAP32(x)
 
#define SWAP64(val)
 

Functions

static INLINE uint8_t is_little_endian (void)
 
static INLINE uint64_t swap_if_big64 (uint64_t val)
 
static INLINE uint32_t swap_if_big32 (uint32_t val)
 
static INLINE uint64_t swap_if_little64 (uint64_t val)
 
static INLINE uint32_t swap_if_little32 (uint32_t val)
 
static INLINE uint16_t swap_if_big16 (uint16_t val)
 
static INLINE uint16_t swap_if_little16 (uint16_t val)
 
static INLINE void store32be (uint32_t *addr, uint32_t data)
 
static INLINE uint32_t load32be (const uint32_t *addr)
 

Macro Definition Documentation

◆ SWAP16

#define SWAP16 (   x)
Value:
((uint16_t)( \
(((uint16_t)(x) & 0x00ff) << 8) | \
(((uint16_t)(x) & 0xff00) >> 8) \
))
GLint GLint GLint GLint GLint x
Definition: glext.h:6295
unsigned short uint16_t
Definition: stdint.h:125

◆ SWAP32

#define SWAP32 (   x)
Value:
((uint32_t)( \
(((uint32_t)(x) & 0x000000ff) << 24) | \
(((uint32_t)(x) & 0x0000ff00) << 8) | \
(((uint32_t)(x) & 0x00ff0000) >> 8) | \
(((uint32_t)(x) & 0xff000000) >> 24) \
))
GLint GLint GLint GLint GLint x
Definition: glext.h:6295
unsigned int uint32_t
Definition: stdint.h:126

◆ SWAP64

#define SWAP64 (   val)
Value:
((((uint64_t)(val) & 0x00000000000000ffULL) << 56) \
| (((uint64_t)(val) & 0x000000000000ff00ULL) << 40) \
| (((uint64_t)(val) & 0x0000000000ff0000ULL) << 24) \
| (((uint64_t)(val) & 0x00000000ff000000ULL) << 8) \
| (((uint64_t)(val) & 0x000000ff00000000ULL) >> 8) \
| (((uint64_t)(val) & 0x0000ff0000000000ULL) >> 24) \
| (((uint64_t)(val) & 0x00ff000000000000ULL) >> 40) \
| (((uint64_t)(val) & 0xff00000000000000ULL) >> 56))
GLuint GLfloat * val
Definition: glext.h:7847
unsigned __int64 uint64_t
Definition: stdint.h:136

Function Documentation

◆ is_little_endian()

static INLINE uint8_t is_little_endian ( void  )
static

is_little_endian:

Checks if the system is little endian or big-endian.

Returns: greater than 0 if little-endian, otherwise big-endian.

Here is the caller graph for this function:

◆ load32be()

static INLINE uint32_t load32be ( const uint32_t addr)
static

load32be: : pointer to unsigned 32-bit buffer

Load value from address. Endian-safe.

Returns: value from address, byte-swapped if necessary.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ store32be()

static INLINE void store32be ( uint32_t addr,
uint32_t  data 
)
static

store32be: : pointer to unsigned 32-bit buffer : unsigned 32-bit value to write

Write data to address. Endian-safe. Byteswaps the data first if necessary before storing it.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ swap_if_big16()

static INLINE uint16_t swap_if_big16 ( uint16_t  val)
static

swap_if_big16: : unsigned 16-bit value

Byteswap unsigned 16-bit value if system is big-endian.

Returns: Byteswapped value in case system is big-endian, otherwise returns same value.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ swap_if_big32()

static INLINE uint32_t swap_if_big32 ( uint32_t  val)
static

swap_if_big32: : unsigned 32-bit value

Byteswap unsigned 32-bit value if system is big-endian.

Returns: Byteswapped value in case system is big-endian, otherwise returns same value.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ swap_if_big64()

static INLINE uint64_t swap_if_big64 ( uint64_t  val)
static

swap_if_big64: : unsigned 64-bit value

Byteswap unsigned 64-bit value if system is big-endian.

Returns: Byteswapped value in case system is big-endian, otherwise returns same value.

Here is the call graph for this function:

◆ swap_if_little16()

static INLINE uint16_t swap_if_little16 ( uint16_t  val)
static

swap_if_little16: : unsigned 16-bit value

Byteswap unsigned 16-bit value if system is little-endian.

Returns: Byteswapped value in case system is little-endian, otherwise returns same value.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ swap_if_little32()

static INLINE uint32_t swap_if_little32 ( uint32_t  val)
static

swap_if_little32: : unsigned 32-bit value

Byteswap unsigned 32-bit value if system is little-endian.

Returns: Byteswapped value in case system is little-endian, otherwise returns same value.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ swap_if_little64()

static INLINE uint64_t swap_if_little64 ( uint64_t  val)
static

swap_if_little64: : unsigned 64-bit value

Byteswap unsigned 64-bit value if system is little-endian.

Returns: Byteswapped value in case system is little-endian, otherwise returns same value.

Here is the call graph for this function:
Here is the caller graph for this function: