tlds
Transactional Operations for Linked Data Structures
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
lockfreeskip.h
Go to the documentation of this file.
1 #ifndef __LOCKFREESKIP_H__
2 #define __LOCKFREESKIP_H__
3 
4 
5 typedef unsigned long setkey_t;
6 typedef void *setval_t;
7 
8 
9 #ifdef __SET_IMPLEMENTATION__
10 
11 /*************************************
12  * INTERNAL DEFINITIONS
13  */
14 
15 /* Fine for 2^NUM_LEVELS nodes. */
16 #define NUM_LEVELS 20
17 
18 
19 /* Internal key values with special meanings. */
20 #define INVALID_FIELD (0) /* Uninitialised field value. */
21 #define SENTINEL_KEYMIN ( 1UL) /* Key value of first dummy node. */
22 #define SENTINEL_KEYMAX (~0UL) /* Key value of last dummy node. */
23 
24 
25 /*
26  * Used internally be set access functions, so that callers can use
27  * key values 0 and 1, without knowing these have special meanings.
28  */
29 #define CALLER_TO_INTERNAL_KEY(_k) ((_k) + 2)
30 
31 
32 /*
33  * SUPPORT FOR WEAK ORDERING OF MEMORY ACCESSES
34  */
35 
36 #ifdef WEAK_MEM_ORDER
37 
38 /* Read field @_f into variable @_x. */
39 #define READ_FIELD(_x,_f) \
40 do { \
41  (_x) = (_f); \
42  if ( (_x) == INVALID_FIELD ) { RMB(); (_x) = (_f); } \
43  assert((_x) != INVALID_FIELD); \
44 } while ( 0 )
45 
46 #else
47 
48 /* Read field @_f into variable @_x. */
49 #define READ_FIELD(_x,_f) ((_x) = (_f))
50 
51 #endif
52 
53 
54 #else
55 
56 /*************************************
57  * PUBLIC DEFINITIONS
58  */
59 
60 /*
61  * Key range accepted by set functions.
62  * We lose three values (conveniently at top end of key space).
63  * - Known invalid value to which all fields are initialised.
64  * - Sentinel key values for up to two dummy nodes.
65  */
66 #define KEY_MIN ( 0U)
67 #define KEY_MAX ((~0U) - 3)
68 
69 typedef void boost_skip; /* opaque */
70 
71 void init_boostskip_subsystem(void);
73 
74 /*
75  * Allocate an empty set.
76  */
78 
79 /*
80  * Add mapping (@k -> @v) into set @s. Return previous mapped value if
81  * one existed, or NULL if no previous mapping for @k existed.
82  *
83  * If @overwrite is FALSE, then if a mapping already exists it is not
84  * modified, and the existing value is returned unchanged. It is possible
85  * to see if the value was changed by observing if the return value is NULL.
86  */
87 setval_t set_update(boost_skip *s, setkey_t k, setval_t v, int overwrite);
88 
89 /*
90  * Remove mapping for key @k from set @s. Return value associated with
91  * removed mapping, or NULL is there was no mapping to delete.
92  */
94 
95 /*
96  * Look up mapping for key @k in set @s. Return value if found, else NULL.
97  */
99 
100 void boostskip_print(boost_skip* s);
101 
102 #endif /* __SET_IMPLEMENTATION__ */
103 
104 
105 #endif /* __SET_H__ */
boost_skip * boostskip_alloc(void)
Definition: lockfreeskip.c:255
void init_boostskip_subsystem(void)
Definition: lockfreeskip.c:482
void * setval_t
Definition: lockfreeskip.h:6
setval_t set_update(boost_skip *s, setkey_t k, setval_t v, int overwrite)
Definition: lockfreeskip.c:286
unsigned long setkey_t
Definition: lockfreeskip.h:5
Definition: lockfreeskip.c:51
void boostskip_print(boost_skip *s)
Definition: lockfreeskip.c:500
void destroy_boostskip_subsystem(void)
Definition: lockfreeskip.c:495
void boost_skip
Definition: lockfreeskip.h:69
setval_t set_lookup(boost_skip *s, setkey_t k)
Definition: lockfreeskip.c:465
setval_t set_remove(boost_skip *s, setkey_t k)
Definition: lockfreeskip.c:407