Files
clang-p2996/compiler-rt/test/tsan/libdispatch/apply-race.c
Julian Lettner 4d4f64cddd [NFC][TSan] Move libdispatch tests into their own subfolder
Remove 'gcd' file prefix. GCD stands for Grand Central Dispatch, which
is another name for libdispatch.
https://apple.github.io/swift-corelibs-libdispatch/

Remove `REQUIRE: dispatch` from tests.

Also rename lit feature 'dispatch' -> 'libdispatch' to be more explicit
what this is about.

Reviewed By: kubamracek

Differential Revision: https://reviews.llvm.org/D59341

llvm-svn: 356202
2019-03-14 20:59:41 +00:00

31 lines
758 B
C

// RUN: %clang_tsan %s -o %t
// RUN: %deflake %run %t 2>&1 | FileCheck %s
#include <dispatch/dispatch.h>
#include "../test.h"
long global;
int main(int argc, const char *argv[]) {
barrier_init(&barrier, 2);
fprintf(stderr, "start\n");
// Warm up GCD (workaround for macOS Sierra where dispatch_apply might run single-threaded).
dispatch_sync(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ });
dispatch_queue_t q = dispatch_queue_create("my.queue", DISPATCH_QUEUE_CONCURRENT);
dispatch_apply(2, q, ^(size_t i) {
global = i;
barrier_wait(&barrier);
});
fprintf(stderr, "done\n");
return 0;
}
// CHECK: start
// CHECK: WARNING: ThreadSanitizer: data race
// CHECK: Location is global 'global'
// CHECK: done