Commit ed53453f authored by Federico Vaga's avatar Federico Vaga

wrtd:rt: minor fix loop head/tail

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>


NOTE
This commit has been created by `git subtree` on the Mock Turtle repository
on tag mock-turtle-2.0

This commit will not compile
parent 27ad3a79
......@@ -29,7 +29,7 @@ void loop_queue_init()
void loop_queue_push(struct wrtd_trig_id *id, uint32_t seq, struct wr_timestamp *ts)
{
if(count == LOOP_QUEUE_SIZE)
if (count >= LOOP_QUEUE_SIZE)
return;
buf[head].id = *id;
......@@ -37,8 +37,7 @@ void loop_queue_push(struct wrtd_trig_id *id, uint32_t seq, struct wr_timestamp
buf[head].ts = *ts;
smem_atomic_add(&head, 1);
if (head == LOOP_QUEUE_SIZE)
if (head >= LOOP_QUEUE_SIZE)
head = 0;
smem_atomic_add(&count, 1);
......@@ -46,16 +45,16 @@ void loop_queue_push(struct wrtd_trig_id *id, uint32_t seq, struct wr_timestamp
struct wrtd_trigger_entry *loop_queue_pop()
{
if(!count)
if (!count)
return NULL;
struct wrtd_trigger_entry *rv = &buf[tail];
smem_atomic_add(&tail, 1);
if(tail == LOOP_QUEUE_SIZE)
if(tail >= LOOP_QUEUE_SIZE)
tail = 0;
smem_atomic_sub(&count, 1);
return rv;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment