From: Mathieu Desnoyers Date: Thu, 1 Sep 2011 13:31:55 +0000 (-0400) Subject: wfstack: push returns prior stack emptiness state X-Git-Tag: v0.6.5~40 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=191098fce0abcec4713428d402c9a892fe79bb77;p=userspace-rcu.git wfstack: push returns prior stack emptiness state Signed-off-by: Mathieu Desnoyers --- diff --git a/urcu/static/wfstack.h b/urcu/static/wfstack.h index 79ed3f7..cb68a59 100644 --- a/urcu/static/wfstack.h +++ b/urcu/static/wfstack.h @@ -56,8 +56,11 @@ void _cds_wfs_init(struct cds_wfs_stack *s) assert(!ret); } +/* + * Returns 0 if stack was empty, 1 otherwise. + */ static inline -void _cds_wfs_push(struct cds_wfs_stack *s, struct cds_wfs_node *node) +int _cds_wfs_push(struct cds_wfs_stack *s, struct cds_wfs_node *node) { struct cds_wfs_node *old_head; @@ -72,6 +75,7 @@ void _cds_wfs_push(struct cds_wfs_stack *s, struct cds_wfs_node *node) * until node->next is set to old_head. */ CMM_STORE_SHARED(node->next, old_head); + return (old_head != CDS_WF_STACK_END); } /* diff --git a/urcu/wfstack.h b/urcu/wfstack.h index 354646d..db2ee0c 100644 --- a/urcu/wfstack.h +++ b/urcu/wfstack.h @@ -54,7 +54,7 @@ struct cds_wfs_stack { extern void cds_wfs_node_init(struct cds_wfs_node *node); extern void cds_wfs_init(struct cds_wfs_stack *s); -extern void cds_wfs_push(struct cds_wfs_stack *s, struct cds_wfs_node *node); +extern int cds_wfs_push(struct cds_wfs_stack *s, struct cds_wfs_node *node); /* __cds_wfs_pop_blocking: caller ensures mutual exclusion between pops */ extern struct cds_wfs_node *__cds_wfs_pop_blocking(struct cds_wfs_stack *s); extern struct cds_wfs_node *cds_wfs_pop_blocking(struct cds_wfs_stack *s); diff --git a/wfstack.c b/wfstack.c index d999a5b..e9799e6 100644 --- a/wfstack.c +++ b/wfstack.c @@ -38,9 +38,9 @@ void cds_wfs_init(struct cds_wfs_stack *s) _cds_wfs_init(s); } -void cds_wfs_push(struct cds_wfs_stack *s, struct cds_wfs_node *node) +int cds_wfs_push(struct cds_wfs_stack *s, struct cds_wfs_node *node) { - _cds_wfs_push(s, node); + return _cds_wfs_push(s, node); } struct cds_wfs_node *__cds_wfs_pop_blocking(struct cds_wfs_stack *s)