summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2022-07-14 18:39:47 +0700
committerhathach <[email protected]>2022-07-14 18:39:47 +0700
commit7e4c0f64cd32ee0c73da37703dda2f83ed760132 (patch)
tree3ed2212ab6057783b3d60672f6d1ff688dc62064
parent4bd47bcb99eef7a71ba2d45842af43e6269c30d4 (diff)
abtract attribute fallthrough
-rw-r--r--src/common/tusb_compiler.h10
-rw-r--r--src/host/usbh.c4
2 files changed, 11 insertions, 3 deletions
diff --git a/src/common/tusb_compiler.h b/src/common/tusb_compiler.h
index ae00f4e75..2c30daf6f 100644
--- a/src/common/tusb_compiler.h
+++ b/src/common/tusb_compiler.h
@@ -131,6 +131,12 @@
#define TU_ATTR_BIT_FIELD_ORDER_BEGIN
#define TU_ATTR_BIT_FIELD_ORDER_END
+ #if __has_attribute(__fallthrough__)
+ #define TU_ATTR_FALLTHROUGH __attribute__((fallthrough))
+ #else
+ #define TU_ATTR_FALLTHROUGH do {} while (0) /* fallthrough */
+ #endif
+
// Endian conversion use well-known host to network (big endian) naming
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define TU_BYTE_ORDER TU_LITTLE_ENDIAN
@@ -156,6 +162,7 @@
#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))
+ #define TU_ATTR_FALLTHROUGH __attribute__((fallthrough))
#define TU_ATTR_PACKED_BEGIN
#define TU_ATTR_PACKED_END
@@ -182,6 +189,7 @@
#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
+ #define TU_ATTR_FALLTHROUGH __attribute__((fallthrough))
#define TU_ATTR_PACKED_BEGIN
#define TU_ATTR_PACKED_END
@@ -207,6 +215,7 @@
#define TU_ATTR_DEPRECATED(mess)
#define TU_ATTR_UNUSED
#define TU_ATTR_USED
+ #define TU_ATTR_FALLTHROUGH do {} while (0) /* fallthrough */
#define TU_ATTR_PACKED_BEGIN _Pragma("pack")
#define TU_ATTR_PACKED_END _Pragma("packoption")
@@ -227,6 +236,7 @@
#error "Compiler attribute porting is required"
#endif
+
#if (TU_BYTE_ORDER == TU_LITTLE_ENDIAN)
#define tu_htons(u16) (TU_BSWAP16(u16))
diff --git a/src/host/usbh.c b/src/host/usbh.c
index 26351d16a..9d618db92 100644
--- a/src/host/usbh.c
+++ b/src/host/usbh.c
@@ -655,9 +655,7 @@ static bool usbh_control_xfer_cb (uint8_t dev_addr, uint8_t ep_addr, xfer_result
TU_ASSERT( hcd_edpt_xfer(rhport, dev_addr, tu_edpt_addr(0, request->bmRequestType_bit.direction), _ctrl_xfer.buffer, request->wLength) );
return true;
}
-#if __GNUC__ >= 7
- __attribute__((fallthrough));
-#endif
+ TU_ATTR_FALLTHROUGH;
case CONTROL_STAGE_DATA:
if (request->wLength)