From 35d9299662e70b9415d7cad400009b0307cd19a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= Date: Tue, 15 Mar 2022 14:18:33 +0100 Subject: [PATCH 1/4] Fix inconsistent function signature in CDC.cpp USBAPI.h declares the return type of Serial_::baud() as `uint32_t` --- cores/arduino/USB/CDC.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/arduino/USB/CDC.cpp b/cores/arduino/USB/CDC.cpp index dea6bd2b..4b93cf91 100644 --- a/cores/arduino/USB/CDC.cpp +++ b/cores/arduino/USB/CDC.cpp @@ -336,7 +336,7 @@ int32_t Serial_::readBreak() { return ret; } -unsigned long Serial_::baud() { +uint32_t Serial_::baud() { return _usbLineInfo.dwDTERate; } From 43df67c4df1fc6b8df67eaa408bdfda5b6b4c890 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= Date: Tue, 15 Mar 2022 14:57:43 +0100 Subject: [PATCH 2/4] Fix inconsistent function signature in HardwareSerial.h This causes an override mismatch for UARTClass::begin(const uint32_t) in UARTClass.h when compiling with Clang --- cores/arduino/HardwareSerial.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/arduino/HardwareSerial.h b/cores/arduino/HardwareSerial.h index 5674e57a..8f1aba87 100644 --- a/cores/arduino/HardwareSerial.h +++ b/cores/arduino/HardwareSerial.h @@ -26,7 +26,7 @@ class HardwareSerial : public Stream { public: - virtual void begin(unsigned long); + virtual void begin(uint32_t); virtual void end(); virtual int available(void) = 0; virtual int peek(void) = 0; From 1c5bf3feacc73498419fecbf5e79522a24e896af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= Date: Tue, 15 Mar 2022 15:03:00 +0100 Subject: [PATCH 3/4] Clang defines the long_call attribute only on MIPS --- cores/arduino/Reset.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cores/arduino/Reset.cpp b/cores/arduino/Reset.cpp index 67ef9e32..e0d830ff 100644 --- a/cores/arduino/Reset.cpp +++ b/cores/arduino/Reset.cpp @@ -23,7 +23,11 @@ extern "C" { #endif +#if !defined(__clang__) || defined(__mips__) __attribute__ ((long_call, section (".ramfunc"))) +#else +__attribute__ ((section (".ramfunc"))) +#endif void banzai() { // Disable all interrupts __disable_irq(); From e4628b9abc047729cdf567caa74a2770c396a114 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= Date: Tue, 15 Mar 2022 15:27:10 +0100 Subject: [PATCH 4/4] Honor deprecation of register keyword in C++17 when building with GCC/Clang --- system/CMSIS/CMSIS/Include/core_cmFunc.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/system/CMSIS/CMSIS/Include/core_cmFunc.h b/system/CMSIS/CMSIS/Include/core_cmFunc.h index 88819f9d..69289534 100644 --- a/system/CMSIS/CMSIS/Include/core_cmFunc.h +++ b/system/CMSIS/CMSIS/Include/core_cmFunc.h @@ -300,6 +300,13 @@ static __INLINE void __set_FPSCR(uint32_t fpscr) #elif defined ( __GNUC__ ) /*------------------ GNU Compiler ---------------------*/ /* GNU gcc specific functions */ +/* C++17 removes register keyword */ +#if __cplusplus >= 201703L +# define DEPRECATED_REGISTER +#else +# define DEPRECATED_REGISTER register +#endif + /** \brief Enable IRQ Interrupts This function enables IRQ interrupts by clearing the I-bit in the CPSR. @@ -402,7 +409,7 @@ __attribute__( ( always_inline ) ) static __INLINE uint32_t __get_xPSR(void) */ __attribute__( ( always_inline ) ) static __INLINE uint32_t __get_PSP(void) { - register uint32_t result; + DEPRECATED_REGISTER uint32_t result; __ASM volatile ("MRS %0, psp\n" : "=r" (result) ); return(result); @@ -429,7 +436,7 @@ __attribute__( ( always_inline ) ) static __INLINE void __set_PSP(uint32_t topOf */ __attribute__( ( always_inline ) ) static __INLINE uint32_t __get_MSP(void) { - register uint32_t result; + DEPRECATED_REGISTER uint32_t result; __ASM volatile ("MRS %0, msp\n" : "=r" (result) ); return(result); @@ -591,6 +598,8 @@ __attribute__( ( always_inline ) ) static __INLINE void __set_FPSCR(uint32_t fps #endif /* (__CORTEX_M == 0x04) */ +#undef DEPRECATED_REGISTER + #elif defined ( __TASKING__ ) /*------------------ TASKING Compiler --------------*/ /* TASKING carm specific functions */