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