From 50e145256471a40c9fbf09c6df8ef7845eb4de0d Mon Sep 17 00:00:00 2001 From: adamdunkels Date: Tue, 23 Feb 2010 18:40:08 +0000 Subject: [PATCH] Ugly workaround for internal error in mspgcc when applying the >= operator to two 32-bit values --- core/sys/timer.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/sys/timer.c b/core/sys/timer.c index 821f2a2bc..756ea4759 100644 --- a/core/sys/timer.c +++ b/core/sys/timer.c @@ -42,7 +42,7 @@ * * Author: Adam Dunkels * - * $Id: timer.c,v 1.5 2009/01/24 15:20:11 adamdunkels Exp $ + * $Id: timer.c,v 1.6 2010/02/23 18:40:08 adamdunkels Exp $ */ #include "contiki-conf.h" @@ -121,7 +121,10 @@ timer_restart(struct timer *t) int timer_expired(struct timer *t) { - return (clock_time_t)(clock_time() - t->start) >= (clock_time_t)t->interval; + clock_time_t diff = clock_time() - t->start; + /* This somewhat ugly way of returning (diff >= t->interval) is + required to avoid an internal error in mspgcc. */ + return diff > t->interval || diff == t->interval; } /*---------------------------------------------------------------------------*/ /**