File tree 4 files changed +18
-224
lines changed
4 files changed +18
-224
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ CFLAGS = -g
3
3
CFLAGS += -Wall
4
4
LDFLAGS += -lpthread
5
5
CFLAGS += -std=c99
6
- # CFLAGS += -fsanitize=thread
6
+ CFLAGS += -fsanitize=thread
7
7
8
8
READER_NUM = 10
9
9
UPDATER_NUM = 1
Original file line number Diff line number Diff line change 4
4
5
5
#include <stddef.h>
6
6
7
- #include "thread-rcu.h"
7
+ /* Reuse the RCU from thread-rcu */
8
+ #include "../thread-rcu/rcu.h"
9
+
10
+ #define __allow_unused __attribute__((unused))
8
11
9
12
#define container_of (ptr , type , member ) \
10
13
__extension__({ \
@@ -63,10 +66,22 @@ static inline void list_del_rcu(struct list_head *node)
63
66
list_init_rcu (node );
64
67
}
65
68
69
+ /*
70
+ * For the write side only (i.e., it should hold the lock when we use the
71
+ * non-rcu postfix for loop API).
72
+ */
73
+
66
74
#define list_for_each (n , head ) for (n = (head)->next; n != (head); n = n->next)
67
75
68
76
#define list_for_each_from (pos , head ) for (; pos != (head); pos = pos->next)
69
77
70
78
#define list_for_each_safe (pos , n , head ) \
71
79
for (pos = (head)->next, n = pos->next; pos != (head); \
72
80
pos = n, n = pos->next)
81
+
82
+ /* The read side should only use the following API. */
83
+
84
+ #define list_for_each_entry_rcu (pos , head , member ) \
85
+ for (pos = list_entry_rcu((head)->next, __typeof__(*pos), member); \
86
+ &pos->member != (head); \
87
+ pos = list_entry_rcu(pos->member.next, __typeof__(*pos), member))
Original file line number Diff line number Diff line change @@ -33,15 +33,12 @@ static struct test *test_alloc(int val)
33
33
static void * reader_side (void * argv )
34
34
{
35
35
struct test __allow_unused * tmp ;
36
- struct list_head * node ;
37
36
38
37
rcu_init ();
39
38
40
39
rcu_read_lock ();
41
40
42
- list_for_each (node , & head ) {
43
- tmp = list_entry_rcu (node , struct test , node );
44
- }
41
+ list_for_each_entry_rcu (tmp , & head , node ) {}
45
42
46
43
rcu_read_unlock ();
47
44
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments