From e346d8cf9503c7de8f0fa2e8f940b5052d875c73 Mon Sep 17 00:00:00 2001 From: adamdunkels Date: Sat, 24 Jan 2009 15:20:11 +0000 Subject: [PATCH] Reverted the timer_expired() back to the previous version (which should be correct). Removed the definition of CLOCK_LT() because it seems to only cause problems. --- core/sys/clock.h | 6 ++++-- core/sys/timer.c | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/core/sys/clock.h b/core/sys/clock.h index 93c451324..b14db6112 100644 --- a/core/sys/clock.h +++ b/core/sys/clock.h @@ -53,13 +53,14 @@ * * Author: Adam Dunkels * - * $Id: clock.h,v 1.10 2009/01/24 10:54:44 adamdunkels Exp $ + * $Id: clock.h,v 1.11 2009/01/24 15:20:11 adamdunkels Exp $ */ #ifndef __CLOCK_H__ #define __CLOCK_H__ #include "contiki-conf.h" +#if 0 /* XXX problems with signedness and use in timer_expired(). #if:ed it out for now. */ /** * Check if a clock time value is less than another clock time value. * @@ -68,7 +69,8 @@ * clock time values. * */ -#define CLOCK_LT(a, b) ((clock_time_t)((a) - (b)) < 0) +#define CLOCK_LT(a, b) ((clock_time_t)((a) - (b)) < ((clock_time_t)(~((clock_time_t)0)) >> 1)) +#endif /* 0 */ /** * Initialize the clock library. diff --git a/core/sys/timer.c b/core/sys/timer.c index 5807bc1a6..821f2a2bc 100644 --- a/core/sys/timer.c +++ b/core/sys/timer.c @@ -42,7 +42,7 @@ * * Author: Adam Dunkels * - * $Id: timer.c,v 1.4 2008/09/21 08:58:05 adamdunkels Exp $ + * $Id: timer.c,v 1.5 2009/01/24 15:20:11 adamdunkels Exp $ */ #include "contiki-conf.h" @@ -121,7 +121,7 @@ timer_restart(struct timer *t) int timer_expired(struct timer *t) { - return CLOCK_LT(clock_time(), t->start + t->interval); + return (clock_time_t)(clock_time() - t->start) >= (clock_time_t)t->interval; } /*---------------------------------------------------------------------------*/ /**