- smp->nodes[node].value = val;
- smp->nodes[node].next.sep.ptr = NULL;
-
- for (success = FALSE; success == FALSE; ) {
- tail.con = smp->tail.con;
- next.con = smp->nodes[tail.sep.ptr].next.con;
- if (tail.con == smp->tail.con) {
- if (next.sep.ptr == NULL) {
- success = cas(&smp->nodes[tail.sep.ptr].next,
- next.con,
- MAKE_LONG(node, next.sep.count+1));
+ store_32(&q->nodes[node].value, val);
+ tmp = atomic_load_explicit(&q->nodes[node].next, relaxed);
+ set_ptr(&tmp, 0); // NULL
+ atomic_store_explicit(&q->nodes[node].next, tmp, relaxed);
+
+ while (!success) {
+ tail = atomic_load_explicit(&q->tail, acquire);
+ next = atomic_load_explicit(&q->nodes[get_ptr(tail)].next, acquire);
+ if (tail == atomic_load_explicit(&q->tail, relaxed)) {
+
+ /* Check for uninitialized 'next' */
+ MODEL_ASSERT(get_ptr(next) != POISON_IDX);
+
+ if (get_ptr(next) == 0) { // == NULL
+ pointer value = MAKE_POINTER(node, get_count(next) + 1);
+ success = atomic_compare_exchange_strong_explicit(&q->nodes[get_ptr(tail)].next,
+ &next, value, release, release);