X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=tos%2Fsystem%2FQueueC.nc;h=ecf714aabed9f3c9221104001e4ce80cab0a74ab;hb=b7e372c3aa2f1da307407397da3b032df4ac4d49;hp=860934833949e98996e3fbc5f43343cde672357b;hpb=1a329382c4f4556fd52d85f4e3f4a67e54911682;p=tinyos-2.x.git diff --git a/tos/system/QueueC.nc b/tos/system/QueueC.nc index 86093483..ecf714aa 100644 --- a/tos/system/QueueC.nc +++ b/tos/system/QueueC.nc @@ -45,7 +45,7 @@ generic module QueueC(typedef queue_t, uint8_t QUEUE_SIZE) { implementation { - queue_t queue[QUEUE_SIZE]; + queue_t ONE_NOK queue[QUEUE_SIZE]; uint8_t head = 0; uint8_t tail = 0; uint8_t size = 0; @@ -87,7 +87,7 @@ implementation { dbg("QueueC", "%s: size is %hhu\n", __FUNCTION__, size); if (!call Queue.empty()) { head++; - head %= QUEUE_SIZE; + if (head == QUEUE_SIZE) head = 0; size--; printQueue(); } @@ -99,7 +99,7 @@ implementation { dbg("QueueC", "%s: size is %hhu\n", __FUNCTION__, size); queue[tail] = newVal; tail++; - tail %= QUEUE_SIZE; + if (tail == QUEUE_SIZE) tail = 0; size++; printQueue(); return SUCCESS; @@ -111,7 +111,9 @@ implementation { command queue_t Queue.element(uint8_t idx) { idx += head; - idx %= QUEUE_SIZE; + if (idx >= QUEUE_SIZE) { + idx -= QUEUE_SIZE; + } return queue[idx]; }