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