From b2438b4563e9974415238b627c47b34e33835d05 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Fri, 30 Mar 2018 22:20:10 +0100 Subject: [PATCH] Enable putchar for all arm platforms Instead of having to #undef putchar in every file where we want to use it, we undef it across the board. See the comment in arm-def.h as to why this needs done. --- arch/cpu/arm/arm-def.h | 19 +++++++++++++++++++ arch/cpu/cc2538/dbg.c | 3 --- os/lib/dbg-io/putchar.c | 1 - 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/arch/cpu/arm/arm-def.h b/arch/cpu/arm/arm-def.h index 2cd31604c..92b19048d 100644 --- a/arch/cpu/arm/arm-def.h +++ b/arch/cpu/arm/arm-def.h @@ -60,6 +60,25 @@ typedef uint32_t uip_stats_t; typedef uint32_t rtimer_clock_t; #define RTIMER_CLOCK_DIFF(a, b) ((int32_t)((a) - (b))) /** @} */ + +/* + * The stdio.h that ships with the arm-gcc toolchain does this: + * + * int _EXFUN(putchar, (int)); + * [...] + * #define putchar(x) putc(x, stdout) + * + * This causes us a lot of trouble: For platforms using this toolchain, every + * time we use putchar we need to first #undef putchar. What we do here is to + * #undef putchar across the board. The resulting code will cause the linker + * to search for a symbol named putchar and this allows us to use the + * implementation under os/lib/dbg-io. + * + * This will fail if stdio.h is included before contiki.h, but it is common + * practice to include contiki.h first + */ +#include +#undef putchar /*---------------------------------------------------------------------------*/ #endif /* ARM_DEF_ */ /*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/cc2538/dbg.c b/arch/cpu/cc2538/dbg.c index c39e05af7..7b33bc471 100644 --- a/arch/cpu/cc2538/dbg.c +++ b/arch/cpu/cc2538/dbg.c @@ -48,9 +48,6 @@ #define flush() #endif /*---------------------------------------------------------------------------*/ -#undef putchar -#undef puts - #define SLIP_END 0300 /*---------------------------------------------------------------------------*/ int diff --git a/os/lib/dbg-io/putchar.c b/os/lib/dbg-io/putchar.c index 11bb7b5e6..d5b81e2ab 100644 --- a/os/lib/dbg-io/putchar.c +++ b/os/lib/dbg-io/putchar.c @@ -35,7 +35,6 @@ #include #include /*---------------------------------------------------------------------------*/ -#undef putchar #undef putc /*---------------------------------------------------------------------------*/ int