Tracepoint API namespacing tracelog
[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>
75181c4b 35#elif defined(__FreeBSD__)
3208818b
MJ
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)
2ae57758 40#else
cc300254 41#error "Please add support for your OS."
2ae57758
MD
42#endif
43
484fc193
MD
44/*
45 * BYTE_ORDER, LITTLE_ENDIAN, and BIG_ENDIAN are only defined on Linux
46 * if __USE_BSD is defined. Force their definition.
47 */
48#ifndef BYTE_ORDER
49#define BYTE_ORDER __BYTE_ORDER
50#endif
51
52#ifndef LITTLE_ENDIAN
53#define LITTLE_ENDIAN __LITTLE_ENDIAN
54#endif
55
56#ifndef BIG_ENDIAN
57#define BIG_ENDIAN __BIG_ENDIAN
58#endif
59
ad496c21
MD
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 */
67
2ae57758 68#endif /* _LTTNG_UST_ENDIAN_H */
This page took 0.031764 seconds and 4 git commands to generate.