14#ifndef WPIUTIL_WPI_SWAPBYTEORDER_H
15#define WPIUTIL_WPI_SWAPBYTEORDER_H
20#if defined(_MSC_VER) && !defined(_DEBUG)
24#if defined(__linux__) || defined(__GNU__) || defined(__HAIKU__) || \
25 defined(__Fuchsia__) || defined(__EMSCRIPTEN__)
28#include <sys/machine.h>
32#define BIG_ENDIAN 4321
33#define LITTLE_ENDIAN 1234
34#if defined(_BIG_ENDIAN)
35#define BYTE_ORDER BIG_ENDIAN
37#define BYTE_ORDER LITTLE_ENDIAN
40#define BIG_ENDIAN 4321
41#define LITTLE_ENDIAN 1234
42#define BYTE_ORDER BIG_ENDIAN
44#if !defined(BYTE_ORDER) && !defined(_WIN32)
45#include <machine/endian.h>
54#if defined(_MSC_VER) && !defined(_DEBUG)
57 return _byteswap_ushort(
value);
67#if defined(__llvm__) || (defined(__GNUC__) && !defined(__ICC))
68 return __builtin_bswap32(
value);
69#elif defined(_MSC_VER) && !defined(_DEBUG)
70 return _byteswap_ulong(
value);
76 return (Byte0 << 24) | (Byte1 << 8) | (Byte2 >> 8) | (Byte3 >> 24);
82#if defined(__llvm__) || (defined(__GNUC__) && !defined(__ICC))
83 return __builtin_bswap64(
value);
84#elif defined(_MSC_VER) && !defined(_DEBUG)
85 return _byteswap_uint64(
value);
89 return (Hi << 32) | Lo;
95#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
153 return static_cast<T
>(
::uint64_t uint64_t
Definition: Meta.h:58
::uint16_t uint16_t
Definition: Meta.h:54
::uint32_t uint32_t
Definition: Meta.h:56
void swapByteOrder(T &Value)
Definition: SwapByteOrder.h:158
constexpr bool IsBigEndianHost
Definition: SwapByteOrder.h:98
unsigned char getSwappedBytes(unsigned char C)
Definition: SwapByteOrder.h:103
static const bool IsLittleEndianHost
Definition: SwapByteOrder.h:101
/file This file defines the SmallVector class.
Definition: AprilTagFieldLayout.h:18
uint32_t ByteSwap_32(uint32_t value)
This function returns a byte-swapped representation of the 32-bit argument.
Definition: SwapByteOrder.h:66
uint64_t ByteSwap_64(uint64_t value)
This function returns a byte-swapped representation of the 64-bit argument.
Definition: SwapByteOrder.h:81
uint16_t ByteSwap_16(uint16_t value)
ByteSwap_16 - This function returns a byte-swapped representation of the 16-bit argument.
Definition: SwapByteOrder.h:53