]> git.proxmox.com Git - rustc.git/blob - src/compiler-rt/test/tsan/default_options.cc
Imported Upstream version 1.0.0~0alpha
[rustc.git] / src / compiler-rt / test / tsan / default_options.cc
1 // RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
2 #include <pthread.h>
3 #include <stdio.h>
4
5 extern "C" const char *__tsan_default_options() {
6 return "report_bugs=0";
7 }
8
9 int Global;
10
11 void *Thread1(void *x) {
12 Global = 42;
13 return NULL;
14 }
15
16 void *Thread2(void *x) {
17 Global = 43;
18 return NULL;
19 }
20
21 int main() {
22 pthread_t t[2];
23 pthread_create(&t[0], NULL, Thread1, NULL);
24 pthread_create(&t[1], NULL, Thread2, NULL);
25 pthread_join(t[0], NULL);
26 pthread_join(t[1], NULL);
27 fprintf(stderr, "DONE\n");
28 return 0;
29 }
30
31 // CHECK-NOT: WARNING: ThreadSanitizer: data race
32 // CHECK: DONE