1 // RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
8 void *Thread(void *x
) {
9 barrier_wait(&barrier
);
14 static void check(int res
, int expect
) {
16 fprintf(stderr
, "Unexpected result of pthread_timedjoin_np: %d\n", res
);
22 barrier_init(&barrier
, 2);
24 pthread_create(&t
, 0, Thread
, 0);
26 clock_gettime(CLOCK_REALTIME
, &ts
);
27 check(pthread_timedjoin_np(t
, 0, &ts
), ETIMEDOUT
);
28 barrier_wait(&barrier
);
29 clock_gettime(CLOCK_REALTIME
, &ts
);
31 check(pthread_timedjoin_np(t
, 0, &ts
), 0);
33 fprintf(stderr
, "PASS\n");
37 // CHECK-NOT: WARNING: ThreadSanitizer: data race
38 // CHECK-NOT: WARNING: ThreadSanitizer: thread leak