From 805464db23cf07f085d5042f46e01b4c9e7b62fd Mon Sep 17 00:00:00 2001 From: Alexey 'Alexxy' Shvetsov Date: Sun, 10 May 2020 00:48:59 +0300 Subject: [PATCH] Fix redefinition of io function Now it should work fine with any gcc version. Old one produces error like in #657 Signed-off-by: Alexey 'Alexxy' Shvetsov --- src/platforms/f4discovery/platform.h | 36 ++++++++++++++++++++++++---- src/platforms/hydrabus/platform.h | 29 +++++++++++++++++++++- src/platforms/native/platform.h | 31 ++++++++++++++++++++++-- src/platforms/stlink/platform.h | 30 ++++++++++++++++++++++- src/platforms/swlink/platform.h | 29 +++++++++++++++++++++- 5 files changed, 145 insertions(+), 10 deletions(-) diff --git a/src/platforms/f4discovery/platform.h b/src/platforms/f4discovery/platform.h index 971ebc2..cb41f9a 100644 --- a/src/platforms/f4discovery/platform.h +++ b/src/platforms/f4discovery/platform.h @@ -153,11 +153,37 @@ static inline int platform_hwversion(void) return 0; } -/* Use newlib provided integer only stdio functions */ -#define sscanf siscanf -#define sprintf siprintf -#define vasprintf vasiprintf -#define snprintf sniprintf +/* + * Use newlib provided integer only stdio functions + */ +/* sscanf */ +#ifdef sscanf +#undef sscanf +#define sscanf siscanf +#else +#define sscanf siscanf +#endif +/* sprintf */ +#ifdef sprintf +#undef sprintf +#define sprintf siprintf +#else +#define sprintf siprintf +#endif +/* vasprintf */ +#ifdef vasprintf +#undef vasprintf +#define vasprintf vasiprintf +#else +#define vasprintf vasiprintf +#endif +/* snprintf */ +#ifdef snprintf +#undef snprintf +#define snprintf sniprintf +#else +#define snprintf sniprintf #endif +#endif diff --git a/src/platforms/hydrabus/platform.h b/src/platforms/hydrabus/platform.h index d0ba61a..792cfba 100644 --- a/src/platforms/hydrabus/platform.h +++ b/src/platforms/hydrabus/platform.h @@ -153,11 +153,38 @@ static inline int platform_hwversion(void) return 0; } -/* Use newlib provided integer only stdio functions */ +/* + * Use newlib provided integer only stdio functions + */ + +/* sscanf */ +#ifdef sscanf +#undef sscanf #define sscanf siscanf +#else +#define sscanf siscanf +#endif +/* sprintf */ +#ifdef sprintf +#undef sprintf #define sprintf siprintf +#else +#define sprintf siprintf +#endif +/* vasprintf */ +#ifdef vasprintf +#undef vasprintf #define vasprintf vasiprintf +#else +#define vasprintf vasiprintf +#endif +/* snprintf */ +#ifdef snprintf +#undef snprintf #define snprintf sniprintf +#else +#define snprintf sniprintf +#endif #endif diff --git a/src/platforms/native/platform.h b/src/platforms/native/platform.h index 59d6908..00043ac 100644 --- a/src/platforms/native/platform.h +++ b/src/platforms/native/platform.h @@ -178,10 +178,37 @@ int usbuart_debug_write(const char *buf, size_t len); #define SET_IDLE_STATE(state) {gpio_set_val(LED_PORT, LED_IDLE_RUN, state);} #define SET_ERROR_STATE(state) {gpio_set_val(LED_PORT, LED_ERROR, state);} -/* Use newlib provided integer only stdio functions */ +/* + * Use newlib provided integer only stdio functions + */ + +/* sscanf */ +#ifdef sscanf +#undef sscanf #define sscanf siscanf +#else +#define sscanf siscanf +#endif +/* sprintf */ +#ifdef sprintf +#undef sprintf #define sprintf siprintf -#define snprintf sniprintf +#else +#define sprintf siprintf +#endif +/* vasprintf */ +#ifdef vasprintf +#undef vasprintf #define vasprintf vasiprintf +#else +#define vasprintf vasiprintf +#endif +/* snprintf */ +#ifdef snprintf +#undef snprintf +#define snprintf sniprintf +#else +#define snprintf sniprintf +#endif #endif diff --git a/src/platforms/stlink/platform.h b/src/platforms/stlink/platform.h index 0ac91bb..1b57223 100644 --- a/src/platforms/stlink/platform.h +++ b/src/platforms/stlink/platform.h @@ -148,11 +148,39 @@ extern uint16_t led_idle_run; extern uint32_t detect_rev(void); -/* Use newlib provided integer only stdio functions */ +/* + * Use newlib provided integer only stdio functions + */ + +/* sscanf */ +#ifdef sscanf +#undef sscanf #define sscanf siscanf +#else +#define sscanf siscanf +#endif +/* sprintf */ +#ifdef sprintf +#undef sprintf #define sprintf siprintf +#else +#define sprintf siprintf +#endif +/* vasprintf */ +#ifdef vasprintf +#undef vasprintf #define vasprintf vasiprintf +#else +#define vasprintf vasiprintf +#endif +/* snprintf */ +#ifdef snprintf +#undef snprintf #define snprintf sniprintf +#else +#define snprintf sniprintf +#endif + #endif diff --git a/src/platforms/swlink/platform.h b/src/platforms/swlink/platform.h index 78bc449..74f1d43 100644 --- a/src/platforms/swlink/platform.h +++ b/src/platforms/swlink/platform.h @@ -154,11 +154,38 @@ extern void set_idle_state(int state); extern uint8_t detect_rev(void); -/* Use newlib provided integer only stdio functions */ +/* + * Use newlib provided integer only stdio functions + */ + +/* sscanf */ +#ifdef sscanf +#undef sscanf #define sscanf siscanf +#else +#define sscanf siscanf +#endif +/* sprintf */ +#ifdef sprintf +#undef sprintf #define sprintf siprintf +#else +#define sprintf siprintf +#endif +/* vasprintf */ +#ifdef vasprintf +#undef vasprintf #define vasprintf vasiprintf +#else +#define vasprintf vasiprintf +#endif +/* snprintf */ +#ifdef snprintf +#undef snprintf #define snprintf sniprintf +#else +#define snprintf sniprintf +#endif #endif