fix: missing prefix LTTNG_UST_ for FLOAT_WORD_ORDER on FreeBSD
[lttng-ust.git] / include / lttng / ust-endian.h
CommitLineData
2ae57758 1/*
c0c0989a 2 * SPDX-License-Identifier: MIT
2ae57758 3 *
c0c0989a 4 * Copyright (C) 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
06e646e0
MJ
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:
2ae57758 23 *
06e646e0
MJ
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 *)
2ae57758
MD
27 */
28
c0c0989a
MJ
29#ifndef _LTTNG_UST_ENDIAN_H
30#define _LTTNG_UST_ENDIAN_H
31
2928fe5a 32#if (defined(__linux__) || defined(__CYGWIN__))
2ae57758 33#include <endian.h>
3208818b 34#include <byteswap.h>
2ae57758 35
baa8acf3
MJ
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)
484fc193 39
baa8acf3
MJ
40#define LTTNG_UST_BYTE_ORDER __BYTE_ORDER
41#define LTTNG_UST_LITTLE_ENDIAN __LITTLE_ENDIAN
42#define LTTNG_UST_BIG_ENDIAN __BIG_ENDIAN
484fc193 43
ad496c21 44#ifdef __FLOAT_WORD_ORDER
baa8acf3 45#define LTTNG_UST_FLOAT_WORD_ORDER __FLOAT_WORD_ORDER
ad496c21 46#else /* __FLOAT_WORD_ORDER */
baa8acf3 47#define LTTNG_UST_FLOAT_WORD_ORDER __BYTE_ORDER
ad496c21 48#endif /* __FLOAT_WORD_ORDER */
baa8acf3
MJ
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
c5a5ae4f 61#define LTTNG_UST_FLOAT_WORD_ORDER BYTE_ORDER
baa8acf3
MJ
62
63#else
64#error "Please add support for your OS."
65#endif
ad496c21 66
2ae57758 67#endif /* _LTTNG_UST_ENDIAN_H */
This page took 0.032039 seconds and 4 git commands to generate.