From 8248685dcf77015b56ba540ec4c7e8bc54aca7ca Mon Sep 17 00:00:00 2001 From: oliverschmidt Date: Mon, 26 May 2008 09:12:22 +0000 Subject: [PATCH] Not all targets support stdio. There I replaced stdio output with log output (and streamlined the source). --- examples/multi-threading/multi-threading.c | 26 ++++++---------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/examples/multi-threading/multi-threading.c b/examples/multi-threading/multi-threading.c index 4f1dc4b2f..c91596d70 100644 --- a/examples/multi-threading/multi-threading.c +++ b/examples/multi-threading/multi-threading.c @@ -30,7 +30,7 @@ * * Author: Oliver Schmidt * - * $Id: multi-threading.c,v 1.3 2007/08/10 10:33:28 oliverschmidt Exp $ + * $Id: multi-threading.c,v 1.4 2008/05/26 09:12:22 oliverschmidt Exp $ */ /** @@ -41,28 +41,16 @@ * Oliver Schmidt */ -#ifdef __CYGWIN__ - -#define WIN32_LEAN_AND_MEAN -#include - /* The Contiki Multi-threading library is on Windows implemented using * Win32 fibers. The Cygwin C-library implements Thread-Local-Storage * in a way that is incompatible with fibers. Therefore most Cygwin - * C-library functions don't work when called from a Contiki thread. - * - * So the sample application calls the Win32 function wsprintf instead - * of the Cygwin function sprintf from its Contiki threads. */ -#define sprintf wsprintf - -#endif /* __CYGWIN__ */ - -#include + * C-library functions don't work when called from a Contiki thread. */ #include "contiki.h" +#include "sys/log.h" #include "sys/mt.h" -static char buf[12]; +static char *ptr; PROCESS(multi_threading_process, "Multi-threading process"); AUTOSTART_PROCESSES(&multi_threading_process); @@ -71,7 +59,7 @@ AUTOSTART_PROCESSES(&multi_threading_process); static void thread_func(char *str, int len) { - sprintf(buf, "%s\n", str + len); + ptr = str + len; mt_yield(); if(len) { @@ -79,7 +67,7 @@ thread_func(char *str, int len) mt_yield(); } - sprintf(buf, "%s\n", str + len); + ptr = str + len; } /*---------------------------------------------------------------------------*/ static void @@ -117,7 +105,7 @@ PROCESS_THREAD(multi_threading_process, ev, data) mt_exec(&count_thread); toggle++; } - printf(buf); + log_message(ptr, ""); etimer_set(&timer, CLOCK_SECOND / 2); }