summaryrefslogtreecommitdiff
path: root/test/tsan/Darwin/gcd-async-norace.mm
diff options
context:
space:
mode:
authorJulian Lettner <jlettner@apple.com>2019-04-09 17:51:55 +0000
committerJulian Lettner <jlettner@apple.com>2019-04-09 17:51:55 +0000
commit62944fa59dcc3c1041ef577a3a4c3a3f9dc145c5 (patch)
tree70c175e1b4486dc02b81f6d12527812e569cb2de /test/tsan/Darwin/gcd-async-norace.mm
parentc9d0c6ed09a739b61ab6af2dc18534eaf37441d7 (diff)
downloadcompiler-rt-62944fa59dcc3c1041ef577a3a4c3a3f9dc145c5.tar.gz
[TSan][libdispatch] Replace CFRunLoop with dispatch_semaphore, pt. 1
Remove the dependency on Foundation so we can start running those tests on other platforms. Rename/move of tests will be done in a separate commit. Reviewed By: kubamracek, dvyukov Differential Revision: https://reviews.llvm.org/D60347 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@358023 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/tsan/Darwin/gcd-async-norace.mm')
-rw-r--r--test/tsan/Darwin/gcd-async-norace.mm17
1 files changed, 9 insertions, 8 deletions
diff --git a/test/tsan/Darwin/gcd-async-norace.mm b/test/tsan/Darwin/gcd-async-norace.mm
index 83f8c0d6f..c3b603579 100644
--- a/test/tsan/Darwin/gcd-async-norace.mm
+++ b/test/tsan/Darwin/gcd-async-norace.mm
@@ -1,24 +1,25 @@
-// RUN: %clang_tsan %s -o %t -framework Foundation
+// RUN: %clang_tsan %s -o %t
// RUN: %run %t 2>&1 | FileCheck %s
-#import <Foundation/Foundation.h>
+#include "dispatch/dispatch.h"
+
+#include <stdio.h>
long global;
int main() {
- NSLog(@"Hello world.");
+ fprintf(stderr, "Hello world.\n");
+ dispatch_semaphore_t done = dispatch_semaphore_create(0);
global = 42;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
global = 43;
- dispatch_sync(dispatch_get_main_queue(), ^{
- CFRunLoopStop(CFRunLoopGetCurrent());
- });
+ dispatch_semaphore_signal(done);
});
- CFRunLoopRun();
- NSLog(@"Done.");
+ dispatch_semaphore_wait(done, DISPATCH_TIME_FOREVER);
+ fprintf(stderr, "Done.\n");
}
// CHECK: Hello world.