fix: missing prefix LTTNG_UST_ for FLOAT_WORD_ORDER on FreeBSD
[lttng-ust.git] / include / lttng / ust-endian.h
1 /*
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright (C) 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5 */
6
7 /*
8 * This header defines the following endian macros based on the current
9 * platform endian headers:
10 *
11 * BYTE_ORDER this macro shall have a value equal to one
12 * of the *_ENDIAN macros in this header.
13 * FLOAT_WORD_ORDER this macro shall have a value equal to one
14 * of the *_ENDIAN macros in this header.
15 * LITTLE_ENDIAN if BYTE_ORDER == LITTLE_ENDIAN, the host
16 * byte order is from least significant to
17 * most significant.
18 * BIG_ENDIAN if BYTE_ORDER == BIG_ENDIAN, the host byte
19 * order is from most significant to least
20 * significant.
21 *
22 * Direct byte swapping interfaces:
23 *
24 * uint16_t bswap_16(uint16_t x); (* swap bytes 16-bit word *)
25 * uint32_t bswap_32(uint32_t x); (* swap bytes 32-bit word *)
26 * uint64_t bswap_64(uint32_t x); (* swap bytes 64-bit word *)
27 */
28
29 #ifndef _LTTNG_UST_ENDIAN_H
30 #define _LTTNG_UST_ENDIAN_H
31
32 #if (defined(__linux__) || defined(__CYGWIN__))
33 #include <endian.h>
34 #include <byteswap.h>
35
36 #define lttng_ust_bswap_16(x) bswap_16(x)
37 #define lttng_ust_bswap_32(x) bswap_32(x)
38 #define lttng_ust_bswap_64(x) bswap_64(x)
39
40 #define LTTNG_UST_BYTE_ORDER __BYTE_ORDER
41 #define LTTNG_UST_LITTLE_ENDIAN __LITTLE_ENDIAN
42 #define LTTNG_UST_BIG_ENDIAN __BIG_ENDIAN
43
44 #ifdef __FLOAT_WORD_ORDER
45 #define LTTNG_UST_FLOAT_WORD_ORDER __FLOAT_WORD_ORDER
46 #else /* __FLOAT_WORD_ORDER */
47 #define LTTNG_UST_FLOAT_WORD_ORDER __BYTE_ORDER
48 #endif /* __FLOAT_WORD_ORDER */
49
50 #elif defined(__FreeBSD__)
51
52 #include <sys/endian.h>
53
54 #define lttng_ust_bswap_16(x) bswap16(x)
55 #define lttng_ust_bswap_32(x) bswap32(x)
56 #define lttng_ust_bswap_64(x) bswap64(x)
57
58 #define LTTNG_UST_BYTE_ORDER BYTE_ORDER
59 #define LTTNG_UST_LITTLE_ENDIAN LITTLE_ENDIAN
60 #define LTTNG_UST_BIG_ENDIAN BIG_ENDIAN
61 #define LTTNG_UST_FLOAT_WORD_ORDER BYTE_ORDER
62
63 #else
64 #error "Please add support for your OS."
65 #endif
66
67 #endif /* _LTTNG_UST_ENDIAN_H */
This page took 0.029424 seconds and 4 git commands to generate.