8#ifndef SkEndian_DEFINED
9#define SkEndian_DEFINED
22#if defined(SK_CPU_LENDIAN) && defined(SK_CPU_BENDIAN)
23 #error "can't have both LENDIAN and BENDIAN defined"
26#if !defined(SK_CPU_LENDIAN) && !defined(SK_CPU_BENDIAN)
27 #error "need either LENDIAN or BENDIAN defined"
34 return static_cast<uint16_t
>((
value >> 8) | ((
value & 0xFF) << 8));
38 static const uint16_t
value =
static_cast<uint16_t
>((
N >> 8) | ((
N & 0xFF) << 8));
47 while (--
count >= 0) {
57 return ((
value & 0xFF) << 24) |
58 ((
value & 0xFF00) << 8) |
59 ((
value & 0xFF0000) >> 8) |
64 static const uint32_t
value = ((
N & 0xFF) << 24) |
66 ((
N & 0xFF0000) >> 8) |
76 while (--
count >= 0) {
86 return (((
value & 0x00000000000000FFULL) << (8*7)) |
87 ((
value & 0x000000000000FF00ULL) << (8*5)) |
88 ((
value & 0x0000000000FF0000ULL) << (8*3)) |
89 ((
value & 0x00000000FF000000ULL) << (8*1)) |
90 ((
value & 0x000000FF00000000ULL) >> (8*1)) |
91 ((
value & 0x0000FF0000000000ULL) >> (8*3)) |
92 ((
value & 0x00FF000000000000ULL) >> (8*5)) |
96 static const uint64_t
value = (((
N & 0x00000000000000FFULL) << (8*7)) |
97 ((
N & 0x000000000000FF00ULL) << (8*5)) |
98 ((
N & 0x0000000000FF0000ULL) << (8*3)) |
99 ((
N & 0x00000000FF000000ULL) << (8*1)) |
100 ((
N & 0x000000FF00000000ULL) >> (8*1)) |
101 ((
N & 0x0000FF0000000000ULL) >> (8*3)) |
102 ((
N & 0x00FF000000000000ULL) >> (8*5)) |
112 while (--
count >= 0) {
121 #define SkEndian_SwapBE16(n) SkEndianSwap16(n)
122 #define SkEndian_SwapBE32(n) SkEndianSwap32(n)
123 #define SkEndian_SwapBE64(n) SkEndianSwap64(n)
124 #define SkEndian_SwapLE16(n) static_cast<uint16_t>(n)
125 #define SkEndian_SwapLE32(n) static_cast<uint32_t>(n)
126 #define SkEndian_SwapLE64(n) static_cast<uint64_t>(n)
128 #define SkTEndian_SwapBE16(n) SkTEndianSwap16<n>::value
129 #define SkTEndian_SwapBE32(n) SkTEndianSwap32<n>::value
130 #define SkTEndian_SwapBE64(n) SkTEndianSwap64<n>::value
131 #define SkTEndian_SwapLE16(n) (n)
132 #define SkTEndian_SwapLE32(n) (n)
133 #define SkTEndian_SwapLE64(n) (n)
135 #define SkEndian_SwapBE16(n) static_cast<uint16_t>(n)
136 #define SkEndian_SwapBE32(n) static_cast<uint32_t>(n)
137 #define SkEndian_SwapBE64(n) static_cast<uint64_t>(n)
138 #define SkEndian_SwapLE16(n) SkEndianSwap16(n)
139 #define SkEndian_SwapLE32(n) SkEndianSwap32(n)
140 #define SkEndian_SwapLE64(n) SkEndianSwap64(n)
142 #define SkTEndian_SwapBE16(n) (n)
143 #define SkTEndian_SwapBE32(n) (n)
144 #define SkTEndian_SwapBE64(n) (n)
145 #define SkTEndian_SwapLE16(n) SkTEndianSwap16<n>::value
146 #define SkTEndian_SwapLE32(n) SkTEndianSwap32<n>::value
147 #define SkTEndian_SwapLE64(n) SkTEndianSwap64<n>::value
153 #define SkEndian_Byte0Shift 0
154 #define SkEndian_Byte1Shift 8
155 #define SkEndian_Byte2Shift 16
156 #define SkEndian_Byte3Shift 24
158 #define SkEndian_Byte0Shift 24
159 #define SkEndian_Byte1Shift 16
160 #define SkEndian_Byte2Shift 8
161 #define SkEndian_Byte3Shift 0
165#if defined(SK_UINT8_BITFIELD_LENDIAN) && defined(SK_UINT8_BITFIELD_BENDIAN)
166 #error "can't have both bitfield LENDIAN and BENDIAN defined"
169#if !defined(SK_UINT8_BITFIELD_LENDIAN) && !defined(SK_UINT8_BITFIELD_BENDIAN)
170 #ifdef SK_CPU_LENDIAN
171 #define SK_UINT8_BITFIELD_LENDIAN
173 #define SK_UINT8_BITFIELD_BENDIAN
177#ifdef SK_UINT8_BITFIELD_LENDIAN
178 #define SK_UINT8_BITFIELD(f0, f1, f2, f3, f4, f5, f6, f7) \
188 #define SK_UINT8_BITFIELD(f0, f1, f2, f3, f4, f5, f6, f7) \
static uint64_t SkEndianSwap64(uint64_t value)
static uint16_t SkEndianSwap16(uint16_t value)
static void SkEndianSwap64s(uint64_t array[], int count)
static void SkEndianSwap16s(uint16_t array[], int count)
static void SkEndianSwap32s(uint32_t array[], int count)
static constexpr uint32_t SkEndianSwap32(uint32_t value)
static const uint16_t value
static const uint32_t value
static const uint64_t value