]>
Commit | Line | Data |
---|---|---|
5bcae85e SL |
1 | // RUN: %clang_tsan %s -o %t -framework Foundation |
2 | // RUN: %env_tsan_opts=ignore_interceptors_accesses=1 %run %t 2>&1 | FileCheck %s | |
3 | ||
4 | #import <Foundation/Foundation.h> | |
5 | ||
6 | long my_global; | |
7 | long my_global2; | |
8 | ||
9 | void callback(void *context) { | |
10 | my_global2 = 42; | |
11 | ||
12 | dispatch_async(dispatch_get_main_queue(), ^{ | |
13 | CFRunLoopStop(CFRunLoopGetMain()); | |
14 | }); | |
15 | } | |
16 | ||
17 | int main(int argc, const char *argv[]) { | |
18 | fprintf(stderr, "start\n"); | |
19 | ||
20 | my_global = 10; | |
21 | dispatch_queue_t q = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); | |
22 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(10 * NSEC_PER_MSEC)), q, ^{ | |
23 | my_global = 42; | |
24 | ||
25 | dispatch_async(dispatch_get_main_queue(), ^{ | |
26 | CFRunLoopStop(CFRunLoopGetMain()); | |
27 | }); | |
28 | }); | |
29 | CFRunLoopRun(); | |
30 | ||
31 | my_global2 = 10; | |
32 | dispatch_after_f(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(10 * NSEC_PER_MSEC)), q, NULL, &callback); | |
33 | CFRunLoopRun(); | |
34 | ||
35 | fprintf(stderr, "done\n"); | |
36 | return 0; | |
37 | } | |
38 | ||
39 | // CHECK: start | |
40 | // CHECK: done | |
41 | // CHECK-NOT: WARNING: ThreadSanitizer |