1// RUN: %clangxx_tsan -O1 --std=c++11 %s -o %t && %run %t 2>&1 | FileCheck %s
2#include "custom_mutex.h"
3
4// Test that custom annotations provide normal mutex synchronization
5// (no race reports for properly protected critical sections).
6
7Mutex mu(true, 0);
8long data;
9
10void *thr(void *arg) {
11 barrier_wait(barrier: &barrier);
12 mu.Lock();
13 data++;
14 mu.Unlock();
15 return 0;
16}
17
18int main() {
19 barrier_init(barrier: &barrier, count: 2);
20 pthread_t th;
21 pthread_create(newthread: &th, attr: 0, start_routine: thr, arg: 0);
22 barrier_wait(barrier: &barrier);
23 mu.Lock();
24 data++;
25 mu.Unlock();
26 pthread_join(th: th, thread_return: 0);
27 fprintf(stderr, format: "DONE\n");
28 return 0;
29}
30
31// CHECK: DONE
32

source code of compiler-rt/test/tsan/custom_mutex0.cpp