summaryrefslogtreecommitdiff
path: root/src/common/tusb_compiler.h
diff options
context:
space:
mode:
authorhathach <[email protected]>2021-07-22 16:48:18 +0700
committerhathach <[email protected]>2021-07-22 16:48:18 +0700
commitfa0936bf588c3942b7d2b92baed1693e73dbfdc1 (patch)
tree2038fc3b34d4c380ebd4cce856bc980b5240f636 /src/common/tusb_compiler.h
parent1c2bc47c078fb48379bb148840e9b9c88c0fa66f (diff)
parent4c0cce4b1df707aa1aeb5e861971b5b31e94a416 (diff)
Merge branch 'CCRX_Port' of https://github.com/Wini-Buh/tinyusb into Wini-Buh-CCRX_Port
Diffstat (limited to 'src/common/tusb_compiler.h')
-rw-r--r--src/common/tusb_compiler.h43
1 files changed, 39 insertions, 4 deletions
diff --git a/src/common/tusb_compiler.h b/src/common/tusb_compiler.h
index 0dd9ba016..6fdd08032 100644
--- a/src/common/tusb_compiler.h
+++ b/src/common/tusb_compiler.h
@@ -52,6 +52,8 @@
#define TU_VERIFY_STATIC _Static_assert
#elif defined (__cplusplus) && __cplusplus >= 201103L
#define TU_VERIFY_STATIC static_assert
+#elif defined(__CCRX__)
+ #define TU_VERIFY_STATIC(const_expr, _mess) typedef char TU_XSTRCAT(Line, __LINE__)[(const_expr) ? 1 : 0];
#else
#define TU_VERIFY_STATIC(const_expr, _mess) enum { TU_XSTRCAT(_verify_static_, _TU_COUNTER_) = 1/(!!(const_expr)) }
#endif
@@ -77,6 +79,12 @@
#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
+ #define TU_PACK_STRUCT_BEGIN
+ #define TU_PACK_STRUCT_END
+
+ #define TU_BIT_FIELD_ORDER_BEGIN
+ #define TU_BIT_FIELD_ORDER_END
+
// Endian conversion use well-known host to network (big endian) naming
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define TU_BYTE_ORDER TU_LITTLE_ENDIAN
@@ -131,6 +139,33 @@
#define TU_BSWAP16(u16) (__iar_builtin_REV16(u16))
#define TU_BSWAP32(u32) (__iar_builtin_REV(u32))
+
+#elif defined(__CCRX__)
+ #define TU_ATTR_ALIGNED(Bytes)
+ #define TU_ATTR_SECTION(sec_name)
+ #define TU_ATTR_PACKED
+ #define TU_ATTR_WEAK
+ #define TU_ATTR_ALWAYS_INLINE
+ #define TU_ATTR_DEPRECATED(mess)
+ #define TU_ATTR_UNUSED
+ #define TU_ATTR_USED
+
+ #define TU_PACK_STRUCT_BEGIN _Pragma("pack")
+ #define TU_PACK_STRUCT_END _Pragma("packoption")
+
+ #define TU_BIT_FIELD_ORDER_BEGIN _Pragma("bit_order right")
+ #define TU_BIT_FIELD_ORDER_END _Pragma("bit_order")
+
+ // Endian conversion use well-known host to network (big endian) naming
+ #if defined(__LIT)
+ #define TU_BYTE_ORDER TU_LITTLE_ENDIAN
+ #else
+ #define TU_BYTE_ORDER TU_BIG_ENDIAN
+ #endif
+
+ #define TU_BSWAP16(u16) ((unsigned short)_builtin_revw((unsigned long)u16))
+ #define TU_BSWAP32(u32) (_builtin_revl(u32))
+
#else
#error "Compiler attribute porting is required"
#endif
@@ -157,11 +192,11 @@
#define tu_htonl(u32) (u32)
#define tu_ntohl(u32) (u32)
- #define tu_htole16(u16) (tu_bswap16(u16))
- #define tu_le16toh(u16) (tu_bswap16(u16))
+ #define tu_htole16(u16) (TU_BSWAP16(u16))
+ #define tu_le16toh(u16) (TU_BSWAP16(u16))
- #define tu_htole32(u32) (tu_bswap32(u32))
- #define tu_le32toh(u32) (tu_bswap32(u32))
+ #define tu_htole32(u32) (TU_BSWAP32(u32))
+ #define tu_le32toh(u32) (TU_BSWAP32(u32))
#else
#error Byte order is undefined