1 // RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
2 // REQUIRES: glibc-2.30
6 pthread_mutex_t m
= PTHREAD_MUTEX_INITIALIZER
;
7 struct timespec ts
= {0};
10 if (!pthread_mutex_trylock(&m
)) {
11 puts("Second thread could not lock mutex");
12 pthread_mutex_unlock(&m
);
18 if (!pthread_mutex_clocklock(&m
, CLOCK_REALTIME
, &ts
)) {
20 pthread_create(&thr
, 0, tfunc
, 0);
22 pthread_mutex_unlock(&m
);
24 puts("Failed to lock mutex");
25 fprintf(stderr
, "PASS\n");
28 // CHECK-NOT: WARNING: ThreadSanitizer: unlock of an unlocked mutex