diff options
author | Siarhei Fiedartsou <siarhei.fedartsou@gmail.com> | 2019-05-16 21:56:22 +0300 |
---|---|---|
committer | Wouter van Oortmerssen <aardappel@gmail.com> | 2019-05-16 11:56:22 -0700 |
commit | 8d86b5347fbeba85f11b7bf479334f6700feb455 (patch) | |
tree | bf31f82dd069721ad9f244febc6baa52697a327b /include | |
parent | 39bd667fd0a149c3bb428ccf35fa8c17fcafeccf (diff) | |
download | flatbuffers-8d86b5347fbeba85f11b7bf479334f6700feb455.tar.gz flatbuffers-8d86b5347fbeba85f11b7bf479334f6700feb455.tar.bz2 flatbuffers-8d86b5347fbeba85f11b7bf479334f6700feb455.zip |
Add support for IAR compiler (#5347)
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))) |