[OptTable] Fix typo VALUE => VALUES (NFCI) (#121523)
[llvm-project.git] / compiler-rt / test / tsan / libdispatch / dispatch_main.c
blob9e4a3ea42adda336f6be89d20d93e32b0e82d06c
1 // Check that we don't crash when dispatch_main calls pthread_exit which
2 // quits the main thread.
4 // RUN: %clang_tsan %s -o %t
5 // RUN: %run %t 2>&1 | FileCheck %s --implicit-check-not='ThreadSanitizer'
7 #include <dispatch/dispatch.h>
9 #include <stdio.h>
10 #include <stdlib.h>
12 int main() {
13 fprintf(stderr,"Hello world");
15 dispatch_queue_t q = dispatch_queue_create("my.queue", DISPATCH_QUEUE_SERIAL);
17 dispatch_async(q, ^{
18 fprintf(stderr,"1");
19 });
21 dispatch_async(q, ^{
22 fprintf(stderr,"2");
23 });
25 dispatch_async(q, ^{
26 fprintf(stderr,"3");
28 dispatch_async(dispatch_get_main_queue(), ^{
29 fprintf(stderr,"Done.");
30 sleep(1);
31 exit(0);
32 });
33 });
35 dispatch_main();
38 // CHECK: Hello world
39 // CHECK: 123
40 // CHECK: Done.