From: Brian Norris Date: Wed, 6 Mar 2013 02:17:49 +0000 (-0800) Subject: ms-queue: bugfix - get_ptr() and get_count() were switched X-Git-Tag: oopsla2013-final~32 X-Git-Url: http://demsky.eecs.uci.edu/git/?p=model-checker-benchmarks.git;a=commitdiff_plain;h=d3c94c5b4370fc71d1c12272af29b3a95178f4bd ms-queue: bugfix - get_ptr() and get_count() were switched I ported the implementation wrong, so that we were extracting bits from the wrong field. --- diff --git a/ms-queue/my_queue.c b/ms-queue/my_queue.c index 33a6292..498fb42 100644 --- a/ms-queue/my_queue.c +++ b/ms-queue/my_queue.c @@ -31,8 +31,6 @@ void init_queue(queue_t *q, int num_threads) 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); diff --git a/ms-queue/my_queue.h b/ms-queue/my_queue.h index 5877a68..c92e420 100644 --- a/ms-queue/my_queue.h +++ b/ms-queue/my_queue.h @@ -11,8 +11,8 @@ typedef atomic_ullong pointer_t; 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;