roo_io
API Documentation for roo_io
Loading...
Searching...
No Matches
endianness.h File Reference

Convert Endianness of shorts, longs, long longs, regardless of architecture/OS. More...

#include <stdlib.h>
#include <stdint.h>
Include dependency graph for endianness.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

static uint16_t bswap16 (uint16_t x)
 
static uint32_t bswap32 (uint32_t x)
 
static uint64_t bswap64 (uint64_t x)
 
static float bswapf (float f)
 Byte-swap 32-bit float.
 
static double bswapd (double d)
 Byte-swap 64-bit double.
 

Detailed Description

Convert Endianness of shorts, longs, long longs, regardless of architecture/OS.

Defines (without pulling in platform-specific network include headers): bswap16, bswap32, bswap64, ntoh16, hton16, ntoh32 hton32, ntoh64, hton64

Should support linux / macos / solaris / windows. Supports GCC (on any platform, including embedded), MSVC2015, and clang, and should support intel, solaris, and ibm compilers as well.

Copyright 2020 github user jtbr, Released under MIT license

SPDX-License-Identifier: MIT OR Apache-2.0

Definition in file endianness.h.

Function Documentation

◆ bswap16()

static uint16_t bswap16 ( uint16_t  x)
inlinestatic

Definition at line 92 of file endianness.h.

Referenced by roo_io::byte_order::Swapper< uint16_t >::operator()().

◆ bswap32()

static uint32_t bswap32 ( uint32_t  x)
inlinestatic

Definition at line 95 of file endianness.h.

Referenced by bswapf(), and roo_io::byte_order::Swapper< uint32_t >::operator()().

◆ bswap64()

static uint64_t bswap64 ( uint64_t  x)
inlinestatic

Definition at line 101 of file endianness.h.

Referenced by bswapd(), and roo_io::byte_order::Swapper< uint64_t >::operator()().

◆ bswapd()

static double bswapd ( double  d)
inlinestatic

Byte-swap 64-bit double.

Definition at line 138 of file endianness.h.

References bswap64().

◆ bswapf()

static float bswapf ( float  f)
inlinestatic

Byte-swap 32-bit float.

Definition at line 114 of file endianness.h.

References bswap32().