I ported the implementation wrong, so that we were extracting bits from
the wrong field.
tail = MAKE_POINTER(1, 0);
next = MAKE_POINTER(0, 0); // (NULL, 0)
- atomic_init(&q->nodes[0].next, 0); // assumed inititalized in original example
-
atomic_store(&q->head, head);
atomic_store(&q->tail, tail);
atomic_store(&q->nodes[1].next, next);
static inline void set_count(pointer *p, unsigned int val) { *p = (*p & ~COUNT_MASK) | ((pointer)val << 32); }
static inline void set_ptr(pointer *p, unsigned int val) { *p = (*p & ~PTR_MASK) | val; }
-static inline unsigned int get_count(pointer p) { return p & PTR_MASK; }
-static inline unsigned int get_ptr(pointer p) { return (p & COUNT_MASK) >> 32; }
+static inline unsigned int get_count(pointer p) { return (p & COUNT_MASK) >> 32; }
+static inline unsigned int get_ptr(pointer p) { return p & PTR_MASK; }
typedef struct node {
unsigned int value;