]> git.proxmox.com Git - rustc.git/blame - src/compiler-rt/test/tsan/race_on_barrier.c
Imported Upstream version 1.6.0+dfsg1
[rustc.git] / src / compiler-rt / test / tsan / race_on_barrier.c
CommitLineData
92a42be0
SL
1// RUN: %clang_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
2#include "test.h"
1a4d82fc
JJ
3
4pthread_barrier_t B;
5int Global;
6
7void *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
14void *Thread2(void *x) {
92a42be0 15 barrier_wait(&barrier);
1a4d82fc
JJ
16 pthread_barrier_wait(&B);
17 return NULL;
18}
19
20int 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