summaryrefslogtreecommitdiffstats
path: root/libs/cython_headers/endian-win.h
blob: 2525fa01d42114f83c4ff543894e453e19767091 (plain)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef ENDIAN_WIN_H_
#define ENDIAN_WIN_H_

#include "byteswap-win.h"

#define LITTLE_ENDIAN	1
#define BIG_ENDIAN	2
#define BYTE_ORDER	LITTLE_ENDIAN

static inline uint16_t htobe16(uint16_t v)
{
	if (BYTE_ORDER == LITTLE_ENDIAN)
		return bswap_16(v);
	return v;
}

static inline uint16_t htole16(uint16_t v)
{
	if (BYTE_ORDER == BIG_ENDIAN)
		return bswap_16(v);
	return v;
}

static inline uint16_t be16toh(uint16_t v)
{
	if (BYTE_ORDER == LITTLE_ENDIAN)
		return bswap_16(v);
	return v;
}

static inline uint16_t le16toh(uint16_t v)
{
	if (BYTE_ORDER == BIG_ENDIAN)
		return bswap_16(v);
	return v;
}

static inline uint32_t htobe32(uint32_t v)
{
	if (BYTE_ORDER == LITTLE_ENDIAN)
		return bswap_32(v);
	return v;
}

static inline uint32_t htole32(uint32_t v)
{
	if (BYTE_ORDER == BIG_ENDIAN)
		return bswap_32(v);
	return v;
}

static inline uint32_t be32toh(uint32_t v)
{
	if (BYTE_ORDER == LITTLE_ENDIAN)
		return bswap_32(v);
	return v;
}

static inline uint32_t le32toh(uint32_t v)
{
	if (BYTE_ORDER == BIG_ENDIAN)
		return bswap_32(v);
	return v;
}

#endif /* ENDIAN_WIN_H_ */
bues.ch cgit interface