X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=include%2Furcu%2Fstatic%2Frculfstack.h;h=b44b9e29fdbad9b73024d653fb992218f221644b;hb=0e2125fb7b2c7a92d7030b41df5fb372a7706c32;hp=54ff377b8aa801bbeaddb07097e05428d6bc8e88;hpb=f99c6e92aaa1582e6cd19d93d44d91d968f39aa7;p=userspace-rcu.git diff --git a/include/urcu/static/rculfstack.h b/include/urcu/static/rculfstack.h index 54ff377..b44b9e2 100644 --- a/include/urcu/static/rculfstack.h +++ b/include/urcu/static/rculfstack.h @@ -1,29 +1,15 @@ +// SPDX-FileCopyrightText: 2010 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + #ifndef _URCU_RCULFSTACK_STATIC_H #define _URCU_RCULFSTACK_STATIC_H /* - * rculfstack-static.h - * * Userspace RCU library - Lock-Free RCU Stack * - * Copyright 2010 - Mathieu Desnoyers - * * TO BE INCLUDED ONLY IN LGPL-COMPATIBLE CODE. See rculfstack.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 - * 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 @@ -83,7 +69,9 @@ int _cds_lfs_push_rcu(struct cds_lfs_stack_rcu *s, * uatomic_cmpxchg() implicit memory barrier orders earlier * stores to node before publication. */ - head = uatomic_cmpxchg(&s->head, old_head, node); + cmm_emit_legacy_smp_mb(); + head = uatomic_cmpxchg_mo(&s->head, old_head, node, + CMM_SEQ_CST, CMM_SEQ_CST); if (old_head == head) break; } @@ -108,7 +96,9 @@ _cds_lfs_pop_rcu(struct cds_lfs_stack_rcu *s) if (head) { struct cds_lfs_node_rcu *next = rcu_dereference(head->next); - if (uatomic_cmpxchg(&s->head, head, next) == head) { + if (uatomic_cmpxchg_mo(&s->head, head, next, + CMM_SEQ_CST, CMM_SEQ_CST) == head) { + cmm_emit_legacy_smp_mb(); return head; } else { /* Concurrent modification. Retry. */