diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/flatbuffers/base.h | 11 | ||||
-rw-r--r-- | include/flatbuffers/flatbuffers.h | 2 |
2 files changed, 11 insertions, 2 deletions
diff --git a/include/flatbuffers/base.h b/include/flatbuffers/base.h index ee8021fd..85dfe0ee 100644 --- a/include/flatbuffers/base.h +++ b/include/flatbuffers/base.h @@ -55,6 +55,10 @@ #include "flatbuffers/stl_emulation.h" +#if defined(__ICCARM__) +#include <intrinsics.h> +#endif + // Note the __clang__ check is needed, because clang presents itself // as an older GNUC compiler (4.2). // Clang 3.3 and later implement all of the ISO C++ 2011 standard. @@ -117,7 +121,7 @@ #define FLATBUFFERS_LITTLEENDIAN 0 #endif // __s390x__ #if !defined(FLATBUFFERS_LITTLEENDIAN) - #if defined(__GNUC__) || defined(__clang__) + #if defined(__GNUC__) || defined(__clang__) || defined(__ICCARM__) #if (defined(__BIG_ENDIAN__) || \ (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)) #define FLATBUFFERS_LITTLEENDIAN 0 @@ -303,6 +307,11 @@ template<typename T> T EndianSwap(T t) { #define FLATBUFFERS_BYTESWAP16 _byteswap_ushort #define FLATBUFFERS_BYTESWAP32 _byteswap_ulong #define FLATBUFFERS_BYTESWAP64 _byteswap_uint64 + #elif defined(__ICCARM__) + #define FLATBUFFERS_BYTESWAP16 __REV16 + #define FLATBUFFERS_BYTESWAP32 __REV + #define FLATBUFFERS_BYTESWAP64(x) \ + ((__REV(static_cast<uint32_t>(x >> 32U))) | (static_cast<uint64_t>(__REV(static_cast<uint32_t>(x)))) << 32U) #else #if defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ < 408 && !defined(__clang__) // __builtin_bswap16 was missing prior to GCC 4.8. diff --git a/include/flatbuffers/flatbuffers.h b/include/flatbuffers/flatbuffers.h index 83dd09de..6966cb0a 100644 --- a/include/flatbuffers/flatbuffers.h +++ b/include/flatbuffers/flatbuffers.h @@ -2475,7 +2475,7 @@ inline int LookupEnum(const char **names, const char *name) { #define FLATBUFFERS_STRUCT_END(name, size) \ __pragma(pack()) \ static_assert(sizeof(name) == size, "compiler breaks packing rules") -#elif defined(__GNUC__) || defined(__clang__) +#elif defined(__GNUC__) || defined(__clang__) || defined(__ICCARM__) #define FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(alignment) \ _Pragma("pack(1)") \ struct __attribute__((aligned(alignment))) |