]> git.proxmox.com Git - rustc.git/blame - src/libcompiler_builtins/compiler-rt/test/tsan/Darwin/gcd-after.mm
New upstream version 1.25.0+dfsg1
[rustc.git] / src / libcompiler_builtins / compiler-rt / test / tsan / Darwin / gcd-after.mm
CommitLineData
5bcae85e 1// RUN: %clang_tsan %s -o %t -framework Foundation
2c00a5a8 2// RUN: %run %t 2>&1 | FileCheck %s
5bcae85e
SL
3
4#import <Foundation/Foundation.h>
5
6long my_global;
7long my_global2;
8
9void callback(void *context) {
10 my_global2 = 42;
11
12 dispatch_async(dispatch_get_main_queue(), ^{
13 CFRunLoopStop(CFRunLoopGetMain());
14 });
15}
16
17int 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