[Sanitizer] Add rudimentary support for wide-character strings to scanf/printf interc...
[blocksruntime.git] / test / tsan / cond_cancel.c
blobe37621ddacc61a2adb47ddb246db9742d8a0a685
1 // RUN: %clang_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
2 // CHECK-NOT: WARNING
3 // CHECK: OK
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <pthread.h>
8 #include <unistd.h>
10 pthread_mutex_t m;
11 pthread_cond_t c;
12 int x;
14 void *thr1(void *p) {
15 pthread_mutex_lock(&m);
16 pthread_cleanup_push((void(*)(void *arg))pthread_mutex_unlock, &m);
17 while (x == 0)
18 pthread_cond_wait(&c, &m);
19 pthread_cleanup_pop(1);
20 return 0;
23 int main() {
24 pthread_t th;
26 pthread_mutex_init(&m, 0);
27 pthread_cond_init(&c, 0);
29 pthread_create(&th, 0, thr1, 0);
30 sleep(1); // let it block on cond var
31 pthread_cancel(th);
33 pthread_join(th, 0);
34 pthread_mutex_lock(&m);
35 pthread_mutex_unlock(&m);
36 fprintf(stderr, "OK\n");