File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 10
10
#define READ_ONCE (var ) (*((volatile typeof(var) *)(&(var))))
11
11
12
12
#define __aligned (x ) __attribute((__aligned__(x)))
13
+
14
+ /**
15
+ * data_race - mark an expression as containing intentional data races
16
+ *
17
+ * This data_race() macro is useful for situations in which data races
18
+ * should be forgiven. One example is diagnostic code that accesses
19
+ * shared variables but is not a part of the core synchronization design.
20
+ * For example, if accesses to a given variable are protected by a lock,
21
+ * except for diagnostic code, then the accesses under the lock should
22
+ * be plain C-language accesses and those in the diagnostic code should
23
+ * use data_race(). This way, KCSAN will complain if buggy lockless
24
+ * accesses to that variable are introduced, even if the buggy accesses
25
+ * are protected by READ_ONCE() or WRITE_ONCE().
26
+ *
27
+ * This macro *does not* affect normal code generation, but is a hint
28
+ * to tooling that data races here are to be ignored. If the access must
29
+ * be atomic *and* KCSAN should ignore the access, use both data_race()
30
+ * and READ_ONCE(), for example, data_race(READ_ONCE(x)).
31
+ */
32
+ #define data_race (expr ) \
33
+ ({ \
34
+ __auto_type __v = (expr); \
35
+ __v; \
36
+ })
37
+
13
38
#endif
You can’t perform that action at this time.
0 commit comments