X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=tos%2Fsystem%2FQueueC.nc;h=ecf714aabed9f3c9221104001e4ce80cab0a74ab;hb=13e400e82fdf39ec7807c7b290136408044d6273;hp=c1fcfd084c35670ed4f60b97cde613095cb3b013;hpb=1ba974b83d19fc41bf80acd52726f36f7f1df297;p=tinyos-2.x.git diff --git a/tos/system/QueueC.nc b/tos/system/QueueC.nc index c1fcfd08..ecf714aa 100644 --- a/tos/system/QueueC.nc +++ b/tos/system/QueueC.nc @@ -34,6 +34,7 @@ * A general FIFO queue component, whose queue has a bounded size. * * @author Philip Levis + * @author Geoffrey Mainland * @date $Date$ */ @@ -44,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; @@ -86,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(); } @@ -98,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; @@ -110,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]; }