]> git.proxmox.com Git - rustc.git/blame - src/compiler-rt/test/tsan/ignore_sync.cc
Imported Upstream version 1.6.0+dfsg1
[rustc.git] / src / compiler-rt / test / tsan / ignore_sync.cc
CommitLineData
92a42be0 1// RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
1a4d82fc
JJ
2#include <pthread.h>
3#include <stdio.h>
4
5extern "C" void AnnotateIgnoreSyncBegin(const char*, int);
6extern "C" void AnnotateIgnoreSyncEnd(const char*, int);
7
8int Global;
9pthread_mutex_t Mutex = PTHREAD_MUTEX_INITIALIZER;
10
11void *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;
18}
19
20int 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);
27}
28
29// CHECK: WARNING: ThreadSanitizer: data race
30