File: endian_port.h

package info (click to toggle)
python-thriftpy 0.3.9%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 560 kB
  • sloc: python: 3,287; ansic: 30; makefile: 7
file content (42 lines) | stat: -rw-r--r-- 705 bytes parent folder | download | duplicates (2)
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
38
39
40
41
42

#if defined(__APPLE__)

#include <libkern/OSByteOrder.h>

#define htobe16(x) OSSwapHostToBigInt16(x)
#define htobe32(x) OSSwapHostToBigInt32(x)
#define htobe64(x) OSSwapHostToBigInt64(x)
#define be16toh(x) OSSwapBigToHostInt16(x)
#define be32toh(x) OSSwapBigToHostInt32(x)
#define be64toh(x) OSSwapBigToHostInt64(x)

#else

#include <endian.h>
#include <byteswap.h>

#ifndef htobe16
#define htobe16(x) bswap_16(x)
#endif

#ifndef htobe32
#define htobe32(x) bswap_32(x)
#endif

#ifndef htobe64
#define htobe64(x) bswap_64(x)
#endif

#ifndef be16toh
#define be16toh(x) bswap_16(x)
#endif

#ifndef be32toh
#define be32toh(x) bswap_32(x)
#endif

#ifndef be64toh
#define be64toh(x) bswap_64(x)
#endif

#endif