]>
Commit | Line | Data |
---|---|---|
92a42be0 SL |
1 | // RUN: %clang_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s |
2 | #include "test.h" | |
1a4d82fc JJ |
3 | |
4 | pthread_barrier_t B; | |
5 | int Global; | |
6 | ||
7 | void *Thread1(void *x) { | |
8 | pthread_barrier_init(&B, 0, 2); | |
92a42be0 | 9 | barrier_wait(&barrier); |
1a4d82fc JJ |
10 | pthread_barrier_wait(&B); |
11 | return NULL; | |
12 | } | |
13 | ||
14 | void *Thread2(void *x) { | |
92a42be0 | 15 | barrier_wait(&barrier); |
1a4d82fc JJ |
16 | pthread_barrier_wait(&B); |
17 | return NULL; | |
18 | } | |
19 | ||
20 | int main() { | |
92a42be0 | 21 | barrier_init(&barrier, 2); |
1a4d82fc JJ |
22 | pthread_t t; |
23 | pthread_create(&t, NULL, Thread1, NULL); | |
24 | Thread2(0); | |
25 | pthread_join(t, NULL); | |
26 | pthread_barrier_destroy(&B); | |
27 | return 0; | |
28 | } | |
29 | ||
30 | // CHECK: WARNING: ThreadSanitizer: data race |