diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2009-11-03 22:20:45 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2009-11-03 22:20:45 +0100 |
commit | 74a60162675fae9ac18fc98ebd3d8626e92719f3 (patch) | |
tree | 12e745df337664afc71e852af25aa4a5e2f75ea9 | |
parent | ee32b123e08a04998594146cb9258ca1fa4ec621 (diff) | |
download | lock_free-74a60162675fae9ac18fc98ebd3d8626e92719f3.zip lock_free-74a60162675fae9ac18fc98ebd3d8626e92719f3.tar.gz |
lfq_push => lfq_push_tail, lfq_pop => lfq_pop_head
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | lfq.c | 6 | ||||
-rw-r--r-- | lfq.h | 6 | ||||
-rw-r--r-- | lfq_test.c | 15 |
4 files changed, 13 insertions, 18 deletions
@@ -16,7 +16,9 @@ cas_test: cas_test.o lock_free_queue_test: lock_free_queue.o lock_free_queue_test.o $(CC) lock_free_queue.o lock_free_queue_test.o -o lock_free_queue_test -lfq_test: lfq_cas.h lfq.o lfq_test.o +lfq.o: lfq.h lfq_cas.h + +lfq_test: lfq.o lfq_test.o $(CC) lfq.o lfq_test.o -o lfq_test as: @@ -36,7 +36,7 @@ void lfq_init( lfq_t *q ) { } /* push a node at the tail of q */ -void lfq_push( lfq_t *q, pointer_t *node ) { +void lfq_push_tail( lfq_t *q, pointer_t *node ) { pointer_t tail; pointer_t last; pointer_t tmp; @@ -79,8 +79,8 @@ void lfq_push( lfq_t *q, pointer_t *node ) { cas( &q->tail.split, tail.split, tmp.split ); } -/* shift a node from the head of q */ -pointer_t* shift( lfq_t *q ) { +/* pop a node from the head of q */ +pointer_t* pop_head( lfq_t *q ) { pointer_t head; pointer_t tail; pointer_t tmp; @@ -50,10 +50,10 @@ typedef struct queue { void lfq_init( lfq_t *q ); /* push a node at the tail of q */ -void lfq_push( lfq_t *q, pointer_t *node ); +void lfq_push_tail( lfq_t *q, pointer_t *node ); -/* shift a node from the head of q */ -pointer_t* shift( lfq_t *q ); +/* pop a node from the head of q */ +pointer_t* pop_head( lfq_t *q ); # ifdef __cplusplus } @@ -32,13 +32,6 @@ #include "lfq.h" #include "lfq_cas.h" -/** - * container_of - cast a member of a structure out to the containing structure - * @ptr: the pointer to the member. - * @type: the type of the container struct this is embedded in. - * @member: the name of the member within the struct. - * - */ #define container_of(ptr, type, member) ({ \ const typeof( ((type *)0)->member ) *__mptr = (ptr); \ (type *)( (char *)__mptr - offsetof(type,member) );}) @@ -79,8 +72,8 @@ int main(int argc, char *argv[]) { /* check lfq */ lfq_init( &q); - printf("shift %X\n",(unsigned int)shift( &q )); - for(i=0; i<10; i++) lfq_push( &q, &data[i].link ); + printf("pop %X\n",(unsigned int)pop_head( &q )); + for(i=0; i<10; i++) lfq_push_tail( &q, &data[i].link ); it = (pointer_t*)q.head.split.next; while(it!=NULL) { @@ -89,8 +82,8 @@ int main(int argc, char *argv[]) { } for(i=0; i<5; i++) { - it = shift( &q ); - printf("shift %X %d\n",(unsigned int)it,container_of(it,struct node,link)->data); + it = pop_head( &q ); + printf("pop %X %d\n",(unsigned int)it,container_of(it,struct node,link)->data); } it = (pointer_t*)q.head.split.next; while(it!=NULL) { |