]>
Commit | Line | Data |
---|---|---|
1a4d82fc | 1 | // RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s |
92a42be0 | 2 | #include "test.h" |
1a4d82fc JJ |
3 | |
4 | int Global; | |
5 | int WTFGlobal; | |
6 | ||
7 | extern "C" { | |
8 | void AnnotateBenignRaceSized(const char *f, int l, | |
9 | void *mem, unsigned int size, const char *desc); | |
10 | void WTFAnnotateBenignRaceSized(const char *f, int l, | |
11 | void *mem, unsigned int size, | |
12 | const char *desc); | |
13 | } | |
14 | ||
15 | ||
16 | void *Thread(void *x) { | |
17 | Global = 42; | |
18 | WTFGlobal = 142; | |
92a42be0 | 19 | barrier_wait(&barrier); |
1a4d82fc JJ |
20 | return 0; |
21 | } | |
22 | ||
23 | int main() { | |
92a42be0 | 24 | barrier_init(&barrier, 2); |
1a4d82fc JJ |
25 | AnnotateBenignRaceSized(__FILE__, __LINE__, |
26 | &Global, sizeof(Global), "Race on Global"); | |
27 | WTFAnnotateBenignRaceSized(__FILE__, __LINE__, | |
28 | &WTFGlobal, sizeof(WTFGlobal), | |
29 | "Race on WTFGlobal"); | |
30 | pthread_t t; | |
31 | pthread_create(&t, 0, Thread, 0); | |
92a42be0 | 32 | barrier_wait(&barrier); |
1a4d82fc JJ |
33 | Global = 43; |
34 | WTFGlobal = 143; | |
35 | pthread_join(t, 0); | |
36 | printf("OK\n"); | |
37 | } | |
38 | ||
39 | // CHECK-NOT: WARNING: ThreadSanitizer: data race |