Make lf stack push return if the stack was empty
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 1 Sep 2011 13:28:30 +0000 (09:28 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 1 Sep 2011 13:28:30 +0000 (09:28 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
rculfstack.c
urcu/rculfstack.h
urcu/static/rculfstack.h

index aa906af9480c66efce8c35ccf8d2b3625b9aabfd..f58628ce4ea06f55185fb75682cbc9f6b974ef36 100644 (file)
@@ -51,9 +51,10 @@ void cds_lfs_init_rcu(struct cds_lfs_stack_rcu *s)
        _cds_lfs_init_rcu(s);
 }
 
-void cds_lfs_push_rcu(struct cds_lfs_stack_rcu *s, struct cds_lfs_node_rcu *node)
+int cds_lfs_push_rcu(struct cds_lfs_stack_rcu *s,
+               struct cds_lfs_node_rcu *node)
 {
-       _cds_lfs_push_rcu(s, node);
+       return _cds_lfs_push_rcu(s, node);
 }
 
 struct cds_lfs_node_rcu *cds_lfs_pop_rcu(struct cds_lfs_stack_rcu *s)
index f6739528a650b2bf8c9bb8d41a35dc400a02c16f..cf00daf26cc65cf09d300dafb91dd73467cf6f42 100644 (file)
@@ -68,7 +68,8 @@ struct cds_lfs_stack_rcu {
 
 extern void cds_lfs_node_init_rcu(struct cds_lfs_node_rcu *node);
 extern void cds_lfs_init_rcu(struct cds_lfs_stack_rcu *s);
-extern void cds_lfs_push_rcu(struct cds_lfs_stack_rcu *s, struct cds_lfs_node_rcu *node);
+extern int cds_lfs_push_rcu(struct cds_lfs_stack_rcu *s,
+                       struct cds_lfs_node_rcu *node);
 
 /*
  * Acts as a RCU reader.
index 9d69fa736996c4dfc704bbffc88d9f14395344c8..1df121b461389fbb0b621e6eeefb37c4b4e131eb 100644 (file)
@@ -64,9 +64,13 @@ void _cds_lfs_init_rcu(struct cds_lfs_stack_rcu *s)
  * required if we first read the old head value). This design decision
  * might be revisited after more throrough benchmarking on various
  * platforms.
+ *
+ * Returns 0 if the stack was empty prior to adding the node.
+ * Returns non-zero otherwise.
  */
 static inline
-void _cds_lfs_push_rcu(struct cds_lfs_stack_rcu *s, struct cds_lfs_node_rcu *node)
+int _cds_lfs_push_rcu(struct cds_lfs_stack_rcu *s,
+                         struct cds_lfs_node_rcu *node)
 {
        struct cds_lfs_node_rcu *head = NULL;
 
@@ -82,6 +86,7 @@ void _cds_lfs_push_rcu(struct cds_lfs_stack_rcu *s, struct cds_lfs_node_rcu *nod
                if (old_head == head)
                        break;
        }
+       return (int) !!((unsigned long) head);
 }
 
 /*
This page took 0.025442 seconds and 4 git commands to generate.