wfcqueue: combine C++ API cds_wfcq_head_cast with overloading
[urcu.git] / include / urcu / wfcqueue.h
CommitLineData
8ad4ce58
MD
1#ifndef _URCU_WFCQUEUE_H
2#define _URCU_WFCQUEUE_H
3
4/*
47215721 5 * urcu/wfcqueue.h
8ad4ce58
MD
6 *
7 * Userspace RCU library - Concurrent Queue with Wait-Free Enqueue/Blocking Dequeue
8 *
9 * Copyright 2010-2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 * Copyright 2011-2012 - Lai Jiangshan <laijs@cn.fujitsu.com>
11 *
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public
14 * License as published by the Free Software Foundation; either
15 * version 2.1 of the License, or (at your option) any later version.
16 *
17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 */
26
27#include <pthread.h>
8ad4ce58
MD
28#include <stdbool.h>
29#include <urcu/compiler.h>
30#include <urcu/arch.h>
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36/*
37 * Concurrent queue with wait-free enqueue/blocking dequeue.
38 *
ebfd2673
MD
39 * This queue has been designed and implemented collaboratively by
40 * Mathieu Desnoyers and Lai Jiangshan. Inspired from
41 * half-wait-free/half-blocking queue implementation done by Paul E.
42 * McKenney.
8ad4ce58
MD
43 */
44
0b73c819 45#define CDS_WFCQ_WOULDBLOCK ((struct cds_wfcq_node *) -1UL)
47215721 46
23773356 47enum cds_wfcq_ret {
f878b49e 48 CDS_WFCQ_RET_WOULDBLOCK = -1,
23773356
MD
49 CDS_WFCQ_RET_DEST_EMPTY = 0,
50 CDS_WFCQ_RET_DEST_NON_EMPTY = 1,
51 CDS_WFCQ_RET_SRC_EMPTY = 2,
52};
53
eec791af
MD
54enum cds_wfcq_state {
55 CDS_WFCQ_STATE_LAST = (1U << 0),
56};
57
8ad4ce58
MD
58struct cds_wfcq_node {
59 struct cds_wfcq_node *next;
60};
61
62/*
63 * Do not put head and tail on the same cache-line if concurrent
64 * enqueue/dequeue are expected from many CPUs. This eliminates
65 * false-sharing between enqueue and dequeue.
66 */
f637f191
MD
67struct __cds_wfcq_head {
68 struct cds_wfcq_node node;
69};
70
8ad4ce58
MD
71struct cds_wfcq_head {
72 struct cds_wfcq_node node;
73 pthread_mutex_t lock;
74};
75
f637f191 76/*
0cdbb569 77 * In C, the transparent union allows calling functions that work on both
f637f191
MD
78 * struct cds_wfcq_head and struct __cds_wfcq_head on any of those two
79 * types.
0cdbb569
MD
80 *
81 * In C++, implement static inline wrappers using function overloading
82 * to obtain an API similar to C.
f637f191 83 */
5135c0fd 84typedef union {
f637f191
MD
85 struct __cds_wfcq_head *_h;
86 struct cds_wfcq_head *h;
0cdbb569 87} caa_c_transparent_union cds_wfcq_head_ptr_t;
f637f191 88
0cdbb569 89#ifndef __cplusplus
4d0d7cbc
MD
90/*
91 * This static inline is only present for compatibility with C++. It is
92 * effect-less in C.
93 */
94static inline struct __cds_wfcq_head *__cds_wfcq_head_cast(struct __cds_wfcq_head *head)
95{
96 return head;
97}
98
99/*
100 * This static inline is only present for compatibility with C++. It is
101 * effect-less in C.
102 */
103static inline struct cds_wfcq_head *cds_wfcq_head_cast(struct cds_wfcq_head *head)
104{
105 return head;
106}
107#else /* #ifndef __cplusplus */
108
0cdbb569 109/*
aaf0064b
MD
110 * This static inline is used by internally in the static inline
111 * implementation of the API.
0cdbb569 112 */
4d0d7cbc
MD
113static inline cds_wfcq_head_ptr_t __cds_wfcq_head_cast(struct __cds_wfcq_head *head)
114{
115 cds_wfcq_head_ptr_t ret = { ._h = head };
116 return ret;
117}
0cdbb569
MD
118
119/*
aaf0064b
MD
120 * This static inline is used by internally in the static inline
121 * implementation of the API.
0cdbb569 122 */
4d0d7cbc
MD
123static inline cds_wfcq_head_ptr_t cds_wfcq_head_cast(struct cds_wfcq_head *head)
124{
125 cds_wfcq_head_ptr_t ret = { .h = head };
126 return ret;
127}
128#endif /* #else #ifndef __cplusplus */
129
8ad4ce58
MD
130struct cds_wfcq_tail {
131 struct cds_wfcq_node *p;
132};
133
134#ifdef _LGPL_SOURCE
135
136#include <urcu/static/wfcqueue.h>
137
138#define cds_wfcq_node_init _cds_wfcq_node_init
139#define cds_wfcq_init _cds_wfcq_init
b4edfa81 140#define __cds_wfcq_init ___cds_wfcq_init
200d100e 141#define cds_wfcq_destroy _cds_wfcq_destroy
8ad4ce58
MD
142#define cds_wfcq_empty _cds_wfcq_empty
143#define cds_wfcq_enqueue _cds_wfcq_enqueue
144
145/* Dequeue locking */
146#define cds_wfcq_dequeue_lock _cds_wfcq_dequeue_lock
147#define cds_wfcq_dequeue_unlock _cds_wfcq_dequeue_unlock
148
149/* Locking performed within cds_wfcq calls. */
150#define cds_wfcq_dequeue_blocking _cds_wfcq_dequeue_blocking
eec791af
MD
151#define cds_wfcq_dequeue_with_state_blocking \
152 _cds_wfcq_dequeue_with_state_blocking
8ad4ce58
MD
153#define cds_wfcq_splice_blocking _cds_wfcq_splice_blocking
154#define cds_wfcq_first_blocking _cds_wfcq_first_blocking
155#define cds_wfcq_next_blocking _cds_wfcq_next_blocking
156
157/* Locking ensured by caller by holding cds_wfcq_dequeue_lock() */
158#define __cds_wfcq_dequeue_blocking ___cds_wfcq_dequeue_blocking
eec791af
MD
159#define __cds_wfcq_dequeue_with_state_blocking \
160 ___cds_wfcq_dequeue_with_state_blocking
8ad4ce58
MD
161#define __cds_wfcq_splice_blocking ___cds_wfcq_splice_blocking
162#define __cds_wfcq_first_blocking ___cds_wfcq_first_blocking
163#define __cds_wfcq_next_blocking ___cds_wfcq_next_blocking
164
47215721
MD
165/*
166 * Locking ensured by caller by holding cds_wfcq_dequeue_lock().
167 * Non-blocking: deque, first, next return CDS_WFCQ_WOULDBLOCK if they
168 * need to block. splice returns nonzero if it needs to block.
169 */
170#define __cds_wfcq_dequeue_nonblocking ___cds_wfcq_dequeue_nonblocking
eec791af
MD
171#define __cds_wfcq_dequeue_with_state_nonblocking \
172 ___cds_wfcq_dequeue_with_state_nonblocking
47215721
MD
173#define __cds_wfcq_splice_nonblocking ___cds_wfcq_splice_nonblocking
174#define __cds_wfcq_first_nonblocking ___cds_wfcq_first_nonblocking
175#define __cds_wfcq_next_nonblocking ___cds_wfcq_next_nonblocking
176
8ad4ce58
MD
177#else /* !_LGPL_SOURCE */
178
179/*
180 * Mutual exclusion of cds_wfcq_* / __cds_wfcq_* API
181 *
f878b49e
MD
182 * Synchronization table:
183 *
184 * External synchronization techniques described in the API below is
185 * required between pairs marked with "X". No external synchronization
186 * required between pairs marked with "-".
187 *
188 * Legend:
189 * [1] cds_wfcq_enqueue
190 * [2] __cds_wfcq_splice (destination queue)
191 * [3] __cds_wfcq_dequeue
192 * [4] __cds_wfcq_splice (source queue)
193 * [5] __cds_wfcq_first
194 * [6] __cds_wfcq_next
195 *
196 * [1] [2] [3] [4] [5] [6]
197 * [1] - - - - - -
198 * [2] - - - - - -
199 * [3] - - X X X X
200 * [4] - - X - X X
201 * [5] - - X X - -
202 * [6] - - X X - -
203 *
8ad4ce58
MD
204 * Mutual exclusion can be ensured by holding cds_wfcq_dequeue_lock().
205 *
206 * For convenience, cds_wfcq_dequeue_blocking() and
207 * cds_wfcq_splice_blocking() hold the dequeue lock.
1fe734e1
MD
208 *
209 * Besides locking, mutual exclusion of dequeue, splice and iteration
210 * can be ensured by performing all of those operations from a single
211 * thread, without requiring any lock.
8ad4ce58
MD
212 */
213
214/*
215 * cds_wfcq_node_init: initialize wait-free queue node.
216 */
217extern void cds_wfcq_node_init(struct cds_wfcq_node *node);
218
219/*
200d100e
MD
220 * cds_wfcq_init: initialize wait-free queue. Pair with
221 * cds_wfcq_destroy().
8ad4ce58
MD
222 */
223extern void cds_wfcq_init(struct cds_wfcq_head *head,
224 struct cds_wfcq_tail *tail);
225
f637f191 226/*
200d100e
MD
227 * cds_wfcq_destroy: destroy wait-free queue. Pair with
228 * cds_wfcq_init().
229 */
230extern void cds_wfcq_destroy(struct cds_wfcq_head *head,
231 struct cds_wfcq_tail *tail);
232
233/*
234 * __cds_wfcq_init: initialize wait-free queue (without lock). Don't
235 * pair with any destroy function.
f637f191
MD
236 */
237extern void __cds_wfcq_init(struct __cds_wfcq_head *head,
238 struct cds_wfcq_tail *tail);
239
8ad4ce58
MD
240/*
241 * cds_wfcq_empty: return whether wait-free queue is empty.
242 *
243 * No memory barrier is issued. No mutual exclusion is required.
244 */
f637f191 245extern bool cds_wfcq_empty(cds_wfcq_head_ptr_t head,
8ad4ce58
MD
246 struct cds_wfcq_tail *tail);
247
248/*
249 * cds_wfcq_dequeue_lock: take the dequeue mutual exclusion lock.
250 */
251extern void cds_wfcq_dequeue_lock(struct cds_wfcq_head *head,
252 struct cds_wfcq_tail *tail);
253
254/*
255 * cds_wfcq_dequeue_unlock: release the dequeue mutual exclusion lock.
256 */
257extern void cds_wfcq_dequeue_unlock(struct cds_wfcq_head *head,
258 struct cds_wfcq_tail *tail);
259
260/*
261 * cds_wfcq_enqueue: enqueue a node into a wait-free queue.
262 *
263 * Issues a full memory barrier before enqueue. No mutual exclusion is
264 * required.
23773356
MD
265 *
266 * Returns false if the queue was empty prior to adding the node.
267 * Returns true otherwise.
8ad4ce58 268 */
f637f191 269extern bool cds_wfcq_enqueue(cds_wfcq_head_ptr_t head,
8ad4ce58
MD
270 struct cds_wfcq_tail *tail,
271 struct cds_wfcq_node *node);
272
273/*
274 * cds_wfcq_dequeue_blocking: dequeue a node from a wait-free queue.
275 *
276 * Content written into the node before enqueue is guaranteed to be
277 * consistent, but no other memory ordering is ensured.
278 * It is valid to reuse and free a dequeued node immediately.
ffa11a18 279 * Mutual exclusion with cds_wfcq_dequeue_blocking and dequeue lock is
1fe734e1 280 * ensured.
8ad4ce58
MD
281 */
282extern struct cds_wfcq_node *cds_wfcq_dequeue_blocking(
283 struct cds_wfcq_head *head,
284 struct cds_wfcq_tail *tail);
285
eec791af
MD
286/*
287 * cds_wfcq_dequeue_with_state_blocking: dequeue with state.
288 *
289 * Same as cds_wfcq_dequeue_blocking, but saves whether dequeueing the
290 * last node of the queue into state (CDS_WFCQ_STATE_LAST).
291 */
292extern struct cds_wfcq_node *cds_wfcq_dequeue_with_state_blocking(
293 struct cds_wfcq_head *head,
294 struct cds_wfcq_tail *tail,
295 int *state);
296
8ad4ce58
MD
297/*
298 * cds_wfcq_splice_blocking: enqueue all src_q nodes at the end of dest_q.
299 *
300 * Dequeue all nodes from src_q.
301 * dest_q must be already initialized.
302 * Content written into the node before enqueue is guaranteed to be
303 * consistent, but no other memory ordering is ensured.
ffa11a18 304 * Mutual exclusion with cds_wfcq_dequeue_blocking and dequeue lock is
1fe734e1 305 * ensured.
23773356
MD
306 *
307 * Returns enum cds_wfcq_ret which indicates the state of the src or
b94aaf6f 308 * dest queue.
8ad4ce58 309 */
23773356 310extern enum cds_wfcq_ret cds_wfcq_splice_blocking(
8ad4ce58
MD
311 struct cds_wfcq_head *dest_q_head,
312 struct cds_wfcq_tail *dest_q_tail,
313 struct cds_wfcq_head *src_q_head,
314 struct cds_wfcq_tail *src_q_tail);
315
316/*
47215721 317 * __cds_wfcq_dequeue_blocking: dequeue a node from a wait-free queue.
8ad4ce58
MD
318 *
319 * Content written into the node before enqueue is guaranteed to be
320 * consistent, but no other memory ordering is ensured.
321 * It is valid to reuse and free a dequeued node immediately.
1fe734e1
MD
322 * Dequeue/splice/iteration mutual exclusion should be ensured by the
323 * caller.
8ad4ce58
MD
324 */
325extern struct cds_wfcq_node *__cds_wfcq_dequeue_blocking(
f637f191 326 cds_wfcq_head_ptr_t head,
8ad4ce58
MD
327 struct cds_wfcq_tail *tail);
328
eec791af
MD
329/*
330 * __cds_wfcq_dequeue_with_state_blocking: dequeue with state.
331 *
332 * Same as __cds_wfcq_dequeue_blocking, but saves whether dequeueing the
333 * last node of the queue into state (CDS_WFCQ_STATE_LAST).
334 */
335extern struct cds_wfcq_node *__cds_wfcq_dequeue_with_state_blocking(
f637f191 336 cds_wfcq_head_ptr_t head,
eec791af
MD
337 struct cds_wfcq_tail *tail,
338 int *state);
339
47215721
MD
340/*
341 * __cds_wfcq_dequeue_nonblocking: dequeue a node from a wait-free queue.
342 *
343 * Same as __cds_wfcq_dequeue_blocking, but returns CDS_WFCQ_WOULDBLOCK
344 * if it needs to block.
345 */
346extern struct cds_wfcq_node *__cds_wfcq_dequeue_nonblocking(
f637f191 347 cds_wfcq_head_ptr_t head,
47215721
MD
348 struct cds_wfcq_tail *tail);
349
eec791af
MD
350/*
351 * __cds_wfcq_dequeue_with_state_blocking: dequeue with state.
352 *
353 * Same as __cds_wfcq_dequeue_nonblocking, but saves whether dequeueing
354 * the last node of the queue into state (CDS_WFCQ_STATE_LAST).
355 */
356extern struct cds_wfcq_node *__cds_wfcq_dequeue_with_state_nonblocking(
f637f191 357 cds_wfcq_head_ptr_t head,
eec791af
MD
358 struct cds_wfcq_tail *tail,
359 int *state);
360
8ad4ce58
MD
361/*
362 * __cds_wfcq_splice_blocking: enqueue all src_q nodes at the end of dest_q.
363 *
364 * Dequeue all nodes from src_q.
365 * dest_q must be already initialized.
f878b49e
MD
366 * Mutual exclusion for src_q should be ensured by the caller as
367 * specified in the "Synchronisation table".
23773356 368 * Returns enum cds_wfcq_ret which indicates the state of the src or
f878b49e 369 * dest queue. Never returns CDS_WFCQ_RET_WOULDBLOCK.
8ad4ce58 370 */
23773356 371extern enum cds_wfcq_ret __cds_wfcq_splice_blocking(
f637f191 372 cds_wfcq_head_ptr_t dest_q_head,
8ad4ce58 373 struct cds_wfcq_tail *dest_q_tail,
f637f191 374 cds_wfcq_head_ptr_t src_q_head,
8ad4ce58
MD
375 struct cds_wfcq_tail *src_q_tail);
376
47215721
MD
377/*
378 * __cds_wfcq_splice_nonblocking: enqueue all src_q nodes at the end of dest_q.
379 *
23773356
MD
380 * Same as __cds_wfcq_splice_blocking, but returns
381 * CDS_WFCQ_RET_WOULDBLOCK if it needs to block.
47215721 382 */
23773356 383extern enum cds_wfcq_ret __cds_wfcq_splice_nonblocking(
f637f191 384 cds_wfcq_head_ptr_t dest_q_head,
47215721 385 struct cds_wfcq_tail *dest_q_tail,
f637f191 386 cds_wfcq_head_ptr_t src_q_head,
47215721
MD
387 struct cds_wfcq_tail *src_q_tail);
388
8ad4ce58
MD
389/*
390 * __cds_wfcq_first_blocking: get first node of a queue, without dequeuing.
391 *
392 * Content written into the node before enqueue is guaranteed to be
393 * consistent, but no other memory ordering is ensured.
1fe734e1
MD
394 * Dequeue/splice/iteration mutual exclusion should be ensured by the
395 * caller.
f94061a3
MD
396 *
397 * Used by for-like iteration macros:
398 * __cds_wfcq_for_each_blocking()
399 * __cds_wfcq_for_each_blocking_safe()
131a29a6
MD
400 *
401 * Returns NULL if queue is empty, first node otherwise.
8ad4ce58
MD
402 */
403extern struct cds_wfcq_node *__cds_wfcq_first_blocking(
f637f191 404 cds_wfcq_head_ptr_t head,
8ad4ce58
MD
405 struct cds_wfcq_tail *tail);
406
47215721
MD
407/*
408 * __cds_wfcq_first_nonblocking: get first node of a queue, without dequeuing.
409 *
410 * Same as __cds_wfcq_first_blocking, but returns CDS_WFCQ_WOULDBLOCK if
411 * it needs to block.
412 */
413extern struct cds_wfcq_node *__cds_wfcq_first_nonblocking(
f637f191 414 cds_wfcq_head_ptr_t head,
47215721
MD
415 struct cds_wfcq_tail *tail);
416
8ad4ce58
MD
417/*
418 * __cds_wfcq_next_blocking: get next node of a queue, without dequeuing.
419 *
420 * Content written into the node before enqueue is guaranteed to be
421 * consistent, but no other memory ordering is ensured.
1fe734e1
MD
422 * Dequeue/splice/iteration mutual exclusion should be ensured by the
423 * caller.
f94061a3
MD
424 *
425 * Used by for-like iteration macros:
426 * __cds_wfcq_for_each_blocking()
427 * __cds_wfcq_for_each_blocking_safe()
131a29a6
MD
428 *
429 * Returns NULL if reached end of queue, non-NULL next queue node
430 * otherwise.
8ad4ce58
MD
431 */
432extern struct cds_wfcq_node *__cds_wfcq_next_blocking(
f637f191 433 cds_wfcq_head_ptr_t head,
8ad4ce58
MD
434 struct cds_wfcq_tail *tail,
435 struct cds_wfcq_node *node);
436
47215721
MD
437/*
438 * __cds_wfcq_next_blocking: get next node of a queue, without dequeuing.
439 *
440 * Same as __cds_wfcq_next_blocking, but returns CDS_WFCQ_WOULDBLOCK if
441 * it needs to block.
442 */
443extern struct cds_wfcq_node *__cds_wfcq_next_nonblocking(
f637f191 444 cds_wfcq_head_ptr_t head,
47215721
MD
445 struct cds_wfcq_tail *tail,
446 struct cds_wfcq_node *node);
447
8ad4ce58
MD
448#endif /* !_LGPL_SOURCE */
449
450/*
451 * __cds_wfcq_for_each_blocking: Iterate over all nodes in a queue,
452 * without dequeuing them.
f637f191 453 * @head: head of the queue (struct cds_wfcq_head or __cds_wfcq_head pointer).
8ad4ce58
MD
454 * @tail: tail of the queue (struct cds_wfcq_tail pointer).
455 * @node: iterator on the queue (struct cds_wfcq_node pointer).
456 *
457 * Content written into each node before enqueue is guaranteed to be
458 * consistent, but no other memory ordering is ensured.
1fe734e1
MD
459 * Dequeue/splice/iteration mutual exclusion should be ensured by the
460 * caller.
8ad4ce58
MD
461 */
462#define __cds_wfcq_for_each_blocking(head, tail, node) \
463 for (node = __cds_wfcq_first_blocking(head, tail); \
464 node != NULL; \
465 node = __cds_wfcq_next_blocking(head, tail, node))
466
467/*
468 * __cds_wfcq_for_each_blocking_safe: Iterate over all nodes in a queue,
469 * without dequeuing them. Safe against deletion.
f637f191 470 * @head: head of the queue (struct cds_wfcq_head or __cds_wfcq_head pointer).
8ad4ce58
MD
471 * @tail: tail of the queue (struct cds_wfcq_tail pointer).
472 * @node: iterator on the queue (struct cds_wfcq_node pointer).
473 * @n: struct cds_wfcq_node pointer holding the next pointer (used
474 * internally).
475 *
476 * Content written into each node before enqueue is guaranteed to be
477 * consistent, but no other memory ordering is ensured.
1fe734e1
MD
478 * Dequeue/splice/iteration mutual exclusion should be ensured by the
479 * caller.
8ad4ce58
MD
480 */
481#define __cds_wfcq_for_each_blocking_safe(head, tail, node, n) \
482 for (node = __cds_wfcq_first_blocking(head, tail), \
483 n = (node ? __cds_wfcq_next_blocking(head, tail, node) : NULL); \
484 node != NULL; \
485 node = n, n = (node ? __cds_wfcq_next_blocking(head, tail, node) : NULL))
486
487#ifdef __cplusplus
488}
0cdbb569
MD
489
490/*
491 * In C++, implement static inline wrappers using function overloading
492 * to obtain an API similar to C.
493 */
494
aaf0064b
MD
495static inline cds_wfcq_head_ptr_t cds_wfcq_head_cast_cpp(struct __cds_wfcq_head *head)
496{
497 cds_wfcq_head_ptr_t ret = { ._h = head };
498 return ret;
499}
500
501static inline cds_wfcq_head_ptr_t cds_wfcq_head_cast_cpp(struct cds_wfcq_head *head)
502{
503 cds_wfcq_head_ptr_t ret = { .h = head };
504 return ret;
505}
506
0cdbb569
MD
507static inline bool cds_wfcq_empty(struct __cds_wfcq_head *head,
508 struct cds_wfcq_tail *tail)
509{
aaf0064b 510 return cds_wfcq_empty(cds_wfcq_head_cast_cpp(head), tail);
0cdbb569
MD
511}
512
513static inline bool cds_wfcq_empty(struct cds_wfcq_head *head,
514 struct cds_wfcq_tail *tail)
515{
aaf0064b 516 return cds_wfcq_empty(cds_wfcq_head_cast_cpp(head), tail);
0cdbb569
MD
517}
518
519static inline bool cds_wfcq_enqueue(struct __cds_wfcq_head *head,
520 struct cds_wfcq_tail *tail,
521 struct cds_wfcq_node *node)
522{
aaf0064b 523 return cds_wfcq_enqueue(cds_wfcq_head_cast_cpp(head), tail, node);
0cdbb569
MD
524}
525
526static inline bool cds_wfcq_enqueue(struct cds_wfcq_head *head,
527 struct cds_wfcq_tail *tail,
528 struct cds_wfcq_node *node)
529{
aaf0064b 530 return cds_wfcq_enqueue(cds_wfcq_head_cast_cpp(head), tail, node);
0cdbb569
MD
531}
532
533static inline struct cds_wfcq_node *__cds_wfcq_dequeue_blocking(
534 struct __cds_wfcq_head *head,
535 struct cds_wfcq_tail *tail)
536{
aaf0064b 537 return __cds_wfcq_dequeue_blocking(cds_wfcq_head_cast_cpp(head), tail);
0cdbb569
MD
538}
539
540static inline struct cds_wfcq_node *__cds_wfcq_dequeue_blocking(
541 struct cds_wfcq_head *head,
542 struct cds_wfcq_tail *tail)
543{
aaf0064b 544 return __cds_wfcq_dequeue_blocking(cds_wfcq_head_cast_cpp(head), tail);
0cdbb569
MD
545}
546
547static inline struct cds_wfcq_node *__cds_wfcq_dequeue_with_state_blocking(
548 struct __cds_wfcq_head *head,
549 struct cds_wfcq_tail *tail,
550 int *state)
551{
aaf0064b 552 return __cds_wfcq_dequeue_with_state_blocking(cds_wfcq_head_cast_cpp(head),
0cdbb569
MD
553 tail, state);
554}
555
556static inline struct cds_wfcq_node *__cds_wfcq_dequeue_with_state_blocking(
557 struct cds_wfcq_head *head,
558 struct cds_wfcq_tail *tail,
559 int *state)
560{
aaf0064b 561 return __cds_wfcq_dequeue_with_state_blocking(cds_wfcq_head_cast_cpp(head),
0cdbb569
MD
562 tail, state);
563}
564
565static inline struct cds_wfcq_node *__cds_wfcq_dequeue_nonblocking(
566 struct __cds_wfcq_head *head,
567 struct cds_wfcq_tail *tail)
568{
aaf0064b 569 return __cds_wfcq_dequeue_nonblocking(cds_wfcq_head_cast_cpp(head), tail);
0cdbb569
MD
570}
571
572static inline struct cds_wfcq_node *__cds_wfcq_dequeue_nonblocking(
573 struct cds_wfcq_head *head,
574 struct cds_wfcq_tail *tail)
575{
aaf0064b 576 return __cds_wfcq_dequeue_nonblocking(cds_wfcq_head_cast_cpp(head), tail);
0cdbb569
MD
577}
578
579static inline struct cds_wfcq_node *__cds_wfcq_dequeue_with_state_nonblocking(
580 struct __cds_wfcq_head *head,
581 struct cds_wfcq_tail *tail,
582 int *state)
583{
aaf0064b 584 return __cds_wfcq_dequeue_with_state_nonblocking(cds_wfcq_head_cast_cpp(head),
0cdbb569
MD
585 tail, state);
586}
587
588static inline struct cds_wfcq_node *__cds_wfcq_dequeue_with_state_nonblocking(
589 struct cds_wfcq_head *head,
590 struct cds_wfcq_tail *tail,
591 int *state)
592{
aaf0064b 593 return __cds_wfcq_dequeue_with_state_nonblocking(cds_wfcq_head_cast_cpp(head),
0cdbb569
MD
594 tail, state);
595}
596
597/* Support the power set of type combinations. */
598static inline enum cds_wfcq_ret __cds_wfcq_splice_blocking(
599 struct __cds_wfcq_head *dest_q_head,
600 struct cds_wfcq_tail *dest_q_tail,
601 struct __cds_wfcq_head *src_q_head,
602 struct cds_wfcq_tail *src_q_tail)
603{
aaf0064b 604 return __cds_wfcq_splice_blocking(cds_wfcq_head_cast_cpp(dest_q_head),
0cdbb569 605 dest_q_tail,
aaf0064b 606 cds_wfcq_head_cast_cpp(src_q_head),
0cdbb569
MD
607 src_q_tail);
608}
609
610static inline enum cds_wfcq_ret __cds_wfcq_splice_blocking(
611 struct cds_wfcq_head *dest_q_head,
612 struct cds_wfcq_tail *dest_q_tail,
613 struct __cds_wfcq_head *src_q_head,
614 struct cds_wfcq_tail *src_q_tail)
615{
aaf0064b 616 return __cds_wfcq_splice_blocking(cds_wfcq_head_cast_cpp(dest_q_head),
0cdbb569 617 dest_q_tail,
aaf0064b 618 cds_wfcq_head_cast_cpp(src_q_head),
0cdbb569
MD
619 src_q_tail);
620}
621
622static inline enum cds_wfcq_ret __cds_wfcq_splice_blocking(
623 struct __cds_wfcq_head *dest_q_head,
624 struct cds_wfcq_tail *dest_q_tail,
625 struct cds_wfcq_head *src_q_head,
626 struct cds_wfcq_tail *src_q_tail)
627{
aaf0064b 628 return __cds_wfcq_splice_blocking(cds_wfcq_head_cast_cpp(dest_q_head),
0cdbb569 629 dest_q_tail,
aaf0064b 630 cds_wfcq_head_cast_cpp(src_q_head),
0cdbb569
MD
631 src_q_tail);
632}
633
634static inline enum cds_wfcq_ret __cds_wfcq_splice_blocking(
635 struct cds_wfcq_head *dest_q_head,
636 struct cds_wfcq_tail *dest_q_tail,
637 struct cds_wfcq_head *src_q_head,
638 struct cds_wfcq_tail *src_q_tail)
639{
aaf0064b 640 return __cds_wfcq_splice_blocking(cds_wfcq_head_cast_cpp(dest_q_head),
0cdbb569 641 dest_q_tail,
aaf0064b 642 cds_wfcq_head_cast_cpp(src_q_head),
0cdbb569
MD
643 src_q_tail);
644}
645
646/* Support the power set of type combinations. */
647static inline enum cds_wfcq_ret __cds_wfcq_splice_nonblocking(
648 struct __cds_wfcq_head *dest_q_head,
649 struct cds_wfcq_tail *dest_q_tail,
650 struct __cds_wfcq_head *src_q_head,
651 struct cds_wfcq_tail *src_q_tail)
652{
aaf0064b 653 return __cds_wfcq_splice_nonblocking(cds_wfcq_head_cast_cpp(dest_q_head),
0cdbb569 654 dest_q_tail,
aaf0064b 655 cds_wfcq_head_cast_cpp(src_q_head),
0cdbb569
MD
656 src_q_tail);
657}
658
659static inline enum cds_wfcq_ret __cds_wfcq_splice_nonblocking(
660 struct cds_wfcq_head *dest_q_head,
661 struct cds_wfcq_tail *dest_q_tail,
662 struct __cds_wfcq_head *src_q_head,
663 struct cds_wfcq_tail *src_q_tail)
664{
aaf0064b 665 return __cds_wfcq_splice_nonblocking(cds_wfcq_head_cast_cpp(dest_q_head),
0cdbb569 666 dest_q_tail,
aaf0064b 667 cds_wfcq_head_cast_cpp(src_q_head),
0cdbb569
MD
668 src_q_tail);
669}
670
671static inline enum cds_wfcq_ret __cds_wfcq_splice_nonblocking(
672 struct __cds_wfcq_head *dest_q_head,
673 struct cds_wfcq_tail *dest_q_tail,
674 struct cds_wfcq_head *src_q_head,
675 struct cds_wfcq_tail *src_q_tail)
676{
aaf0064b 677 return __cds_wfcq_splice_nonblocking(cds_wfcq_head_cast_cpp(dest_q_head),
0cdbb569 678 dest_q_tail,
aaf0064b 679 cds_wfcq_head_cast_cpp(src_q_head),
0cdbb569
MD
680 src_q_tail);
681}
682
683static inline enum cds_wfcq_ret __cds_wfcq_splice_nonblocking(
684 struct cds_wfcq_head *dest_q_head,
685 struct cds_wfcq_tail *dest_q_tail,
686 struct cds_wfcq_head *src_q_head,
687 struct cds_wfcq_tail *src_q_tail)
688{
aaf0064b 689 return __cds_wfcq_splice_nonblocking(cds_wfcq_head_cast_cpp(dest_q_head),
0cdbb569 690 dest_q_tail,
aaf0064b 691 cds_wfcq_head_cast_cpp(src_q_head),
0cdbb569
MD
692 src_q_tail);
693}
694
695static inline struct cds_wfcq_node *__cds_wfcq_first_blocking(
696 struct __cds_wfcq_head *head,
697 struct cds_wfcq_tail *tail)
698{
aaf0064b 699 return __cds_wfcq_first_blocking(cds_wfcq_head_cast_cpp(head), tail);
0cdbb569
MD
700}
701
702static inline struct cds_wfcq_node *__cds_wfcq_first_blocking(
703 struct cds_wfcq_head *head,
704 struct cds_wfcq_tail *tail)
705{
aaf0064b 706 return __cds_wfcq_first_blocking(cds_wfcq_head_cast_cpp(head), tail);
0cdbb569
MD
707}
708
709static inline struct cds_wfcq_node *__cds_wfcq_first_nonblocking(
710 struct __cds_wfcq_head *head,
711 struct cds_wfcq_tail *tail)
712{
aaf0064b 713 return __cds_wfcq_first_nonblocking(cds_wfcq_head_cast_cpp(head), tail);
0cdbb569
MD
714}
715
716static inline struct cds_wfcq_node *__cds_wfcq_first_nonblocking(
717 struct cds_wfcq_head *head,
718 struct cds_wfcq_tail *tail)
719{
aaf0064b 720 return __cds_wfcq_first_nonblocking(cds_wfcq_head_cast_cpp(head), tail);
0cdbb569
MD
721}
722
723static inline struct cds_wfcq_node *__cds_wfcq_next_blocking(
724 struct __cds_wfcq_head *head,
725 struct cds_wfcq_tail *tail,
726 struct cds_wfcq_node *node)
727{
aaf0064b 728 return __cds_wfcq_next_blocking(cds_wfcq_head_cast_cpp(head), tail, node);
0cdbb569
MD
729}
730
731static inline struct cds_wfcq_node *__cds_wfcq_next_blocking(
732 struct cds_wfcq_head *head,
733 struct cds_wfcq_tail *tail,
734 struct cds_wfcq_node *node)
735{
aaf0064b 736 return __cds_wfcq_next_blocking(cds_wfcq_head_cast_cpp(head), tail, node);
0cdbb569
MD
737}
738
739static inline struct cds_wfcq_node *__cds_wfcq_next_nonblocking(
740 struct __cds_wfcq_head *head,
741 struct cds_wfcq_tail *tail,
742 struct cds_wfcq_node *node)
743{
aaf0064b 744 return __cds_wfcq_next_nonblocking(cds_wfcq_head_cast_cpp(head), tail, node);
0cdbb569
MD
745}
746
747static inline struct cds_wfcq_node *__cds_wfcq_next_nonblocking(
748 struct cds_wfcq_head *head,
749 struct cds_wfcq_tail *tail,
750 struct cds_wfcq_node *node)
751{
aaf0064b 752 return __cds_wfcq_next_nonblocking(cds_wfcq_head_cast_cpp(head), tail, node);
0cdbb569
MD
753}
754
8ad4ce58
MD
755#endif
756
757#endif /* _URCU_WFCQUEUE_H */
This page took 0.071619 seconds and 4 git commands to generate.