diff options
author | Chris Friedt <cfriedt@fb.com> | 2022-09-26 16:02:50 -0400 |
---|---|---|
committer | Jens Geyer <Jens-G@users.noreply.github.com> | 2022-10-25 22:20:47 +0200 |
commit | 0bc818f363a50282910fa19ae605689954239fcb (patch) | |
tree | 1a3a799181b8b97d792e55e4e08aadcf6e47148b | |
parent | 0a29a48e5ac01dd49cfcc52cfec09ac5bdc4ba7c (diff) | |
download | thrift-0bc818f363a50282910fa19ae605689954239fcb.tar.gz |
lib: cpp: TProtocol: support zephyr byteorder
Zephyr's byteorder is defined in
`<zephyr/sys/byteorder.h>`. However, the `bswap_xx`
macros are also defined there. They need to be `#undef`d
first when building for big-endian architectures, since
the Thrift byteorder macros are no-ops for little-endian
architectures.
Signed-off-by: Chris Friedt <cfriedt@fb.com>
-rw-r--r-- | lib/cpp/src/thrift/protocol/TProtocol.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/cpp/src/thrift/protocol/TProtocol.h b/lib/cpp/src/thrift/protocol/TProtocol.h index b691c4169..c6ff36049 100644 --- a/lib/cpp/src/thrift/protocol/TProtocol.h +++ b/lib/cpp/src/thrift/protocol/TProtocol.h @@ -86,6 +86,20 @@ static inline To bitwise_cast(From from) { #include <sys/param.h> #endif +#ifdef __ZEPHYR__ +# include <zephyr/sys/byteorder.h> + +# define __THRIFT_BYTE_ORDER __BYTE_ORDER__ +# define __THRIFT_LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__ +# define __THRIFT_BIG_ENDIAN __ORDER_BIG_ENDIAN__ + +# if __THRIFT_BYTE_ORDER == __THRIFT_BIG_ENDIAN +# undef bswap_64 +# undef bswap_32 +# undef bswap_16 +# endif +#endif + #ifndef __THRIFT_BYTE_ORDER # if defined(BYTE_ORDER) && defined(LITTLE_ENDIAN) && defined(BIG_ENDIAN) # define __THRIFT_BYTE_ORDER BYTE_ORDER |