[Sanitizer] Add rudimentary support for wide-character strings to scanf/printf interc...
[blocksruntime.git] / test / tsan / ignore_sync.cc
blob67f2d906d9c732dceab1698dd63bbd83eb77a916
1 // RUN: %clangxx_tsan -O1 %s -o %t && not %t 2>&1 | FileCheck %s
2 #include <pthread.h>
3 #include <stdio.h>
5 extern "C" void AnnotateIgnoreSyncBegin(const char*, int);
6 extern "C" void AnnotateIgnoreSyncEnd(const char*, int);
8 int Global;
9 pthread_mutex_t Mutex = PTHREAD_MUTEX_INITIALIZER;
11 void *Thread(void *x) {
12 AnnotateIgnoreSyncBegin(0, 0);
13 pthread_mutex_lock(&Mutex);
14 Global++;
15 pthread_mutex_unlock(&Mutex);
16 AnnotateIgnoreSyncEnd(0, 0);
17 return 0;
20 int main() {
21 pthread_t t;
22 pthread_create(&t, 0, Thread, 0);
23 pthread_mutex_lock(&Mutex);
24 Global++;
25 pthread_mutex_unlock(&Mutex);
26 pthread_join(t, 0);
29 // CHECK: WARNING: ThreadSanitizer: data race