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 annoations provide normal mutex synchronization 5 // (no race reports for properly protected critical sections). 6 7 Mutex mu(true, 0); 8 long data; 9 thr(void * arg)10void *thr(void *arg) { 11 barrier_wait(&barrier); 12 mu.Lock(); 13 data++; 14 mu.Unlock(); 15 return 0; 16 } 17 main()18int main() { 19 barrier_init(&barrier, 2); 20 pthread_t th; 21 pthread_create(&th, 0, thr, 0); 22 barrier_wait(&barrier); 23 mu.Lock(); 24 data++; 25 mu.Unlock(); 26 pthread_join(th, 0); 27 fprintf(stderr, "DONE\n"); 28 return 0; 29 } 30 31 // CHECK: DONE 32