summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorMengsk <[email protected]>2020-05-08 13:29:33 +0200
committerMengsk <[email protected]>2020-05-08 13:29:33 +0200
commitf02ad1d0dcbbad57ccb8308d09843b8f688bcceb (patch)
treec7ab5ffd1c97f696e4aa458499b9f643e0092a70 /src/common
parente6d946123c6855199603de2a578d35aea9bc0094 (diff)
Add IAR compiler attribute and endian support.
Diffstat (limited to 'src/common')
-rw-r--r--src/common/tusb_compiler.h21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/common/tusb_compiler.h b/src/common/tusb_compiler.h
index e403c749b..6f6aa3c39 100644
--- a/src/common/tusb_compiler.h
+++ b/src/common/tusb_compiler.h
@@ -99,7 +99,26 @@
#define TU_BSWAP16(u16) (__builtin_bswap16(u16))
#define TU_BSWAP32(u32) (__builtin_bswap32(u32))
-#else
+#elif defined(__ICCARM__)
+ #define TU_ATTR_ALIGNED(Bytes) __attribute__ ((aligned(Bytes)))
+ #define TU_ATTR_SECTION(sec_name) __attribute__ ((section(#sec_name)))
+ #define TU_ATTR_PACKED __attribute__ ((packed))
+ #define TU_ATTR_PREPACKED
+ #define TU_ATTR_WEAK __attribute__ ((weak))
+ #define TU_ATTR_DEPRECATED(mess) __attribute__ ((deprecated(mess))) // warn if function with this attribute is used
+ #define TU_ATTR_UNUSED __attribute__ ((unused)) // Function/Variable is meant to be possibly unused
+ #define TU_ATTR_USED __attribute__ ((used)) // Function/Variable is meant to be used
+
+ // Endian conversion use well-known host to network (big endian) naming
+ #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+ #define TU_BYTE_ORDER TU_LITTLE_ENDIAN
+ #else
+ #define TU_BYTE_ORDER TU_BIG_ENDIAN
+ #endif
+
+ #define TU_BSWAP16(u16) (__iar_builtin_REV16(u16))
+ #define TU_BSWAP32(u32) (__iar_builtin_REV(u32))
+#else
#error "Compiler attribute porting is required"
#endif