]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/tsan/Darwin/gcd-semaphore-norace.mm
Vendor import of compiler-rt trunk r351319 (just before the release_80
[FreeBSD/FreeBSD.git] / test / tsan / Darwin / gcd-semaphore-norace.mm
1 // RUN: %clang_tsan %s -o %t -framework Foundation
2 // RUN: %run %t 2>&1 | FileCheck %s
3
4 #import <Foundation/Foundation.h>
5
6 long global;
7
8 int main() {
9     NSLog(@"Hello world.");
10
11     global = 42;
12     
13     dispatch_semaphore_t sem = dispatch_semaphore_create(0);
14     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
15         
16         global = 43;
17         dispatch_semaphore_signal(sem);
18     });
19     
20     dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
21     global = 44;
22
23     NSLog(@"Done.");
24     return 0;
25 }
26
27 // CHECK: Hello world.
28 // CHECK: Done.
29 // CHECK-NOT: WARNING: ThreadSanitizer