Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / tsan / libdispatch / after.c
blob7ec2e10aff439e856779c5cff1d2a0f5d7694b44
1 // RUN: %clang_tsan %s -o %t
2 // RUN: %run %t 2>&1 | FileCheck %s --implicit-check-not='ThreadSanitizer'
4 #include "dispatch/dispatch.h"
6 #include <stdio.h>
8 long my_global;
9 long my_global2;
10 dispatch_semaphore_t done;
12 void callback(void *context) {
13 my_global2 = 42;
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);
24 my_global = 10;
25 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(10 * NSEC_PER_MSEC)), q, ^{
26 my_global = 42;
28 dispatch_semaphore_signal(done);
29 });
31 my_global2 = 10;
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");
37 return 0;
40 // CHECK: start
41 // CHECK: done