From: Mathieu Desnoyers Date: Thu, 1 Sep 2011 13:28:30 +0000 (-0400) Subject: Make lf stack push return if the stack was empty X-Git-Tag: v0.6.5~41 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=e1a3b81e201ccfd019dae3778bd6ba0bd1e545e4;p=userspace-rcu.git Make lf stack push return if the stack was empty Signed-off-by: Mathieu Desnoyers --- diff --git a/rculfstack.c b/rculfstack.c index aa906af..f58628c 100644 --- a/rculfstack.c +++ b/rculfstack.c @@ -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) diff --git a/urcu/rculfstack.h b/urcu/rculfstack.h index f673952..cf00daf 100644 --- a/urcu/rculfstack.h +++ b/urcu/rculfstack.h @@ -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. diff --git a/urcu/static/rculfstack.h b/urcu/static/rculfstack.h index 9d69fa7..1df121b 100644 --- a/urcu/static/rculfstack.h +++ b/urcu/static/rculfstack.h @@ -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); } /*