aboutsummaryrefslogtreecommitdiff
path: root/contrib/lib9p/apple_endian.h
blob: d061b643b8f2cc0efdf7d612f97c166db154ea7f (plain) (blame)
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
#ifndef _APPLE_ENDIAN_H
#define _APPLE_ENDIAN_H

/*
 * Shims to make Apple's endian headers and macros compatible
 * with <sys/endian.h> (which is awful).
 */

# include <libkern/OSByteOrder.h>

# define _LITTLE_ENDIAN 0x12345678
# define _BIG_ENDIAN 0x87654321

# ifdef __LITTLE_ENDIAN__
#  define _BYTE_ORDER _LITTLE_ENDIAN
# endif
# ifdef __BIG_ENDIAN__
#  define _BYTE_ORDER _BIG_ENDIAN
# endif

# define htole32(x)	OSSwapHostToLittleInt32(x)
# define le32toh(x)	OSSwapLittleToHostInt32(x)

# define htobe32(x)	OSSwapHostToBigInt32(x)
# define be32toh(x)	OSSwapBigToHostInt32(x)

#endif /* _APPLE_ENDIAN_H */