[docs] Fix build-docs.sh
[llvm-project.git] / compiler-rt / test / tsan / default_options.cpp
blob3b447e734f23f43b9552f43b5c7b8949949ee8bd
1 // RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
2 #include <pthread.h>
3 #include <stdio.h>
5 #if (__APPLE__)
6 __attribute__((weak))
7 #endif
8 extern "C" const char *__tsan_default_options() {
9 return "report_bugs=0";
12 int Global;
14 void *Thread1(void *x) {
15 Global = 42;
16 return NULL;
19 void *Thread2(void *x) {
20 Global = 43;
21 return NULL;
24 int main() {
25 pthread_t t[2];
26 pthread_create(&t[0], NULL, Thread1, NULL);
27 pthread_create(&t[1], NULL, Thread2, NULL);
28 pthread_join(t[0], NULL);
29 pthread_join(t[1], NULL);
30 fprintf(stderr, "DONE\n");
31 return 0;
34 // CHECK-NOT: WARNING: ThreadSanitizer: data race
35 // CHECK: DONE