static void lifo_aba_push (lifo_t *stk, node_t *x) {
node_t *head;
do {
- head = ((volatile lifo_t *)stk)->head;
- ((volatile node_t *)x)->next = head;
- } while (__sync_val_compare_and_swap(&stk->head, head, x) != head);
+ head = VOLATILE_DEREF(stk).head;
+ VOLATILE_DEREF(x).next = head;
+ } while (SYNC_CAS(&stk->head, head, x) != head);
}
node_t *lifo_aba_pop (lifo_t *stk) {
node_t *head;
do {
- head = ((volatile lifo_t *)stk)->head;
+ head = VOLATILE_DEREF(stk).head;
if (head == NULL)
return NULL;
- } while (__sync_val_compare_and_swap(&stk->head, head, head->next) != head);
+ } while (SYNC_CAS(&stk->head, head, head->next) != head);
head->next = NULL;
return head;
}
unsigned int rand_seed = (unsigned int)id + 1;
// Wait for all the worker threads to be ready.
- __sync_fetch_and_add(&wait_, -1);
+ (void)__sync_fetch_and_add(&wait_, -1);
do {} while (wait_);
int i;
int main (int argc, char **argv) {
lwt_set_trace_level("m3r3");
- int num_threads = 2;
+ int num_threads = MAX_NUM_THREADS;
if (argc == 2)
{
errno = 0;