Commit 3715a540c49335532fb0f75f5b18bc9e269f4471
Committed by
Tom Rini
1 parent
c989166037
Exists in
v2017.01-smarct4x
and in
25 other branches
compiler.h: use system endian macros on OpenBSD
The u-boot endian macros map directly to system endian macros on OpenBSD. Signed-off-by: Jonathan Gray <jsg@jsg.id.au>
Showing 1 changed file with 17 additions and 2 deletions Side-by-side Diff
include/compiler.h
... | ... | @@ -15,7 +15,7 @@ |
15 | 15 | defined(__sun__) || \ |
16 | 16 | defined(__APPLE__) |
17 | 17 | # include <inttypes.h> |
18 | -#elif defined(__linux__) || defined(__WIN32__) || defined(__MINGW32__) | |
18 | +#elif defined(__linux__) || defined(__WIN32__) || defined(__MINGW32__) || defined(__OpenBSD__) | |
19 | 19 | # include <stdint.h> |
20 | 20 | #endif |
21 | 21 | |
... | ... | @@ -50,6 +50,8 @@ |
50 | 50 | #endif |
51 | 51 | #ifdef __FreeBSD__ |
52 | 52 | # include <sys/endian.h> /* htole32 and friends */ |
53 | +#elif defined(__OpenBSD__) | |
54 | +# include <endian.h> | |
53 | 55 | #endif |
54 | 56 | |
55 | 57 | #include <time.h> |
... | ... | @@ -82,7 +84,20 @@ |
82 | 84 | # define uswap_64(x) _uswap_64(x, ) |
83 | 85 | #endif |
84 | 86 | |
85 | -#if __BYTE_ORDER == __LITTLE_ENDIAN | |
87 | +#if defined(__OpenBSD__) | |
88 | +#define cpu_to_le16(x) htole16(x) | |
89 | +#define cpu_to_le32(x) htole32(x) | |
90 | +#define cpu_to_le64(x) htole64(x) | |
91 | +#define le16_to_cpu(x) letoh16(x) | |
92 | +#define le32_to_cpu(x) letoh32(x) | |
93 | +#define le64_to_cpu(x) letoh64(x) | |
94 | +#define cpu_to_be16(x) htobe16(x) | |
95 | +#define cpu_to_be32(x) htobe32(x) | |
96 | +#define cpu_to_be64(x) htobe64(x) | |
97 | +#define be16_to_cpu(x) betoh16(x) | |
98 | +#define be32_to_cpu(x) betoh32(x) | |
99 | +#define be64_to_cpu(x) betoh64(x) | |
100 | +#elif __BYTE_ORDER == __LITTLE_ENDIAN | |
86 | 101 | # define cpu_to_le16(x) (x) |
87 | 102 | # define cpu_to_le32(x) (x) |
88 | 103 | # define cpu_to_le64(x) (x) |