mal-packet-weaver
C++20 packet serialization/deserialization library.
Loading...
Searching...
No Matches
mal_toolkit::endianness Namespace Reference

Enumerations

enum class  CompilerType : uint32_t { kUnknown = 1 << 0 , kGCC = 1 << 1 , kMSVC = 1 << 2 , kICC = 1 << 3 }
 Ensures that the determined endianness is valid. More...
 

Functions

constexpr bool is_big_endian ()
 Determines if the system's native endianness is big-endian.
 
constexpr bool is_little_endian ()
 Determines if the system's native endianness is little-endian.
 
constexpr uint32_t compiler_type ()
 Determines the compiler type used to compile the code.
 
constexpr bool is_compiler_icc ()
 Checks if the code was compiled with ICC (Intel C++ Compiler).
 
constexpr bool is_compiler_gcc ()
 Checks if the code was compiled with GCC (GNU Compiler Collection).
 
constexpr bool is_compiler_msvc ()
 Checks if the code was compiled with MSVC (Microsoft Visual C++).
 
uint16_t betole16 (uint16_t x)
 Converts a 16-bit value between big-endian and little-endian.
 
uint32_t betole32 (uint32_t x)
 Converts a 32-bit value between big-endian and little-endian.
 
uint64_t betole64 (uint64_t x)
 Converts a 64-bit value between big-endian and little-endian.
 
__m128i betole128 (__m128i x)
 Converts a 128-bit value between big-endian and little-endian using SSE2 intrinsics.
 
__m256i betole256 (__m256i x)
 Converts a 256-bit value between big-endian and little-endian using AVX2 intrinsics.
 

Variables

constexpr bool kIsBigEndian = is_big_endian()
 Represents the determined endianness of the system.
 
constexpr bool kIsLittleEndian = is_little_endian()
 Represents the determined endianness of the system.
 
constexpr uint32_t kCompilerType = compiler_type()
 Indicates the compiler type used for the code.
 

Enumeration Type Documentation

◆ CompilerType

enum class mal_toolkit::endianness::CompilerType : uint32_t
strong

Ensures that the determined endianness is valid.

This compile-time assertion checks if the determined endianness is either big-endian or little-endian.

Indicates the compiler type.

Enumerator
kUnknown 
kGCC 
kMSVC 
kICC 

Definition at line 55 of file endianness.hpp.

Function Documentation

◆ betole128()

__m128i mal_toolkit::endianness::betole128 ( __m128i x)

Converts a 128-bit value between big-endian and little-endian using SSE2 intrinsics.

Parameters
xThe value to be converted.
Returns
The converted value.

Definition at line 188 of file endianness.hpp.

Here is the caller graph for this function:

◆ betole16()

uint16_t mal_toolkit::endianness::betole16 ( uint16_t x)
inline

Converts a 16-bit value between big-endian and little-endian.

Parameters
xThe value to be converted.
Returns
The converted value.

Definition at line 114 of file endianness.hpp.

Here is the caller graph for this function:

◆ betole256()

__m256i mal_toolkit::endianness::betole256 ( __m256i x)

Converts a 256-bit value between big-endian and little-endian using AVX2 intrinsics.

Parameters
xThe value to be converted.
Returns
The converted value.

Definition at line 204 of file endianness.hpp.

Here is the caller graph for this function:

◆ betole32()

uint32_t mal_toolkit::endianness::betole32 ( uint32_t x)
inline

Converts a 32-bit value between big-endian and little-endian.

Parameters
xThe value to be converted.
Returns
The converted value.

Definition at line 136 of file endianness.hpp.

Here is the caller graph for this function:

◆ betole64()

uint64_t mal_toolkit::endianness::betole64 ( uint64_t x)

Converts a 64-bit value between big-endian and little-endian.

Parameters
xThe value to be converted.
Returns
The converted value.

Definition at line 160 of file endianness.hpp.

◆ compiler_type()

uint32_t mal_toolkit::endianness::compiler_type ( )
constexpr

Determines the compiler type used to compile the code.

Returns
A bitmask representing the compiler type.

Definition at line 67 of file endianness.hpp.

◆ is_big_endian()

bool mal_toolkit::endianness::is_big_endian ( )
constexpr

Determines if the system's native endianness is big-endian.

Returns
True if the system's native endianness is big-endian, false otherwise.

Definition at line 23 of file endianness.hpp.

◆ is_compiler_gcc()

bool mal_toolkit::endianness::is_compiler_gcc ( )
constexpr

Checks if the code was compiled with GCC (GNU Compiler Collection).

Returns
True if the code was compiled with GCC, false otherwise.

Definition at line 101 of file endianness.hpp.

◆ is_compiler_icc()

bool mal_toolkit::endianness::is_compiler_icc ( )
constexpr

Checks if the code was compiled with ICC (Intel C++ Compiler).

Returns
True if the code was compiled with ICC, false otherwise.

Definition at line 95 of file endianness.hpp.

◆ is_compiler_msvc()

bool mal_toolkit::endianness::is_compiler_msvc ( )
constexpr

Checks if the code was compiled with MSVC (Microsoft Visual C++).

Returns
True if the code was compiled with MSVC, false otherwise.

Definition at line 107 of file endianness.hpp.

◆ is_little_endian()

bool mal_toolkit::endianness::is_little_endian ( )
constexpr

Determines if the system's native endianness is little-endian.

Returns
True if the system's native endianness is little-endian, false otherwise.

Definition at line 29 of file endianness.hpp.

Variable Documentation

◆ kCompilerType

uint32_t mal_toolkit::endianness::kCompilerType = compiler_type()
constexpr

Indicates the compiler type used for the code.

Definition at line 89 of file endianness.hpp.

◆ kIsBigEndian

bool mal_toolkit::endianness::kIsBigEndian = is_big_endian()
constexpr

Represents the determined endianness of the system.

This is a compile-time constant indicating whether the system's native endianness is big-endian or little-endian.

Definition at line 36 of file endianness.hpp.

◆ kIsLittleEndian

bool mal_toolkit::endianness::kIsLittleEndian = is_little_endian()
constexpr

Represents the determined endianness of the system.

This is a compile-time constant indicating whether the system's native endianness is little-endian or big-endian.

Definition at line 43 of file endianness.hpp.