41#if (defined(_MSC_VER) && !defined(__clang__)) || defined(__INTEL_COMPILER) || defined(__INTEL_LLVM_COMPILER)
53#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__INTEL_LLVM_COMPILER) && !defined(__clang__)
62#define pint_bswap16(x) _byteswap_ushort(x)
63#define pint_bswap32(x) _byteswap_ulong(x)
65#define pint_bswap64(x) _byteswap_uint64(x)
66#elif defined(__INTEL_COMPILER)
72#define pint_bswap16(x) _bswap16(x)
73#define pint_bswap32(x) _bswap32(x)
74#define pint_bswap64(x) _bswap64(x)
90#define pint_bswap16(x) __builtin_bswap16(x)
91#define pint_bswap32(x) __builtin_bswap32(x)
92#define pint_bswap64(x) __builtin_bswap64(x)
95static inline uint16_t pntoh16(
const void *p)
98 memcpy(&ret, p,
sizeof(ret));
99#if G_BYTE_ORDER == G_LITTLE_ENDIAN
100 ret = pint_bswap16(ret);
105static inline uint32_t pntoh32(
const void *p)
108 memcpy(&ret, p,
sizeof(ret));
109#if G_BYTE_ORDER == G_LITTLE_ENDIAN
110 ret = pint_bswap32(ret);
115static inline uint64_t pntoh64(
const void *p)
118 memcpy(&ret, p,
sizeof(ret));
119#if G_BYTE_ORDER == G_LITTLE_ENDIAN
120 ret = pint_bswap64(ret);
125static inline uint16_t pletoh16(
const void *p)
128 memcpy(&ret, p,
sizeof(ret));
129#if G_BYTE_ORDER == G_BIG_ENDIAN
130 ret = pint_bswap16(ret);
135static inline uint32_t pletoh32(
const void *p)
138 memcpy(&ret, p,
sizeof(ret));
139#if G_BYTE_ORDER == G_BIG_ENDIAN
140 ret = pint_bswap32(ret);
145static inline uint64_t pletoh64(
const void *p)
148 memcpy(&ret, p,
sizeof(ret));
149#if G_BYTE_ORDER == G_BIG_ENDIAN
150 ret = pint_bswap64(ret);
155static inline void phton16(uint8_t *p, uint16_t v)
157#if G_BYTE_ORDER == G_LITTLE_ENDIAN
160 memcpy(p, &v,
sizeof(v));
163static inline void phton32(uint8_t *p, uint32_t v)
165#if G_BYTE_ORDER == G_LITTLE_ENDIAN
168 memcpy(p, &v,
sizeof(v));
171static inline void phton64(uint8_t *p, uint64_t v) {
172#if G_BYTE_ORDER == G_LITTLE_ENDIAN
175 memcpy(p, &v,
sizeof(v));
178static inline void phtole32(uint8_t *p, uint32_t v)
180#if G_BYTE_ORDER == G_BIG_ENDIAN
183 memcpy(p, &v,
sizeof(v));
186static inline void phtole64(uint8_t *p, uint64_t v) {
187#if G_BYTE_ORDER == G_BIG_ENDIAN
190 memcpy(p, &v,
sizeof(v));
195static inline uint16_t pntoh16(
const void *p)
197 return (uint16_t)*((
const uint8_t *)(p)+0)<<8|
198 (uint16_t)*((
const uint8_t *)(p)+1)<<0;
201static inline uint32_t pntoh32(
const void *p)
203 return (uint32_t)*((
const uint8_t *)(p)+0)<<24|
204 (uint32_t)*((
const uint8_t *)(p)+1)<<16|
205 (uint32_t)*((
const uint8_t *)(p)+2)<<8|
206 (uint32_t)*((
const uint8_t *)(p)+3)<<0;
209static inline uint64_t pntoh64(
const void *p)
211 return (uint64_t)*((
const uint8_t *)(p)+0)<<56|
212 (uint64_t)*((
const uint8_t *)(p)+1)<<48|
213 (uint64_t)*((
const uint8_t *)(p)+2)<<40|
214 (uint64_t)*((
const uint8_t *)(p)+3)<<32|
215 (uint64_t)*((
const uint8_t *)(p)+4)<<24|
216 (uint64_t)*((
const uint8_t *)(p)+5)<<16|
217 (uint64_t)*((
const uint8_t *)(p)+6)<<8|
218 (uint64_t)*((
const uint8_t *)(p)+7)<<0;
221static inline uint16_t pletoh16(
const void *p)
223 return (uint16_t)*((
const uint8_t *)(p)+1)<<8|
224 (uint16_t)*((
const uint8_t *)(p)+0)<<0;
227static inline uint32_t pletoh32(
const void *p)
229 return (uint32_t)*((
const uint8_t *)(p)+3)<<24|
230 (uint32_t)*((
const uint8_t *)(p)+2)<<16|
231 (uint32_t)*((
const uint8_t *)(p)+1)<<8|
232 (uint32_t)*((
const uint8_t *)(p)+0)<<0;
235static inline uint64_t pletoh64(
const void *p)
237 return (uint64_t)*((
const uint8_t *)(p)+7)<<56|
238 (uint64_t)*((
const uint8_t *)(p)+6)<<48|
239 (uint64_t)*((
const uint8_t *)(p)+5)<<40|
240 (uint64_t)*((
const uint8_t *)(p)+4)<<32|
241 (uint64_t)*((
const uint8_t *)(p)+3)<<24|
242 (uint64_t)*((
const uint8_t *)(p)+2)<<16|
243 (uint64_t)*((
const uint8_t *)(p)+1)<<8|
244 (uint64_t)*((
const uint8_t *)(p)+0)<<0;
251static inline void phton16(uint8_t *p, uint16_t v)
253 p[0] = (uint8_t)(v >> 8);
254 p[1] = (uint8_t)(v >> 0);
257static inline void phton32(uint8_t *p, uint32_t v)
259 p[0] = (uint8_t)(v >> 24);
260 p[1] = (uint8_t)(v >> 16);
261 p[2] = (uint8_t)(v >> 8);
262 p[3] = (uint8_t)(v >> 0);
265static inline void phton64(uint8_t *p, uint64_t v) {
266 p[0] = (uint8_t)(v >> 56);
267 p[1] = (uint8_t)(v >> 48);
268 p[2] = (uint8_t)(v >> 40);
269 p[3] = (uint8_t)(v >> 32);
270 p[4] = (uint8_t)(v >> 24);
271 p[5] = (uint8_t)(v >> 16);
272 p[6] = (uint8_t)(v >> 8);
273 p[7] = (uint8_t)(v >> 0);
276static inline void phtole32(uint8_t *p, uint32_t v) {
277 p[0] = (uint8_t)(v >> 0);
278 p[1] = (uint8_t)(v >> 8);
279 p[2] = (uint8_t)(v >> 16);
280 p[3] = (uint8_t)(v >> 24);
283static inline void phtole64(uint8_t *p, uint64_t v) {
284 p[0] = (uint8_t)(v >> 0);
285 p[1] = (uint8_t)(v >> 8);
286 p[2] = (uint8_t)(v >> 16);
287 p[3] = (uint8_t)(v >> 24);
288 p[4] = (uint8_t)(v >> 32);
289 p[5] = (uint8_t)(v >> 40);
290 p[6] = (uint8_t)(v >> 48);
291 p[7] = (uint8_t)(v >> 56);
295static inline uint32_t pntoh24(
const void *p)
297 return (uint32_t)*((
const uint8_t *)(p)+0)<<16|
298 (uint32_t)*((
const uint8_t *)(p)+1)<<8|
299 (uint32_t)*((
const uint8_t *)(p)+2)<<0;
302static inline uint64_t pntoh40(
const void *p)
304 return (uint64_t)*((
const uint8_t *)(p)+0)<<32|
305 (uint64_t)*((
const uint8_t *)(p)+1)<<24|
306 (uint64_t)*((
const uint8_t *)(p)+2)<<16|
307 (uint64_t)*((
const uint8_t *)(p)+3)<<8|
308 (uint64_t)*((
const uint8_t *)(p)+4)<<0;
311static inline uint64_t pntoh48(
const void *p)
313 return (uint64_t)*((
const uint8_t *)(p)+0)<<40|
314 (uint64_t)*((
const uint8_t *)(p)+1)<<32|
315 (uint64_t)*((
const uint8_t *)(p)+2)<<24|
316 (uint64_t)*((
const uint8_t *)(p)+3)<<16|
317 (uint64_t)*((
const uint8_t *)(p)+4)<<8|
318 (uint64_t)*((
const uint8_t *)(p)+5)<<0;
321static inline uint64_t pntoh56(
const void *p)
323 return (uint64_t)*((
const uint8_t *)(p)+0)<<48|
324 (uint64_t)*((
const uint8_t *)(p)+1)<<40|
325 (uint64_t)*((
const uint8_t *)(p)+2)<<32|
326 (uint64_t)*((
const uint8_t *)(p)+3)<<24|
327 (uint64_t)*((
const uint8_t *)(p)+4)<<16|
328 (uint64_t)*((
const uint8_t *)(p)+5)<<8|
329 (uint64_t)*((
const uint8_t *)(p)+6)<<0;
332static inline uint32_t pletoh24(
const void *p)
334 return (uint32_t)*((
const uint8_t *)(p)+2)<<16|
335 (uint32_t)*((
const uint8_t *)(p)+1)<<8|
336 (uint32_t)*((
const uint8_t *)(p)+0)<<0;
339static inline uint64_t pletoh40(
const void *p)
341 return (uint64_t)*((
const uint8_t *)(p)+4)<<32|
342 (uint64_t)*((
const uint8_t *)(p)+3)<<24|
343 (uint64_t)*((
const uint8_t *)(p)+2)<<16|
344 (uint64_t)*((
const uint8_t *)(p)+1)<<8|
345 (uint64_t)*((
const uint8_t *)(p)+0)<<0;
348static inline uint64_t pletoh48(
const void *p)
350 return (uint64_t)*((
const uint8_t *)(p)+5)<<40|
351 (uint64_t)*((
const uint8_t *)(p)+4)<<32|
352 (uint64_t)*((
const uint8_t *)(p)+3)<<24|
353 (uint64_t)*((
const uint8_t *)(p)+2)<<16|
354 (uint64_t)*((
const uint8_t *)(p)+1)<<8|
355 (uint64_t)*((
const uint8_t *)(p)+0)<<0;
358static inline uint64_t pletoh56(
const void *p)
360 return (uint64_t)*((
const uint8_t *)(p)+6)<<48|
361 (uint64_t)*((
const uint8_t *)(p)+5)<<40|
362 (uint64_t)*((
const uint8_t *)(p)+4)<<32|
363 (uint64_t)*((
const uint8_t *)(p)+3)<<24|
364 (uint64_t)*((
const uint8_t *)(p)+2)<<16|
365 (uint64_t)*((
const uint8_t *)(p)+1)<<8|
366 (uint64_t)*((
const uint8_t *)(p)+0)<<0;