Commit | Line | Data |
---|---|---|
2ae57758 | 1 | /* |
c0c0989a | 2 | * SPDX-License-Identifier: MIT |
2ae57758 | 3 | * |
c0c0989a | 4 | * Copyright (C) 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
2ae57758 MD |
5 | * |
6 | * endian.h compatibility layer. | |
2ae57758 MD |
7 | */ |
8 | ||
c0c0989a MJ |
9 | #ifndef _LTTNG_UST_ENDIAN_H |
10 | #define _LTTNG_UST_ENDIAN_H | |
11 | ||
2928fe5a | 12 | #if (defined(__linux__) || defined(__CYGWIN__)) |
2ae57758 | 13 | #include <endian.h> |
3208818b | 14 | #include <byteswap.h> |
75181c4b | 15 | #elif defined(__FreeBSD__) |
3208818b MJ |
16 | #include <sys/endian.h> |
17 | #define bswap_16(x) bswap16(x) | |
18 | #define bswap_32(x) bswap32(x) | |
19 | #define bswap_64(x) bswap64(x) | |
2ae57758 | 20 | #else |
cc300254 | 21 | #error "Please add support for your OS." |
2ae57758 MD |
22 | #endif |
23 | ||
484fc193 MD |
24 | /* |
25 | * BYTE_ORDER, LITTLE_ENDIAN, and BIG_ENDIAN are only defined on Linux | |
26 | * if __USE_BSD is defined. Force their definition. | |
27 | */ | |
28 | #ifndef BYTE_ORDER | |
29 | #define BYTE_ORDER __BYTE_ORDER | |
30 | #endif | |
31 | ||
32 | #ifndef LITTLE_ENDIAN | |
33 | #define LITTLE_ENDIAN __LITTLE_ENDIAN | |
34 | #endif | |
35 | ||
36 | #ifndef BIG_ENDIAN | |
37 | #define BIG_ENDIAN __BIG_ENDIAN | |
38 | #endif | |
39 | ||
ad496c21 MD |
40 | #ifndef FLOAT_WORD_ORDER |
41 | #ifdef __FLOAT_WORD_ORDER | |
42 | #define FLOAT_WORD_ORDER __FLOAT_WORD_ORDER | |
43 | #else /* __FLOAT_WORD_ORDER */ | |
44 | #define FLOAT_WORD_ORDER BYTE_ORDER | |
45 | #endif /* __FLOAT_WORD_ORDER */ | |
46 | #endif /* FLOAT_WORD_ORDER */ | |
47 | ||
2ae57758 | 48 | #endif /* _LTTNG_UST_ENDIAN_H */ |