-
Notifications
You must be signed in to change notification settings - Fork 0
/
endian_27aq18pth4y0m1zzesylkwjk5.h.in
37 lines (33 loc) · 1.19 KB
/
endian_27aq18pth4y0m1zzesylkwjk5.h.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* {NOTICE1}
* {NOTICE2}
*
* Copyright (c) 2017 Guenther Brunthaler. All rights reserved.
*
* This source file is free software.
* Distribution is permitted under the terms of the MIT license.*/
#ifndef HEADER_27AQ18PTH4Y0M1ZZESYLKWJK5_INCLUDED
#define HEADER_27AQ18PTH4Y0M1ZZESYLKWJK5_INCLUDED
#define WORDS_{END}ENDIAN 1
#define SWAP_BIG_LITTLE_ENDIANNESS(var) { \
unsigned i= 0, j= (unsigned)sizeof (var); \
unsigned char *bytes= (void *)&var; \
while (i < j) { \
unsigned char tmp= bytes[i]; \
bytes[i++]= bytes[--j]; \
bytes[j]= tmp; \
} \
}
#if WORDS_BIGENDIAN
#define TOGGLE_BIG_AND_NATIVE_ENDIANNESS(var) /**/
#define TOGGLE_LITTLE_AND_NATIVE_ENDIANNESS(var) \
SWAP_BIG_LITTLE_ENDIANNESS(var)
#elif WORDS_LITTLEENDIAN
#define TOGGLE_BIG_AND_NATIVE_ENDIANNESS(var) \
SWAP_BIG_LITTLE_ENDIANNESS(var)
#define TOGGLE_LITTLE_AND_NATIVE_ENDIANNESS(var) /**/
#elif WORDS_UNSUPPORTEDENDIAN
#error "The endianness of this platform is not supported!"
#else
#error "Endianness has not been determined yet!"
#endif
#endif /* !HEADER_27AQ18PTH4Y0M1ZZESYLKWJK5_INCLUDED */