Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
endian.h File Reference
#include <stdint.h>

Go to the source code of this file.

Macros

#define htobe16(x)   __bswap_16 (x)
 Converts a host endian 16-bit value to big endian.
 
#define htole16(x)   (x)
 Converts a host endian 16-bit value to little endian.
 
#define be16toh(x)   __bswap_16 (x)
 Converts a big endian 16-bit value to host endian.
 
#define le16toh(x)   (x)
 Converts a little endian 16-bit value to host endian.
 
#define htobe32(x)   __bswap_32 (x)
 Converts a host endian 32-bit value to big endian.
 
#define htole32(x)   (x)
 Converts a host endian 32-bit value to little endian.
 
#define be32toh(x)   __bswap_32 (x)
 Converts a big endian 32-bit value to host endian.
 
#define le32toh(x)   (x)
 Converts a little endian 32-bit value to host endian.
 
#define htobe64(x)   __bswap_64 (x)
 Converts a host endian 64-bit value to big endian.
 
#define htole64(x)   (x)
 Converts a host endian 64-bit value to little endian.
 
#define be64toh(x)   __bswap_64 (x)
 Converts a big endian 64-bit value to host endian.
 
#define le64toh(x)   (x)
 Converts a little endian 64-bit value to host endian.
 

Functions

static uint16_t __bswap_16 (uint16_t x)
 Byte swap a 16 bit value.
 
static uint32_t __bswap_32 (uint32_t x)
 Byte swap a 32 bit value.
 
static uint64_t __bswap_64 (uint64_t x)
 Byte swap a 64 bit value.
 

Detailed Description

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

This file represents endian swapping for the nuttx RTOS

Author
Stuart W. Baker
Date
13 August 2012

Definition in file nuttx/endian.h.

Macro Definition Documentation

◆ be16toh

#define be16toh (   x)    __bswap_16 (x)

Converts a big endian 16-bit value to host endian.

Definition at line 92 of file nuttx/endian.h.

◆ be32toh

#define be32toh (   x)    __bswap_32 (x)

Converts a big endian 32-bit value to host endian.

Definition at line 101 of file nuttx/endian.h.

◆ be64toh

#define be64toh (   x)    __bswap_64 (x)

Converts a big endian 64-bit value to host endian.

Definition at line 110 of file nuttx/endian.h.

◆ htobe16

#define htobe16 (   x)    __bswap_16 (x)

Converts a host endian 16-bit value to big endian.

Definition at line 88 of file nuttx/endian.h.

◆ htobe32

#define htobe32 (   x)    __bswap_32 (x)

Converts a host endian 32-bit value to big endian.

Definition at line 97 of file nuttx/endian.h.

◆ htobe64

#define htobe64 (   x)    __bswap_64 (x)

Converts a host endian 64-bit value to big endian.

Definition at line 106 of file nuttx/endian.h.

◆ htole16

#define htole16 (   x)    (x)

Converts a host endian 16-bit value to little endian.

Definition at line 90 of file nuttx/endian.h.

◆ htole32

#define htole32 (   x)    (x)

Converts a host endian 32-bit value to little endian.

Definition at line 99 of file nuttx/endian.h.

◆ htole64

#define htole64 (   x)    (x)

Converts a host endian 64-bit value to little endian.

Definition at line 108 of file nuttx/endian.h.

◆ le16toh

#define le16toh (   x)    (x)

Converts a little endian 16-bit value to host endian.

Definition at line 94 of file nuttx/endian.h.

◆ le32toh

#define le32toh (   x)    (x)

Converts a little endian 32-bit value to host endian.

Definition at line 103 of file nuttx/endian.h.

◆ le64toh

#define le64toh (   x)    (x)

Converts a little endian 64-bit value to host endian.

Definition at line 112 of file nuttx/endian.h.

Function Documentation

◆ __bswap_16()

static uint16_t __bswap_16 ( uint16_t  x)
inlinestatic

Byte swap a 16 bit value.

Parameters
xvalue to swap
Returns
byte swapped value

Definition at line 40 of file nuttx/endian.h.

◆ __bswap_32()

static uint32_t __bswap_32 ( uint32_t  x)
inlinestatic

Byte swap a 32 bit value.

Parameters
xvalue to swap
Returns
byte swapped value

Definition at line 49 of file nuttx/endian.h.

◆ __bswap_64()

static uint64_t __bswap_64 ( uint64_t  x)
inlinestatic

Byte swap a 64 bit value.

Parameters
xvalue to swap
Returns
byte swapped value

Definition at line 59 of file nuttx/endian.h.