[ASan/Win] Add a comment about DCL-using-static vs threads
[blocksruntime.git] / test / tsan / thread_name2.cc
blob0530c9888f15f9d91b1cec668c47171028bbebda
1 // RUN: %clangxx_tsan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
2 #include <pthread.h>
3 #include <stdio.h>
4 #include <unistd.h>
6 int Global;
8 void *Thread1(void *x) {
9 sleep(1);
10 Global++;
11 return 0;
14 void *Thread2(void *x) {
15 pthread_setname_np(pthread_self(), "foobar2");
16 Global--;
17 return 0;
20 int main() {
21 pthread_t t[2];
22 pthread_create(&t[0], 0, Thread1, 0);
23 pthread_create(&t[1], 0, Thread2, 0);
24 pthread_setname_np(t[0], "foobar1");
25 pthread_join(t[0], NULL);
26 pthread_join(t[1], NULL);
29 // CHECK: WARNING: ThreadSanitizer: data race
30 // CHECK: Thread T1 'foobar1'
31 // CHECK: Thread T2 'foobar2'