From 08cf72e7257deae5406347f1372b56b9bf92a93d Mon Sep 17 00:00:00 2001 From: andreaskoepke Date: Fri, 7 Dec 2007 19:00:15 +0000 Subject: [PATCH] hello compiler bug (looks like shifting by 32 bits inside a 64 bit type is trouble), bye bye platform independence --- tos/platforms/eyesIFX/LocalTimeP.nc | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/tos/platforms/eyesIFX/LocalTimeP.nc b/tos/platforms/eyesIFX/LocalTimeP.nc index d696ad0d..ac27c6c1 100644 --- a/tos/platforms/eyesIFX/LocalTimeP.nc +++ b/tos/platforms/eyesIFX/LocalTimeP.nc @@ -37,11 +37,20 @@ module LocalTimeP { } } implementation { - uint16_t counter2sec = 40000U; + typedef union + { + int64_t op; + struct { + uint32_t lo; + int32_t hi; + }; + } i64parts_t; + + uint16_t counter2sec = 126; int32_t dayCounter = 0; bool increaseDay = FALSE; async command uint32_t LocalTime32kHz.get() { - int64_t time; + uint32_t time; unsigned t; bool dirty1; bool dirty2; @@ -65,17 +74,16 @@ implementation { } async command int64_t WideLocalTime.get() { - int64_t time; + i64parts_t time; uint32_t t; atomic { t = call LocalTime32kHz.get(); - time = dayCounter; - if(increaseDay) time++; - if(time < 0) time = 0; - time <<= 32; - time += t; + time.hi = dayCounter; + if(increaseDay) time.hi++; + if(time.hi < 0) time.hi = 0; + time.lo = t; } - return time; + return time.op; } async event void Counter32khz16.overflow() { -- 2.39.2