X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=include%2Furcu%2Fstatic%2Fwfstack.h;h=8c5648ea3ede060ddc4c2d4ddfe244faf6ece5bc;hb=d18544842bdfbf2cba6c194a8e8d305ddf5e295e;hp=e96c8876a2b916dcd5bde1e1ba2ad3f8b5ff4ec8;hpb=6893800a4d1cc14dff0395ddcd660a5138db183d;p=urcu.git diff --git a/include/urcu/static/wfstack.h b/include/urcu/static/wfstack.h index e96c887..8c5648e 100644 --- a/include/urcu/static/wfstack.h +++ b/include/urcu/static/wfstack.h @@ -1,35 +1,21 @@ +// SPDX-FileCopyrightText: 2010-2012 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + #ifndef _URCU_STATIC_WFSTACK_H #define _URCU_STATIC_WFSTACK_H /* - * urcu/static/wfstack.h - * * Userspace RCU library - Stack with with wait-free push, blocking traversal. * * TO BE INCLUDED ONLY IN LGPL-COMPATIBLE CODE. See urcu/wfstack.h for * linking dynamically with the userspace rcu library. - * - * Copyright 2010-2012 - Mathieu Desnoyers - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include -#include #include #include +#include #include #include @@ -37,7 +23,7 @@ extern "C" { #endif -#define CDS_WFS_END ((void *) 0x1UL) +#define CDS_WFS_END ((struct cds_wfs_head *) 0x1UL) #define CDS_WFS_ADAPT_ATTEMPTS 10 /* Retry if being set */ #define CDS_WFS_WAIT 10 /* Wait 10 ms if being set */ @@ -96,7 +82,7 @@ void _cds_wfs_init(struct cds_wfs_stack *s) s->head = CDS_WFS_END; ret = pthread_mutex_init(&s->lock, NULL); - assert(!ret); + urcu_posix_assert(!ret); } /* @@ -107,7 +93,7 @@ static inline void _cds_wfs_destroy(struct cds_wfs_stack *s) { int ret = pthread_mutex_destroy(&s->lock); - assert(!ret); + urcu_posix_assert(!ret); } static inline bool ___cds_wfs_end(void *node) @@ -142,7 +128,7 @@ int _cds_wfs_push(cds_wfs_stack_ptr_t u_stack, struct cds_wfs_node *node) struct __cds_wfs_stack *s = u_stack._s; struct cds_wfs_head *old_head, *new_head; - assert(node->next == NULL); + urcu_posix_assert(node->next == NULL); new_head = caa_container_of(node, struct cds_wfs_head, node); /* * uatomic_xchg() implicit memory barrier orders earlier stores @@ -323,7 +309,7 @@ static inline void _cds_wfs_pop_lock(struct cds_wfs_stack *s) int ret; ret = pthread_mutex_lock(&s->lock); - assert(!ret); + urcu_posix_assert(!ret); } /* @@ -334,7 +320,7 @@ static inline void _cds_wfs_pop_unlock(struct cds_wfs_stack *s) int ret; ret = pthread_mutex_unlock(&s->lock); - assert(!ret); + urcu_posix_assert(!ret); } /* @@ -345,9 +331,11 @@ struct cds_wfs_node * _cds_wfs_pop_with_state_blocking(struct cds_wfs_stack *s, int *state) { struct cds_wfs_node *retnode; + cds_wfs_stack_ptr_t stack; _cds_wfs_pop_lock(s); - retnode = ___cds_wfs_pop_with_state_blocking(s, state); + stack.s = s; + retnode = ___cds_wfs_pop_with_state_blocking(stack, state); _cds_wfs_pop_unlock(s); return retnode; } @@ -370,9 +358,11 @@ struct cds_wfs_head * _cds_wfs_pop_all_blocking(struct cds_wfs_stack *s) { struct cds_wfs_head *rethead; + cds_wfs_stack_ptr_t stack; _cds_wfs_pop_lock(s); - rethead = ___cds_wfs_pop_all(s); + stack.s = s; + rethead = ___cds_wfs_pop_all(stack); _cds_wfs_pop_unlock(s); return rethead; }