SDL_endian.h File Reference
`#include "SDL_stdinc.h"`
`#include "begin_code.h"`
`#include "close_code.h"`
Include dependency graph for SDL_endian.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Macros

Swap to native
Byteswap item from the specified endianness to the native endianness.
#define | SDL_SwapLE16(X)
#define | SDL_SwapLE32(X)
#define | SDL_SwapLE64(X)
#define | SDL_SwapFloatLE(X)
#define | SDL_SwapBE16(X)
#define | SDL_SwapBE32(X)
#define | SDL_SwapBE64(X)
#define | SDL_SwapFloatBE(X)

## The two types of endianness

# CategoryEndian

Functions for reading and writing endian-specific values

#define | SDL_LIL_ENDIAN 1234
#define | SDL_BIG_ENDIAN 4321
#define | SDL_BYTEORDER SDL_LIL_ENDIAN
#define | SDL_FLOATWORDORDER SDL_BYTEORDER
#define | HAS_BUILTIN_BSWAP16 0
#define | HAS_BUILTIN_BSWAP32 0
#define | HAS_BUILTIN_BSWAP64 0
#define | HAS_BROKEN_BSWAP 0
SDL_FORCE_INLINE Uint16 | SDL_Swap16 (Uint16 x)
SDL_FORCE_INLINE Uint32 | SDL_Swap32 (Uint32 x)
SDL_FORCE_INLINE Uint64 | SDL_Swap64 (Uint64 x)
SDL_FORCE_INLINE float | SDL_SwapFloat (float x)

## Macro Definition Documentation

## HAS_BROKEN_BSWAP

#define HAS_BROKEN_BSWAP 0

Definition at line 147 of file SDL_endian.h.

## HAS_BUILTIN_BSWAP16

#define HAS_BUILTIN_BSWAP16 0

Definition at line 144 of file SDL_endian.h.

## HAS_BUILTIN_BSWAP32

#define HAS_BUILTIN_BSWAP32 0

Definition at line 145 of file SDL_endian.h.

## HAS_BUILTIN_BSWAP64

#define HAS_BUILTIN_BSWAP64 0

Definition at line 146 of file SDL_endian.h.

## SDL_BIG_ENDIAN

#define SDL_BIG_ENDIAN 4321

Definition at line 55 of file SDL_endian.h.

## SDL_BYTEORDER

#define SDL_BYTEORDER SDL_LIL_ENDIAN

Definition at line 94 of file SDL_endian.h.

## SDL_FLOATWORDORDER

#define SDL_FLOATWORDORDER SDL_BYTEORDER

Definition at line 117 of file SDL_endian.h.

## SDL_LIL_ENDIAN

#define SDL_LIL_ENDIAN 1234

Definition at line 54 of file SDL_endian.h.

## SDL_SwapBE16

#define SDL_SwapBE16 | ( |  | X | ) |

Value:
SDL_Swap16(X)
SDL_Swap16
SDL_FORCE_INLINE Uint16 SDL_Swap16(Uint16 x)
Definition SDL_endian.h:203

Definition at line 372 of file SDL_endian.h.

## SDL_SwapBE32

#define SDL_SwapBE32 | ( |  | X | ) |

Value:
SDL_Swap32(X)
SDL_Swap32
SDL_FORCE_INLINE Uint32 SDL_Swap32(Uint32 x)
Definition SDL_endian.h:264

Definition at line 373 of file SDL_endian.h.

## SDL_SwapBE64

#define SDL_SwapBE64 | ( |  | X | ) |

Value:
SDL_Swap64(X)
SDL_Swap64
SDL_FORCE_INLINE Uint64 SDL_Swap64(Uint64 x)
Definition SDL_endian.h:319

Definition at line 374 of file SDL_endian.h.

## SDL_SwapFloatBE

#define SDL_SwapFloatBE | ( |  | X | ) |

Value:
SDL_SwapFloat(X)
SDL_SwapFloat
SDL_FORCE_INLINE float SDL_SwapFloat(float x)
Definition SDL_endian.h:345

Definition at line 375 of file SDL_endian.h.

## SDL_SwapFloatLE

#define SDL_SwapFloatLE | ( |  | X | ) |

Value:
(X)

Definition at line 371 of file SDL_endian.h.

## SDL_SwapLE16

#define SDL_SwapLE16 | ( |  | X | ) |

Value:
(X)

Definition at line 368 of file SDL_endian.h.

## SDL_SwapLE32

#define SDL_SwapLE32 | ( |  | X | ) |

Value:
(X)

Definition at line 369 of file SDL_endian.h.

## SDL_SwapLE64

#define SDL_SwapLE64 | ( |  | X | ) |

Value:
(X)

Definition at line 370 of file SDL_endian.h.

## Function Documentation

## SDL_Swap16()

SDL_FORCE_INLINE Uint16 SDL_Swap16 | ( | Uint16 | x | ) |

Use this function to swap the byte order of a 16-bit value.

Parameters

  x | the value to be swapped.

Returns
  the swapped value.

See also
  SDL_SwapBE16
  SDL_SwapLE16

Definition at line 203 of file SDL_endian.h.

{
return SDL_static_cast(Uint16, ((x << 8) | (x >> 8)));
}
Uint16
uint16_t Uint16
Definition SDL_stdinc.h:217
SDL_static_cast
#define SDL_static_cast(type, expression)
Definition SDL_stdinc.h:163

References SDL_static_cast.

## SDL_Swap32()

SDL_FORCE_INLINE Uint32 SDL_Swap32 | ( | Uint32 | x | ) |

Use this function to swap the byte order of a 32-bit value.

Parameters

  x | the value to be swapped.

Returns
  the swapped value.

See also
  SDL_SwapBE32
  SDL_SwapLE32

Definition at line 264 of file SDL_endian.h.

{
return SDL_static_cast(Uint32, ((x << 24) | ((x << 8) & 0x00FF0000) |
((x >> 8) & 0x0000FF00) | (x >> 24)));
}
Uint32
uint32_t Uint32
Definition SDL_stdinc.h:231

References SDL_static_cast.

Referenced by SDL_Swap64(), and SDL_SwapFloat().

## SDL_Swap64()

SDL_FORCE_INLINE Uint64 SDL_Swap64 | ( | Uint64 | x | ) |

Use this function to swap the byte order of a 64-bit value.

Parameters

  x | the value to be swapped.

Returns
  the swapped value.

See also
  SDL_SwapBE64
  SDL_SwapLE64

Definition at line 319 of file SDL_endian.h.

{
Uint32 hi, lo;
/* Separate into high and low 32-bit values and swap them */
lo = SDL_static_cast(Uint32, x & 0xFFFFFFFF);
x >>= 32;
hi = SDL_static_cast(Uint32, x & 0xFFFFFFFF);
x = SDL_Swap32(lo);
x <<= 32;
x |= SDL_Swap32(hi);
return (x);
}

References SDL_static_cast, and SDL_Swap32().

## SDL_SwapFloat()

SDL_FORCE_INLINE float SDL_SwapFloat | ( | float | x | ) |

Use this function to swap the byte order of a floating point value.

Parameters

  x | the value to be swapped.

Returns
  the swapped value.

See also
  SDL_SwapFloatBE
  SDL_SwapFloatLE

Definition at line 345 of file SDL_endian.h.

{
union {
float f;
Uint32 ui32;
} swapper;
swapper.f = x;
swapper.ui32 = SDL_Swap32(swapper.ui32);
return swapper.f;
}

References SDL_Swap32().