Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / tsan / Linux / clockwait_double_lock.c
blob8b3edab8264c362c443065cc1f2ed11b82944f47
1 // Regression test for https://github.com/google/sanitizers/issues/1259
2 // RUN: %clang_tsan -O1 %s -o %t && %run %t
3 // REQUIRES: glibc-2.30 || android-30
5 #define _GNU_SOURCE
6 #include <pthread.h>
8 pthread_cond_t cv;
9 pthread_mutex_t mtx;
11 void *fn(void *vp) {
12 pthread_mutex_lock(&mtx);
13 pthread_cond_signal(&cv);
14 pthread_mutex_unlock(&mtx);
15 return NULL;
18 int main() {
19 pthread_mutex_lock(&mtx);
21 pthread_t tid;
22 pthread_create(&tid, NULL, fn, NULL);
24 struct timespec ts;
25 clock_gettime(CLOCK_MONOTONIC, &ts);
26 ts.tv_sec += 10;
27 pthread_cond_clockwait(&cv, &mtx, CLOCK_MONOTONIC, &ts);
28 pthread_mutex_unlock(&mtx);
30 pthread_join(tid, NULL);
31 return 0;