1 | // RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s |
2 | #include "test.h" |
3 | |
4 | int Global; |
5 | |
6 | void *Thread(void *x) { |
7 | AnnotateIgnoreWritesBegin(__FILE__, __LINE__); |
8 | AnnotateIgnoreReadsBegin(__FILE__, __LINE__); |
9 | Global = 42; |
10 | AnnotateIgnoreReadsEnd(__FILE__, __LINE__); |
11 | AnnotateIgnoreWritesEnd(__FILE__, __LINE__); |
12 | barrier_wait(barrier: &barrier); |
13 | return 0; |
14 | } |
15 | |
16 | int main() { |
17 | barrier_init(barrier: &barrier, count: 2); |
18 | pthread_t t; |
19 | pthread_create(newthread: &t, attr: 0, start_routine: Thread, arg: 0); |
20 | barrier_wait(barrier: &barrier); |
21 | Global = 43; |
22 | pthread_join(th: t, thread_return: 0); |
23 | fprintf(stderr, format: "OK\n" ); |
24 | } |
25 | |
26 | // CHECK-NOT: WARNING: ThreadSanitizer: data race |
27 | |