2 * SPDX-License-Identifier: MIT
4 * Copyright (C) 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 * This header defines the following endian macros based on the current
9 * platform endian headers:
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
18 * BIG_ENDIAN if BYTE_ORDER == BIG_ENDIAN, the host byte
19 * order is from most significant to least
22 * Direct byte swapping interfaces:
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 *)
29 #ifndef _LTTNG_UST_ENDIAN_H
30 #define _LTTNG_UST_ENDIAN_H
32 #if (defined(__linux__) || defined(__CYGWIN__))
35 #elif defined(__FreeBSD__)
36 #include <sys/endian.h>
37 #define bswap_16(x) bswap16(x)
38 #define bswap_32(x) bswap32(x)
39 #define bswap_64(x) bswap64(x)
41 #error "Please add support for your OS."
45 * BYTE_ORDER, LITTLE_ENDIAN, and BIG_ENDIAN are only defined on Linux
46 * if __USE_BSD is defined. Force their definition.
49 #define BYTE_ORDER __BYTE_ORDER
53 #define LITTLE_ENDIAN __LITTLE_ENDIAN
57 #define BIG_ENDIAN __BIG_ENDIAN
60 #ifndef FLOAT_WORD_ORDER
61 #ifdef __FLOAT_WORD_ORDER
62 #define FLOAT_WORD_ORDER __FLOAT_WORD_ORDER
63 #else /* __FLOAT_WORD_ORDER */
64 #define FLOAT_WORD_ORDER BYTE_ORDER
65 #endif /* __FLOAT_WORD_ORDER */
66 #endif /* FLOAT_WORD_ORDER */
68 #endif /* _LTTNG_UST_ENDIAN_H */
This page took 0.044343 seconds and 5 git commands to generate.