1 #ifndef _URCU_DEFER_STATIC_H
2 #define _URCU_DEFER_STATIC_H
7 * Userspace RCU header - memory reclamation.
9 * TO BE INCLUDED ONLY IN LGPL-COMPATIBLE CODE. See urcu-defer.h for linking
10 * dynamically with the userspace rcu reclamation library.
12 * Copyright (c) 2009 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
13 * Copyright (c) 2009 Paul E. McKenney, IBM Corporation.
15 * This library is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU Lesser General Public
17 * License as published by the Free Software Foundation; either
18 * version 2.1 of the License, or (at your option) any later version.
20 * This library is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 * Lesser General Public License for more details.
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
29 * IBM's contributions to this file may be relicensed under LGPLv2 or later.
35 #include <urcu/compiler.h>
36 #include <urcu/arch.h>
37 #include <urcu/uatomic_arch.h>
38 #include <urcu/list.h>
39 #include <urcu/system.h>
46 * Number of entries in the per-thread defer queue. Must be power of 2.
48 #define DEFER_QUEUE_SIZE (1 << 12)
49 #define DEFER_QUEUE_MASK (DEFER_QUEUE_SIZE - 1)
52 * Typically, data is aligned at least on the architecture size.
53 * Use lowest bit to indicate that the current callback is changing.
54 * Assumes that (void *)-2L is not used often. Used to encode non-aligned
55 * functions and non-aligned data using extra space.
56 * We encode the (void *)-2L fct as: -2L, fct, data.
57 * We encode the (void *)-2L data as: -2L, fct, data.
58 * Here, DQ_FCT_MARK == ~DQ_FCT_BIT. Required for the test order.
60 #define DQ_FCT_BIT (1 << 0)
61 #define DQ_IS_FCT_BIT(x) ((unsigned long)(x) & DQ_FCT_BIT)
62 #define DQ_SET_FCT_BIT(x) \
63 (x = (void *)((unsigned long)(x) | DQ_FCT_BIT))
64 #define DQ_CLEAR_FCT_BIT(x) \
65 (x = (void *)((unsigned long)(x) & ~DQ_FCT_BIT))
66 #define DQ_FCT_MARK ((void *)(~DQ_FCT_BIT))
69 * This code section can only be included in LGPL 2.1 compatible source code.
70 * See below for the function call wrappers which can be used in code meant to
71 * be only linked with the Userspace RCU library. This comes with a small
72 * performance degradation on the read-side due to the added function calls.
73 * This is required to permit relinking with newer versions of the library.
77 #define rcu_assert(args...) assert(args)
79 #define rcu_assert(args...)
84 * Contains pointers. Encoded to save space when same callback is often used.
85 * When looking up the next item:
86 * - if DQ_FCT_BIT is set, set the current callback to DQ_CLEAR_FCT_BIT(ptr)
87 * - next element contains pointer to data.
88 * - else if item == DQ_FCT_MARK
89 * - set the current callback to next element ptr
90 * - following next element contains pointer to data.
91 * - else current element contains data
94 unsigned long head
; /* add element at head */
95 void *last_fct_in
; /* last fct pointer encoded */
96 unsigned long tail
; /* next element to remove at tail */
97 void *last_fct_out
; /* last fct pointer encoded */
99 /* registry information */
100 unsigned long last_head
;
101 struct cds_list_head list
; /* list of thread queues */
108 #endif /* _URCU_DEFER_STATIC_H */
This page took 0.031963 seconds and 4 git commands to generate.