]> git.saurik.com Git - redis.git/blob - src/endian.h
ziplist.c endianess fixes, chapter 4.
[redis.git] / src / endian.h
1 #ifndef __ENDIAN_H
2 #define __ENDIAN_H
3
4 void memrev16(void *p);
5 void memrev32(void *p);
6 void memrev64(void *p);
7 uint16_t intrev16(uint16_t v);
8 uint32_t intrev32(uint32_t v);
9 uint64_t intrev64(uint64_t v);
10
11 /* variants of the function doing the actual convertion only if the target
12 * host is big endian */
13 #if (BYTE_ORDER == LITTLE_ENDIAN)
14 #define memrev16ifbe(p)
15 #define memrev32ifbe(p)
16 #define memrev64ifbe(p)
17 #define intrev16ifbe(v) (v)
18 #define intrev32ifbe(v) (v)
19 #define intrev64ifbe(v) (v)
20 #else
21 #define memrev16ifbe(p) memrev16(p)
22 #define memrev32ifbe(p) memrev32(p)
23 #define memrev64ifbe(p) memrev64(p)
24 #define intrev16ifbe(v) intrev16(v)
25 #define intrev32ifbe(v) intrev32(v)
26 #define intrev64ifbe(v) intrev64(v)
27 #endif
28
29 #endif