1 // RUN: %clang_tsan %s -o %t
2 // RUN: %run %t 2>&1 | FileCheck %s --implicit-check-not='ThreadSanitizer'
4 #include <dispatch/dispatch.h>
8 void notify_callback(void *context
) {
13 fprintf(stderr
, "Hello world.");
15 dispatch_queue_t q
= dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT
, 0);
17 for (int i
= 0; i
< 300000; i
++) {
18 dispatch_group_t g
= dispatch_group_create();
19 dispatch_group_enter(g
);
21 dispatch_group_leave(g
);
23 dispatch_group_notify(g
, q
, ^{
29 for (int i
= 0; i
< 300000; i
++) {
30 dispatch_group_t g
= dispatch_group_create();
31 dispatch_group_enter(g
);
33 dispatch_group_leave(g
);
35 dispatch_group_notify_f(g
, q
, NULL
, ¬ify_callback
);
39 fprintf(stderr
, "Done.");
42 // CHECK: Hello world.