Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1 | From 626fe5e043de25e970ebdf061b88c646fa689113 Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Tue, 19 Sep 2017 10:09:31 -0700 |
| 4 | Subject: [PATCH 2/2] use __builtin_bswap16 when building with clang |
| 5 | |
| 6 | clang pretends to be gcc 4.2.0 and therefore the code does |
| 7 | not use __builtin_bswap16 but tries to synthesize it |
| 8 | |
| 9 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 10 | --- |
| 11 | Upstream-Status: Submitted |
| 12 | include/flatbuffers/base.h | 2 +- |
| 13 | 1 file changed, 1 insertion(+), 1 deletion(-) |
| 14 | |
| 15 | diff --git a/include/flatbuffers/base.h b/include/flatbuffers/base.h |
| 16 | index c73fb2d..13e8fac 100644 |
| 17 | --- a/include/flatbuffers/base.h |
| 18 | +++ b/include/flatbuffers/base.h |
| 19 | @@ -156,7 +156,7 @@ template<typename T> T EndianSwap(T t) { |
| 20 | #define FLATBUFFERS_BYTESWAP32 _byteswap_ulong |
| 21 | #define FLATBUFFERS_BYTESWAP64 _byteswap_uint64 |
| 22 | #else |
| 23 | - #if defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ < 408 |
| 24 | + #if defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ < 408 && !defined(__clang__) |
| 25 | // __builtin_bswap16 was missing prior to GCC 4.8. |
| 26 | #define FLATBUFFERS_BYTESWAP16(x) \ |
| 27 | static_cast<uint16_t>(__builtin_bswap32(static_cast<uint32_t>(x) << 16)) |
| 28 | -- |
| 29 | 2.14.1 |
| 30 | |