Mercurial > hg > CbC > CbC_llvm
comparison compiler-rt/test/tsan/race_on_barrier2.c @ 150:1d019706d866
LLVM10
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 15:10:13 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
147:c2174574ed3a | 150:1d019706d866 |
---|---|
1 // RUN: %clang_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s | |
2 | |
3 // pthread barriers are not available on OS X | |
4 // UNSUPPORTED: darwin | |
5 | |
6 #include <pthread.h> | |
7 #include <stdio.h> | |
8 #include <stddef.h> | |
9 #include <unistd.h> | |
10 | |
11 pthread_barrier_t B; | |
12 int Global; | |
13 | |
14 void *Thread1(void *x) { | |
15 if (pthread_barrier_wait(&B) == PTHREAD_BARRIER_SERIAL_THREAD) | |
16 pthread_barrier_destroy(&B); | |
17 return NULL; | |
18 } | |
19 | |
20 void *Thread2(void *x) { | |
21 if (pthread_barrier_wait(&B) == PTHREAD_BARRIER_SERIAL_THREAD) | |
22 pthread_barrier_destroy(&B); | |
23 return NULL; | |
24 } | |
25 | |
26 int main() { | |
27 pthread_barrier_init(&B, 0, 2); | |
28 pthread_t t; | |
29 pthread_create(&t, NULL, Thread1, NULL); | |
30 Thread2(0); | |
31 pthread_join(t, NULL); | |
32 return 0; | |
33 } | |
34 | |
35 // CHECK: WARNING: ThreadSanitizer: data race |