summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNathan Conrad <[email protected]>2019-09-16 11:27:05 -0400
committerNathan Conrad <[email protected]>2019-09-16 11:27:05 -0400
commitdfe92542e63af0032c5f9b0fcd14a5f5971f78fe (patch)
tree0aaa7d0f13b93af3c9284c35f0bf85a3763d3aee /src
parent889c17a442fead48826bf4241f05539cef44bf57 (diff)
Change inline functions to macros, and make all parameter names uniform.
Diffstat (limited to 'src')
-rw-r--r--src/common/tusb_compiler.h58
1 files changed, 23 insertions, 35 deletions
diff --git a/src/common/tusb_compiler.h b/src/common/tusb_compiler.h
index df0326afd..58732b871 100644
--- a/src/common/tusb_compiler.h
+++ b/src/common/tusb_compiler.h
@@ -75,17 +75,8 @@
#define TU_BYTE_ORDER TU_BIG_ENDIAN
#endif
- static inline uint16_t tu_bswap16(uint16_t u16)
- {
- return __builtin_bswap16(u16);
- }
-
- static inline uint32_t tu_bswap32(uint32_t u32)
- {
- return __builtin_bswap32(u32);
- }
-
- #define TU_BSWAP16
+#define TU_BSWAP16(u16) (__builtin_bswap16(u16))
+#define TU_BSWAP32(u32) (__builtin_bswap32(u32))
#elif defined(__TI_COMPILER_VERSION__)
#define TU_ATTR_ALIGNED(Bytes) __attribute__ ((aligned(Bytes)))
@@ -103,44 +94,41 @@
#define TU_BYTE_ORDER TU_BIG_ENDIAN
#endif
- static inline uint16_t tu_bswap16(uint16_t u16)
- {
- return __builtin_bswap16(u16);
- }
+ #define TU_BSWAP16(u16) (__builtin_bswap16(u16))
+ #define TU_BSWAP32(u32) (__builtin_bswap32(u32))
- static inline uint32_t tu_bswap32(uint32_t u32)
- {
- return __builtin_bswap32(u32);
- }
#else
#error "Compiler attribute porting is required"
#endif
#if (TU_BYTE_ORDER == TU_LITTLE_ENDIAN)
- #define tu_htonl(u32) tu_bswap32(u32)
- #define tu_ntohl(u32) tu_bswap32(u32)
- #define tu_htons(u16) tu_bswap16(u16)
- #define tu_ntohs(u16) tu_bswap16(u16)
+ #define tu_htons(u16) (TU_BSWAP16(u16))
+ #define tu_ntohs(u16) (TU_BSWAP16(u16))
+
+ #define tu_htonl(u32) (TU_BSWAP32(u32))
+ #define tu_ntohl(u32) (TU_BSWAP32(u32))
- #define tu_htole16(x) (x)
- #define tu_le16toh(x) (x)
+ #define tu_htole16(u16) (u16)
+ #define tu_le16toh(u16) (u16)
- #define tu_htole32(x) (x)
- #define tu_le32toh(x) (x)
+ #define tu_htole32(u32) (u32)
+ #define tu_le32toh(u32) (u32)
#elif (TU_BYTE_ORDER == TU_BIG_ENDIAN)
- #define tu_htonl(u32) (x)
- #define tu_ntohl(u32) (x)
- #define tu_htons(u16) (x)
- #define tu_ntohs(u16) (x)
+ #define tu_htons(u16) (u16)
+ #define tu_ntohs(u16) (u16)
+
+ #define tu_htonl(u32) (u32)
+ #define tu_ntohl(u32) (u32)
+
- #define tu_htole16(x) tu_bswap16(u32)
- #define tu_le16toh(x) tu_bswap16(u32)
+ #define tu_htole16(u16) (tu_bswap16(u16))
+ #define tu_le16toh(u16) (tu_bswap16(u16))
- #define tu_htole32(x) tu_bswap32(u32)
- #define tu_le32toh(x) tu_bswap32(u32)
+ #define tu_htole32(u32) (tu_bswap32(u32))
+ #define tu_le32toh(u32) (tu_bswap32(u32))
#else
#error Byte order is undefined