1 // RUN: %clang_tsan %s -o %t
2 // RUN: %run %t 2>&1 | FileCheck %s --implicit-check-not='ThreadSanitizer'
4 #include "dispatch/dispatch.h"
10 dispatch_semaphore_t done
;
12 void callback(void *context
) {
15 dispatch_semaphore_signal(done
);
18 int main(int argc
, const char *argv
[]) {
19 fprintf(stderr
, "start\n");
20 done
= dispatch_semaphore_create(0);
22 dispatch_queue_t q
= dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT
, 0);
25 dispatch_after(dispatch_time(DISPATCH_TIME_NOW
, (int64_t)(10 * NSEC_PER_MSEC
)), q
, ^{
28 dispatch_semaphore_signal(done
);
32 dispatch_after_f(dispatch_time(DISPATCH_TIME_NOW
, (int64_t)(10 * NSEC_PER_MSEC
)), q
, NULL
, &callback
);
34 dispatch_semaphore_wait(done
, DISPATCH_TIME_FOREVER
);
35 dispatch_semaphore_wait(done
, DISPATCH_TIME_FOREVER
);
36 fprintf(stderr
, "done\n");