X-Git-Url: http://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=urcu%2Fstatic%2Flfstack.h;h=63af91adf301918b0331eb3cf55c0c52c5f9711f;hp=77a26dc39293e0a230d00688cbd786e9dab32db0;hb=48a8832be16833b1a9f2625799ac3d0ea4dafc91;hpb=7294103b4caaa3487a362ae9925faa7f6821e0b3 diff --git a/urcu/static/lfstack.h b/urcu/static/lfstack.h index 77a26dc..63af91a 100644 --- a/urcu/static/lfstack.h +++ b/urcu/static/lfstack.h @@ -8,8 +8,8 @@ * * Copyright 2010-2012 - Mathieu Desnoyers * - * TO BE INCLUDED ONLY IN LGPL-COMPATIBLE CODE. See rculfstack.h for linking - * dynamically with the userspace rcu library. + * TO BE INCLUDED ONLY IN LGPL-COMPATIBLE CODE. See urcu/lfstack.h for + * linking dynamically with the userspace rcu library. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -78,6 +78,15 @@ void _cds_lfs_init(struct cds_lfs_stack *s) assert(!ret); } +/* + * ___cds_lfs_init: initialize lock-free stack. + */ +static inline +void ___cds_lfs_init(struct __cds_lfs_stack *s) +{ + s->head = NULL; +} + static inline bool ___cds_lfs_empty_head(struct cds_lfs_head *head) { @@ -90,9 +99,9 @@ bool ___cds_lfs_empty_head(struct cds_lfs_head *head) * No memory barrier is issued. No mutual exclusion is required. */ static inline -bool _cds_lfs_empty(struct cds_lfs_stack *s) +bool _cds_lfs_empty(cds_lfs_stack_ptr_t s) { - return ___cds_lfs_empty_head(CMM_LOAD_SHARED(s->head)); + return ___cds_lfs_empty_head(CMM_LOAD_SHARED(s._s->head)); } /* @@ -118,16 +127,17 @@ bool _cds_lfs_empty(struct cds_lfs_stack *s) * always performing an exclusive cacheline access, rather than doing * non-exclusive followed by exclusive cacheline access (which would be * required if we first read the old head value). This design decision - * might be revisited after more throrough benchmarking on various + * might be revisited after more thorough benchmarking on various * platforms. * * Returns 0 if the stack was empty prior to adding the node. * Returns non-zero otherwise. */ static inline -bool _cds_lfs_push(struct cds_lfs_stack *s, +bool _cds_lfs_push(cds_lfs_stack_ptr_t u_s, struct cds_lfs_node *node) { + struct __cds_lfs_stack *s = u_s._s; struct cds_lfs_head *head = NULL; struct cds_lfs_head *new_head = caa_container_of(node, struct cds_lfs_head, node); @@ -168,8 +178,10 @@ bool _cds_lfs_push(struct cds_lfs_stack *s, * __cds_lfs_pop_all(). (multi-provider/single-consumer scheme). */ static inline -struct cds_lfs_node *___cds_lfs_pop(struct cds_lfs_stack *s) +struct cds_lfs_node *___cds_lfs_pop(cds_lfs_stack_ptr_t u_s) { + struct __cds_lfs_stack *s = u_s._s; + for (;;) { struct cds_lfs_head *head, *next_head; struct cds_lfs_node *next; @@ -211,8 +223,10 @@ struct cds_lfs_node *___cds_lfs_pop(struct cds_lfs_stack *s) * __cds_lfs_pop_all(). (multi-provider/single-consumer scheme). */ static inline -struct cds_lfs_head *___cds_lfs_pop_all(struct cds_lfs_stack *s) +struct cds_lfs_head *___cds_lfs_pop_all(cds_lfs_stack_ptr_t u_s) { + struct __cds_lfs_stack *s = u_s._s; + /* * Implicit memory barrier after uatomic_xchg() matches implicit * memory barrier before uatomic_cmpxchg() in cds_lfs_push. It