1 // RUN: %clang_tsan %s -o %t
2 // RUN: %run %t 2>&1 | FileCheck %s --implicit-check-not='ThreadSanitizer'
4 #include "dispatch/dispatch.h"
11 fprintf(stderr
, "Hello world.\n");
12 dispatch_semaphore_t done
= dispatch_semaphore_create(0);
14 dispatch_queue_t q
= dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT
, 0);
17 dispatch_group_t g
= dispatch_group_create();
18 dispatch_group_async(g
, q
, ^{
21 dispatch_group_wait(g
, DISPATCH_TIME_FOREVER
);
25 dispatch_group_enter(g
);
28 dispatch_group_leave(g
);
30 dispatch_group_wait(g
, DISPATCH_TIME_FOREVER
);
34 dispatch_group_enter(g
);
37 dispatch_group_leave(g
);
39 dispatch_group_notify(g
, q
, ^{
42 dispatch_semaphore_signal(done
);
45 dispatch_semaphore_wait(done
, DISPATCH_TIME_FOREVER
);
46 fprintf(stderr
, "Done.\n");
49 // CHECK: Hello world.