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.
This commit is contained in:
George Oikonomou 2018-03-30 22:20:10 +01:00
parent 87dfa61fd6
commit b2438b4563
3 changed files with 19 additions and 4 deletions

View File

@ -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 <stdio.h>
#undef putchar
/*---------------------------------------------------------------------------*/
#endif /* ARM_DEF_ */
/*---------------------------------------------------------------------------*/

View File

@ -48,9 +48,6 @@
#define flush()
#endif
/*---------------------------------------------------------------------------*/
#undef putchar
#undef puts
#define SLIP_END 0300
/*---------------------------------------------------------------------------*/
int

View File

@ -35,7 +35,6 @@
#include <stdio.h>
#include <string.h>
/*---------------------------------------------------------------------------*/
#undef putchar
#undef putc
/*---------------------------------------------------------------------------*/
int