tlds
Transactional Operations for Linked Data Structures
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
stmskip.h
Go to the documentation of this file.
1 #ifndef __STMSKIP_H__
2 #define __STMSKIP_H__
3 
4 #include <stdint.h>
5 
6 typedef unsigned long setkey_t;
7 typedef void *setval_t;
8 
9 typedef struct set_op_st
10 {
11  uint8_t type;
12  uint32_t key;
13 }set_op;
14 
15 
16 #ifdef __STMSKIP_IMPLEMENTATION__
17 
18 /*************************************
19  * INTERNAL DEFINITIONS
20  */
21 
22 /* Fine for 2^NUM_LEVELS nodes. */
23 #define NUM_LEVELS 20
24 
25 
26 /* Internal key values with special meanings. */
27 #define INVALID_FIELD (0) /* Uninitialised field value. */
28 #define SENTINEL_KEYMIN ( 1UL) /* Key value of first dummy node. */
29 #define SENTINEL_KEYMAX (~0UL) /* Key value of last dummy node. */
30 
31 
32 /*
33  * Used internally be set access functions, so that callers can use
34  * key values 0 and 1, without knowing these have special meanings.
35  */
36 #define CALLER_TO_INTERNAL_KEY(_k) ((_k) + 2)
37 
38 
39 /*
40  * SUPPORT FOR WEAK ORDERING OF MEMORY ACCESSES
41  */
42 
43 #ifdef WEAK_MEM_ORDER
44 
45 /* Read field @_f into variable @_x. */
46 #define READ_FIELD(_x,_f) \
47 do { \
48  (_x) = (_f); \
49  if ( (_x) == INVALID_FIELD ) { RMB(); (_x) = (_f); } \
50  assert((_x) != INVALID_FIELD); \
51 } while ( 0 )
52 
53 #else
54 
55 /* Read field @_f into variable @_x. */
56 #define READ_FIELD(_x,_f) ((_x) = (_f))
57 
58 #endif
59 
60 
61 #else
62 
63 /*************************************
64  * PUBLIC DEFINITIONS
65  */
66 
67 
68 /*
69  * Key range accepted by set functions.
70  * We lose three values (conveniently at top end of key space).
71  * - Known invalid value to which all fields are initialised.
72  * - Sentinel key values for up to two dummy nodes.
73  */
74 #define KEY_MIN ( 0U)
75 #define KEY_MAX ((~0U) - 3)
76 
77 typedef void stm_skip; /* opaque */
78 
79 void init_stmskip_subsystem(void);
80 void destory_stmskip_subsystem(void);
81 
82 /*
83  * Allocate an empty set.
84  */
85 stm_skip *stmskip_alloc(void);
86 
87 bool stmskip_execute_ops(stm_skip* l, set_op ops[], int op_size);
88 
89 #endif /* __SET_IMPLEMENTATION__ */
90 
91 #endif /* __SET_H__ */
bool set_op ops[]
Definition: stmskip.cc:238
unsigned long setkey_t
Definition: stmskip.h:6
bool stmskip_execute_ops(stm_skip *l, set_op ops[], int op_size)
uint8_t type
Definition: stmskip.h:11
void init_stmskip_subsystem(void)
Definition: stmskip.cc:289
Definition: defs.h:133
void * setval_t
Definition: stmskip.h:7
uint32_t key
Definition: stmskip.h:12
void destory_stmskip_subsystem(void)
Definition: stmskip.cc:300
stm_skip * stmskip_alloc(void)
Definition: stmskip.cc:121
void stm_skip
Definition: stmskip.h:77
Definition: stmskip.h:9
struct set_op_st set_op