libosmocore
1.10.0.58-6cd7a
Osmocom core library
endian.h
Go to the documentation of this file.
1
14
#pragma once
15
16
#if defined(__FreeBSD__)
17
#include <sys/endian.h>
18
#if BYTE_ORDER == LITTLE_ENDIAN
19
#define OSMO_IS_LITTLE_ENDIAN 1
20
#define OSMO_IS_BIG_ENDIAN 0
21
#elif BYTE_ORDER == BIG_ENDIAN
22
#define OSMO_IS_LITTLE_ENDIAN 0
23
#define OSMO_IS_BIG_ENDIAN 1
24
#else
25
#error "Unknown endian"
26
#endif
27
#elif defined(__APPLE__)
28
#include <machine/endian.h>
29
#if defined(__DARWIN_LITTLE_ENDIAN)
30
#define OSMO_IS_LITTLE_ENDIAN 1
31
#define OSMO_IS_BIG_ENDIAN 0
32
#elif defined(__DARWIN_BIG_ENDIAN)
33
#define OSMO_IS_LITTLE_ENDIAN 0
34
#define OSMO_IS_BIG_ENDIAN 1
35
#else
36
#error "Unknown endian"
37
#endif
38
#elif defined(__linux__)
39
#include <
endian.h
>
40
#if __BYTE_ORDER == __LITTLE_ENDIAN
41
#define OSMO_IS_LITTLE_ENDIAN 1
42
#define OSMO_IS_BIG_ENDIAN 0
43
#elif __BYTE_ORDER == __BIG_ENDIAN
44
#define OSMO_IS_LITTLE_ENDIAN 0
45
#define OSMO_IS_BIG_ENDIAN 1
46
#else
47
#error "Unknown endian"
48
#endif
49
#else
50
/* let's try to rely on the compiler. GCC and CLANG/LLVM seem
51
* to support this ... */
52
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
53
#define OSMO_IS_LITTLE_ENDIAN 1
54
#define OSMO_IS_BIG_ENDIAN 0
55
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
56
#define OSMO_IS_LITTLE_ENDIAN 0
57
#define OSMO_IS_BIG_ENDIAN 1
58
#else
59
#error "Unknown endian"
60
#endif
61
#endif
62
endian.h
GNU and FreeBSD have various ways to express the endianness but none of them is similar enough.
include
osmocom
core
endian.h
Generated by
1.9.4