1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

also make pointers stored in a queue relative

This commit is contained in:
Georg Reinke 2017-04-04 11:37:46 +02:00
parent 08a60dcaca
commit 589d50a55a
2 changed files with 3 additions and 3 deletions

View file

@ -44,7 +44,7 @@ typedef char cacheline_pad_t[CACHELINE_SIZE];
struct queue_cell {
atomic_size_t sequence;
void *data;
size_t data_off; /**< Pointer relative to the queue struct */
};
struct queue {

View file

@ -102,7 +102,7 @@ int queue_push(struct queue *q, void *ptr)
pos = atomic_load_explicit(&q->tail, memory_order_relaxed);
}
cell->data = ptr;
cell->data_off = (char *) ptr - (char *) q;
atomic_store_explicit(&cell->sequence, pos + 1, memory_order_release);
return 1;
@ -131,7 +131,7 @@ int queue_pull(struct queue *q, void **ptr)
pos = atomic_load_explicit(&q->head, memory_order_relaxed);
}
*ptr = cell->data;
*ptr = (char *) q + cell->data_off;
atomic_store_explicit(&cell->sequence, pos + q->buffer_mask + 1, memory_order_release);
return 1;