inc/ecu/endian.h File Reference

ECU: inc/ecu/endian.h File Reference
ECU
endian.h File Reference
#include <stdint.h>
Include dependency graph for endian.h:

Go to the source code of this file.

Macros

Compile-time Byte Swapping
#define ECU_SWAP16_COMPILETIME(x_)
 Returns byte-swapped value (switches endiannes) of 16-bit input at compile-time. Compatible with any C or C++ standard that supports fixed-width types since these standards mandate size of int is at least 2 bytes and uint16_t is defined.
 
#define ECU_SWAP32_COMPILETIME(x_)
 Returns byte-swapped value (switches endianness) of 32-bit input at compile-time. Compatible with any C or C++ standard that supports fixed-width types since these standards mandate size of unsigned long (UL) is at least 4 bytes and uint32_t is defined.
 
#define ECU_SWAP64_COMPILETIME(x_)
 Returns byte-swapped value (switches endianness) of 64-bit input at compile-time. Compatible with any C or C++ standard that supports fixed-width types since these standards mandate size of unsigned long long (ULL) is at least 8 bytes and uint64_t is defined.
 
Reading Big Endian Data
#define ECU_BE16_TO_CPU_COMPILETIME(x_)
 Portable method for reading big endian encoded data at compile-time. Returns byte-swapped input if compiling on little endian target. Does nothing and returns same input if compiling on big endian target.
 
#define ECU_BE32_TO_CPU_COMPILETIME(x_)
 Portable method for reading big endian encoded data at compile-time. Returns byte-swapped input if compiling on little endian target. Does nothing and returns same input if compiling on big endian target.
 
#define ECU_BE64_TO_CPU_COMPILETIME(x_)
 Portable method for reading big endian encoded data at compile-time. Returns byte-swapped input if compiling on little endian target. Does nothing and returns same input if compiling on big endian target.
 
#define ECU_BE32_TO_CPU_RUNTIME(x_)
 Portable method for reading big endian encoded data at runtime. Returns byte-swapped input if compiling on little endian target. Does nothing and returns same input if compiling on big endian target.
 
#define ECU_BE64_TO_CPU_RUNTIME(x_)
 Portable method for reading big endian encoded data at compile-time. Returns byte-swapped input if compiling on little endian target. Does nothing and returns same input if compiling on big endian target.
 
#define ECU_BE16_TO_CPU_RUNTIME(x_)
 Portable method for reading big endian encoded data at compile-time. Returns byte-swapped input if compiling on little endian target. Does nothing and returns same input if compiling on big endian target.
 
Reading Little Endian Data
#define ECU_LE16_TO_CPU_COMPILETIME(x_)
 Portable method for reading little endian encoded data at compile-time. Does nothing and returns same input if compiling on little endian target. Returns byte-swapped input if compiling on big endian target.
 
#define ECU_LE32_TO_CPU_COMPILETIME(x_)
 Portable method for reading little endian encoded data at compile-time. Does nothing and returns same input if compiling on little endian target. Returns byte-swapped input if compiling on big endian target.
 
#define ECU_LE64_TO_CPU_COMPILETIME(x_)
 Portable method for reading little endian encoded data at compile-time. Does nothing and returns same input if compiling on little endian target. Returns byte-swapped input if compiling on big endian target.
 
#define ECU_LE16_TO_CPU_RUNTIME(x_)
 Portable method for reading little endian encoded data at runtime. Does nothing and returns same input if compiling on little endian target. Returns byte-swapped input if compiling on big endian target.
 
#define ECU_LE32_TO_CPU_RUNTIME(x_)
 Portable method for reading little endian encoded data at compile-time. Does nothing and returns same input if compiling on little endian target. Returns byte-swapped input if compiling on big endian target.
 
#define ECU_LE64_TO_CPU_RUNTIME(x_)
 Portable method for reading little endian encoded data at compile-time. Does nothing and returns same input if compiling on little endian target. Returns byte-swapped input if compiling on big endian target.
 
Sending Big Endian Data
#define ECU_CPU_TO_BE16_COMPILETIME(x_)
 Portable method for sending data in big endian format at compile-time. Returns byte-swapped input if compiling on little endian target. Does nothing and returns same input if compiling on big endian target.
 
#define ECU_CPU_TO_BE32_COMPILETIME(x_)
 Portable method for sending data in big endian format at compile-time. Returns byte-swapped input if compiling on little endian target. Does nothing and returns same input if compiling on big endian target.
 
#define ECU_CPU_TO_BE64_COMPILETIME(x_)
 Portable method for sending data in big endian format at compile-time. Returns byte-swapped input if compiling on little endian target. Does nothing and returns same input if compiling on big endian target.
 
#define ECU_CPU_TO_BE16_RUNTIME(x_)
 Portable method for sending data in big endian format at runtime. Returns byte-swapped input if compiling on little endian target. Does nothing and returns same input if compiling on big endian target.
 
#define ECU_CPU_TO_BE32_RUNTIME(x_)
 Portable method for sending data in big endian format at compile-time. Returns byte-swapped input if compiling on little endian target. Does nothing and returns same input if compiling on big endian target.
 
#define ECU_CPU_TO_BE64_RUNTIME(x_)
 Portable method for sending data in big endian format at compile-time. Returns byte-swapped input if compiling on little endian target. Does nothing and returns same input if compiling on big endian target.
 
Sending Little Endian Data
#define ECU_CPU_TO_LE16_COMPILETIME(x_)
 Portable method for sending data in little endian format at compile-time. Does nothing and returns same input if compiling on little endian target. Returns byte-swapped input if compiling on big endian target.
 
#define ECU_CPU_TO_LE32_COMPILETIME(x_)
 Portable method for sending data in little endian format at compile-time. Does nothing and returns same input if compiling on little endian target. Returns byte-swapped input if compiling on big endian target.
 
#define ECU_CPU_TO_LE64_COMPILETIME(x_)
 Portable method for sending data in little endian format at compile-time. Does nothing and returns same input if compiling on little endian target. Returns byte-swapped input if compiling on big endian target.
 
#define ECU_CPU_TO_LE16_RUNTIME(x_)
 Portable method for sending data in little endian format at runtime. Does nothing and returns same input if compiling on little endian target. Returns byte-swapped input if compiling on big endian target.
 
#define ECU_CPU_TO_LE32_RUNTIME(x_)
 Portable method for sending data in little endian format at compile-time. Does nothing and returns same input if compiling on little endian target. Returns byte-swapped input if compiling on big endian target.
 
#define ECU_CPU_TO_LE64_RUNTIME(x_)
 Portable method for sending data in little endian format at compile-time. Does nothing and returns same input if compiling on little endian target. Returns byte-swapped input if compiling on big endian target.
 

Functions

Runtime Byte Swapping
static uint16_t ecu_swap16_runtime (uint_fast16_t val)
 Returns byte-swapped value (switches endianness) of 16-bit input at runtime. Can handle signed inputs since implementation only cares about the binary representation of the input, not its actual value.
 
static uint32_t ecu_swap32_runtime (uint_fast32_t val)
 Returns byte-swapped value (switches endianness) of 32-bit input at runtime. Can handle signed inputs since implementation only cares about the binary representation of the input, not its actual value.
 
static uint64_t ecu_swap64_runtime (uint_fast64_t val)
 Returns byte-swapped value (switches endianness) of 64-bit input at runtime. Can handle signed inputs since implementation only cares about the binary representation of the input, not its actual value.
 

Detailed Description

See endian.h section in Sphinx documentation.

Author
Ian Ress
Version
0.1
Date
2024-04-17