Revert "[lldb][test] Remove compiler version check and use regex" (#124101)
[llvm-project.git] / compiler-rt / test / tsan / libdispatch / source-event2.c
blob1afad950d2d54a556e47565d8884d5963d608644
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 global;
9 dispatch_semaphore_t done;
11 void handler(void *arg) {
12 fprintf(stderr, "global = %ld\n", global);
14 dispatch_semaphore_signal(done);
17 int main(int argc, const char *argv[]) {
18 done = dispatch_semaphore_create(0);
20 dispatch_queue_t queue =
21 dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
23 dispatch_source_t source =
24 dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
26 dispatch_source_set_timer(source, dispatch_walltime(NULL, 0), 1e9, 5);
28 global = 42;
30 dispatch_source_set_event_handler_f(source, &handler);
32 dispatch_resume(source);
34 dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
36 return 0;
39 // CHECK: global = 42