diff options
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/tusb_common.h | 11 | ||||
| -rw-r--r-- | src/common/tusb_compiler.h | 9 |
2 files changed, 5 insertions, 15 deletions
diff --git a/src/common/tusb_common.h b/src/common/tusb_common.h index 75087f541..7c5f11dc2 100644 --- a/src/common/tusb_common.h +++ b/src/common/tusb_common.h @@ -61,12 +61,6 @@ #define TU_BIT_CLEAR(x, n) ( (x) & (~TU_BIT(n)) ) ///< clear n-th bit of x
#define TU_BIT_TEST(x, n) ( ((x) & TU_BIT(n)) ? true : false ) ///< check if n-th bit of x is 1
-//------------- Endian Conversion -------------//
-#define ENDIAN_BE(u32) \
- (uint32_t) ( (((u32) & 0xFF) << 24) | (((u32) & 0xFF00) << 8) | (((u32) >> 8) & 0xFF00) | (((u32) >> 24) & 0xFF) )
-
-#define ENDIAN_BE16(le16) ((uint16_t) ((U16_LOW_U8(le16) << 8) | U16_HIGH_U8(le16)) )
-
// for declaration of reserved field, make use of _TU_COUNTER_
#define TU_RESERVED XSTRING_CONCAT_(reserved, _TU_COUNTER_)
@@ -92,11 +86,6 @@ //--------------------------------------------------------------------+
// INLINE FUNCTION
//--------------------------------------------------------------------+
-#ifndef __n2be_16 // TODO clean up
-#define __n2be_16(u16) ((uint16_t) ((U16_LOW_U8(u16) << 8) | U16_HIGH_U8(u16)) )
-#define __be2n_16(u16) __n2be_16(u16)
-#endif
-
#define tu_memclr(buffer, size) memset((buffer), 0, (size))
#define tu_varclr(_var) tu_memclr(_var, sizeof(*(_var)))
diff --git a/src/common/tusb_compiler.h b/src/common/tusb_compiler.h index 3ed8e1af7..9536873cf 100644 --- a/src/common/tusb_compiler.h +++ b/src/common/tusb_compiler.h @@ -62,11 +62,12 @@ #define ATTR_UNUSED __attribute__ ((unused)) // Function/Variable is meant to be possibly unused
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
- #define __n2be(x) __builtin_bswap32(x) ///< built-in function to convert 32-bit from native to Big Endian
- #define __be2n(x) __n2be(x) ///< built-in function to convert 32-bit from Big Endian to native
+ // Endian conversion use well-known host to network (big endian) naming
+ #define tu_htonl(x) __builtin_bswap32(x)
+ #define tu_ntohl(x) tu_htonl(x)
- #define __n2be_16(u16) __builtin_bswap16(u16)
- #define __be2n_16(u16) __n2be_16(u16)
+ #define tu_htons(u16) __builtin_bswap16(u16)
+ #define tu_ntohs(u16) tu_htons(u16)
#endif
#else
|
