| 1 | /* |
| 2 | * wfcqueue.c |
| 3 | * |
| 4 | * Userspace RCU library - Concurrent Queue with Wait-Free Enqueue/Blocking Dequeue |
| 5 | * |
| 6 | * Copyright 2010-2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
| 7 | * Copyright 2011-2012 - Lai Jiangshan <laijs@cn.fujitsu.com> |
| 8 | * |
| 9 | * This library is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU Lesser General Public |
| 11 | * License as published by the Free Software Foundation; either |
| 12 | * version 2.1 of the License, or (at your option) any later version. |
| 13 | * |
| 14 | * This library is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 | * Lesser General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU Lesser General Public |
| 20 | * License along with this library; if not, write to the Free Software |
| 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 22 | */ |
| 23 | |
| 24 | /* Do not #define _LGPL_SOURCE to ensure we can emit the wrapper symbols */ |
| 25 | #include "urcu/wfcqueue.h" |
| 26 | #include "urcu/static/wfcqueue.h" |
| 27 | |
| 28 | /* |
| 29 | * library wrappers to be used by non-LGPL compatible source code. |
| 30 | */ |
| 31 | |
| 32 | void cds_wfcq_node_init(struct cds_wfcq_node *node) |
| 33 | { |
| 34 | _cds_wfcq_node_init(node); |
| 35 | } |
| 36 | |
| 37 | void cds_wfcq_init(struct cds_wfcq_head *head, |
| 38 | struct cds_wfcq_tail *tail) |
| 39 | { |
| 40 | _cds_wfcq_init(head, tail); |
| 41 | } |
| 42 | |
| 43 | void __cds_wfcq_init(struct __cds_wfcq_head *head, |
| 44 | struct cds_wfcq_tail *tail) |
| 45 | { |
| 46 | ___cds_wfcq_init(head, tail); |
| 47 | } |
| 48 | |
| 49 | bool cds_wfcq_empty(cds_wfcq_head_ptr_t head, |
| 50 | struct cds_wfcq_tail *tail) |
| 51 | |
| 52 | { |
| 53 | return _cds_wfcq_empty(head, tail); |
| 54 | } |
| 55 | |
| 56 | bool cds_wfcq_enqueue(cds_wfcq_head_ptr_t head, |
| 57 | struct cds_wfcq_tail *tail, |
| 58 | struct cds_wfcq_node *node) |
| 59 | { |
| 60 | return _cds_wfcq_enqueue(head, tail, node); |
| 61 | } |
| 62 | |
| 63 | void cds_wfcq_dequeue_lock(struct cds_wfcq_head *head, |
| 64 | struct cds_wfcq_tail *tail) |
| 65 | { |
| 66 | _cds_wfcq_dequeue_lock(head, tail); |
| 67 | } |
| 68 | |
| 69 | void cds_wfcq_dequeue_unlock(struct cds_wfcq_head *head, |
| 70 | struct cds_wfcq_tail *tail) |
| 71 | { |
| 72 | _cds_wfcq_dequeue_unlock(head, tail); |
| 73 | } |
| 74 | |
| 75 | struct cds_wfcq_node *cds_wfcq_dequeue_blocking( |
| 76 | struct cds_wfcq_head *head, |
| 77 | struct cds_wfcq_tail *tail) |
| 78 | { |
| 79 | return _cds_wfcq_dequeue_blocking(head, tail); |
| 80 | } |
| 81 | |
| 82 | struct cds_wfcq_node *cds_wfcq_dequeue_with_state_blocking( |
| 83 | struct cds_wfcq_head *head, |
| 84 | struct cds_wfcq_tail *tail, |
| 85 | int *state) |
| 86 | { |
| 87 | return _cds_wfcq_dequeue_with_state_blocking(head, tail, state); |
| 88 | } |
| 89 | |
| 90 | enum cds_wfcq_ret cds_wfcq_splice_blocking( |
| 91 | struct cds_wfcq_head *dest_q_head, |
| 92 | struct cds_wfcq_tail *dest_q_tail, |
| 93 | struct cds_wfcq_head *src_q_head, |
| 94 | struct cds_wfcq_tail *src_q_tail) |
| 95 | { |
| 96 | return _cds_wfcq_splice_blocking(dest_q_head, dest_q_tail, |
| 97 | src_q_head, src_q_tail); |
| 98 | } |
| 99 | |
| 100 | struct cds_wfcq_node *__cds_wfcq_dequeue_blocking( |
| 101 | cds_wfcq_head_ptr_t head, |
| 102 | struct cds_wfcq_tail *tail) |
| 103 | { |
| 104 | return ___cds_wfcq_dequeue_blocking(head, tail); |
| 105 | } |
| 106 | |
| 107 | struct cds_wfcq_node *__cds_wfcq_dequeue_with_state_blocking( |
| 108 | cds_wfcq_head_ptr_t head, |
| 109 | struct cds_wfcq_tail *tail, |
| 110 | int *state) |
| 111 | { |
| 112 | return ___cds_wfcq_dequeue_with_state_blocking(head, tail, state); |
| 113 | } |
| 114 | |
| 115 | struct cds_wfcq_node *__cds_wfcq_dequeue_nonblocking( |
| 116 | cds_wfcq_head_ptr_t head, |
| 117 | struct cds_wfcq_tail *tail) |
| 118 | { |
| 119 | return ___cds_wfcq_dequeue_nonblocking(head, tail); |
| 120 | } |
| 121 | |
| 122 | struct cds_wfcq_node *__cds_wfcq_dequeue_with_state_nonblocking( |
| 123 | cds_wfcq_head_ptr_t head, |
| 124 | struct cds_wfcq_tail *tail, |
| 125 | int *state) |
| 126 | { |
| 127 | return ___cds_wfcq_dequeue_with_state_nonblocking(head, tail, state); |
| 128 | } |
| 129 | |
| 130 | enum cds_wfcq_ret __cds_wfcq_splice_blocking( |
| 131 | cds_wfcq_head_ptr_t dest_q_head, |
| 132 | struct cds_wfcq_tail *dest_q_tail, |
| 133 | cds_wfcq_head_ptr_t src_q_head, |
| 134 | struct cds_wfcq_tail *src_q_tail) |
| 135 | { |
| 136 | return ___cds_wfcq_splice_blocking(dest_q_head, dest_q_tail, |
| 137 | src_q_head, src_q_tail); |
| 138 | } |
| 139 | |
| 140 | enum cds_wfcq_ret __cds_wfcq_splice_nonblocking( |
| 141 | cds_wfcq_head_ptr_t dest_q_head, |
| 142 | struct cds_wfcq_tail *dest_q_tail, |
| 143 | cds_wfcq_head_ptr_t src_q_head, |
| 144 | struct cds_wfcq_tail *src_q_tail) |
| 145 | { |
| 146 | return ___cds_wfcq_splice_nonblocking(dest_q_head, dest_q_tail, |
| 147 | src_q_head, src_q_tail); |
| 148 | } |
| 149 | |
| 150 | struct cds_wfcq_node *__cds_wfcq_first_blocking( |
| 151 | cds_wfcq_head_ptr_t head, |
| 152 | struct cds_wfcq_tail *tail) |
| 153 | { |
| 154 | return ___cds_wfcq_first_blocking(head, tail); |
| 155 | } |
| 156 | |
| 157 | struct cds_wfcq_node *__cds_wfcq_first_nonblocking( |
| 158 | cds_wfcq_head_ptr_t head, |
| 159 | struct cds_wfcq_tail *tail) |
| 160 | { |
| 161 | return ___cds_wfcq_first_nonblocking(head, tail); |
| 162 | } |
| 163 | |
| 164 | struct cds_wfcq_node *__cds_wfcq_next_blocking( |
| 165 | cds_wfcq_head_ptr_t head, |
| 166 | struct cds_wfcq_tail *tail, |
| 167 | struct cds_wfcq_node *node) |
| 168 | { |
| 169 | return ___cds_wfcq_next_blocking(head, tail, node); |
| 170 | } |
| 171 | |
| 172 | struct cds_wfcq_node *__cds_wfcq_next_nonblocking( |
| 173 | cds_wfcq_head_ptr_t head, |
| 174 | struct cds_wfcq_tail *tail, |
| 175 | struct cds_wfcq_node *node) |
| 176 | { |
| 177 | return ___cds_wfcq_next_nonblocking(head, tail, node); |
| 178 | } |