1*7c3d14c8STreehugger Robot // RUN: %clangxx_tsan %s -o %t 2*7c3d14c8STreehugger Robot // RUN: %run %t 2>&1 | FileCheck %s 3*7c3d14c8STreehugger Robot 4*7c3d14c8STreehugger Robot // bench.h needs pthread barriers which are not available on OS X 5*7c3d14c8STreehugger Robot // UNSUPPORTED: darwin 6*7c3d14c8STreehugger Robot 7*7c3d14c8STreehugger Robot #include "bench.h" 8*7c3d14c8STreehugger Robot 9*7c3d14c8STreehugger Robot pthread_rwlock_t mtx; 10*7c3d14c8STreehugger Robot thread(int tid)11*7c3d14c8STreehugger Robotvoid thread(int tid) { 12*7c3d14c8STreehugger Robot for (int i = 0; i < bench_niter; i++) { 13*7c3d14c8STreehugger Robot pthread_rwlock_rdlock(&mtx); 14*7c3d14c8STreehugger Robot pthread_rwlock_unlock(&mtx); 15*7c3d14c8STreehugger Robot } 16*7c3d14c8STreehugger Robot } 17*7c3d14c8STreehugger Robot bench()18*7c3d14c8STreehugger Robotvoid bench() { 19*7c3d14c8STreehugger Robot pthread_rwlock_init(&mtx, 0); 20*7c3d14c8STreehugger Robot pthread_rwlock_wrlock(&mtx); 21*7c3d14c8STreehugger Robot pthread_rwlock_unlock(&mtx); 22*7c3d14c8STreehugger Robot pthread_rwlock_rdlock(&mtx); 23*7c3d14c8STreehugger Robot pthread_rwlock_unlock(&mtx); 24*7c3d14c8STreehugger Robot start_thread_group(bench_nthread, thread); 25*7c3d14c8STreehugger Robot } 26*7c3d14c8STreehugger Robot 27*7c3d14c8STreehugger Robot // CHECK: DONE 28*7c3d14c8STreehugger Robot 29