summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rw-r--r--lfq.c6
-rw-r--r--lfq.h6
-rw-r--r--lfq_test.c15
4 files changed, 13 insertions, 18 deletions
diff --git a/Makefile b/Makefile
index 67d1f5c..a196f10 100644
--- a/Makefile
+++ b/Makefile
@@ -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:
diff --git a/lfq.c b/lfq.c
index b2bd3e3..8fa9758 100644
--- a/lfq.c
+++ b/lfq.c
@@ -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;
diff --git a/lfq.h b/lfq.h
index 2391112..3906f9b 100644
--- a/lfq.h
+++ b/lfq.h
@@ -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
}
diff --git a/lfq_test.c b/lfq_test.c
index 2502b8d..4223f3f 100644
--- a/lfq_test.c
+++ b/lfq_test.c
@@ -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) {