]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
hello compiler bug (looks like shifting by 32 bits inside a 64 bit type is
authorandreaskoepke <andreaskoepke>
Fri, 7 Dec 2007 19:00:15 +0000 (19:00 +0000)
committerandreaskoepke <andreaskoepke>
Fri, 7 Dec 2007 19:00:15 +0000 (19:00 +0000)
trouble), bye bye platform independence

tos/platforms/eyesIFX/LocalTimeP.nc

index d696ad0d959eda4009942e2f7e43821c05031a12..ac27c6c134dae791258aeb8fb8bef8f1878957e0 100644 (file)
@@ -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() {