]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/chips/atm128/adc/AdcStreamP.nc
turn on safe compilation for some modules
[tinyos-2.x.git] / tos / chips / atm128 / adc / AdcStreamP.nc
index 6bc47bc1272199dd6447220bb50bea15c322f5e8..b5a844f44bead883422af7de1c431c16e116ed04 100644 (file)
@@ -43,7 +43,7 @@
  */
 #include "Timer.h"
 
-module AdcStreamP {
+module AdcStreamP @safe() {
   provides {
     interface Init @atleastonce();
     interface ReadStream<uint16_t>[uint8_t client];
@@ -68,13 +68,15 @@ implementation {
   /* Stream data */
   struct list_entry_t {
     uint16_t count;
-    struct list_entry_t *next;
+    struct list_entry_t * ONE_NOK next;
   };
   struct list_entry_t *bufferQueue[NSTREAM];
-  struct list_entry_t **bufferQueueEnd[NSTREAM];
-  uint16_t *lastBuffer, lastCount;
+  struct list_entry_t * ONE_NOK * bufferQueueEnd[NSTREAM];
+  uint16_t * ONE_NOK lastBuffer, lastCount;
 
-  norace uint16_t *buffer, *pos, count;
+  norace uint16_t count;
+  norace uint16_t * COUNT_NOK(count) buffer; 
+  norace uint16_t * BND_NOK(buffer, buffer+count) pos;
   norace uint32_t now, period;
 
 
@@ -108,7 +110,7 @@ implementation {
       return ESIZE;
     atomic
       {
-       struct list_entry_t *newEntry = (struct list_entry_t *)buf;
+       struct list_entry_t * ONE newEntry = TCAST(struct list_entry_t * ONE, buf);
 
        if (!bufferQueueEnd[c]) // Can't post right now.
          return FAIL;
@@ -141,8 +143,10 @@ implementation {
     uint8_t c = client;
 
     atomic entry = bufferQueue[c];
-    for (; entry; entry = entry->next)
-      signal ReadStream.bufferDone[c](FAIL, (uint16_t *)entry, entry->count);
+    for (; entry; entry = entry->next){
+      uint16_t tmp_count __DEPUTY_UNUSED__ = entry->count;
+      signal ReadStream.bufferDone[c](FAIL, TCAST(uint16_t * COUNT_NOK(tmp_count),entry), entry->count);
+    }
 
     atomic
       {
@@ -200,11 +204,13 @@ implementation {
          }
        else
          {
+            uint16_t tmp_count;
            bufferQueue[client] = entry->next;
            if (!bufferQueue[client])
              bufferQueueEnd[client] = &bufferQueue[client];
-           pos = buffer = (uint16_t *)entry;
            count = entry->count;
+            tmp_count = count;
+           pos = buffer = TCAST(uint16_t * COUNT_NOK(tmp_count), entry);
            nextAlarm();
          }
       }