diff options
Diffstat (limited to 'compiler-rt/test/tsan/race_on_write.cc')
-rw-r--r-- | compiler-rt/test/tsan/race_on_write.cc | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/compiler-rt/test/tsan/race_on_write.cc b/compiler-rt/test/tsan/race_on_write.cc index 484bbb7ae02..147591a39b9 100644 --- a/compiler-rt/test/tsan/race_on_write.cc +++ b/compiler-rt/test/tsan/race_on_write.cc @@ -1,7 +1,5 @@ // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s -#include <pthread.h> -#include <stdio.h> -#include <unistd.h> +#include "test.h" #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> @@ -11,7 +9,7 @@ char buf; void *Thread1(void *x) { buf = 1; - sleep(1); + barrier_wait(&barrier); return NULL; } @@ -21,11 +19,12 @@ void *Thread2(void *x) { } int main() { + barrier_init(&barrier, 2); fd = open("/dev/null", O_WRONLY); if (fd < 0) return 1; pthread_t t[2]; pthread_create(&t[0], NULL, Thread1, NULL); - sleep(1); + barrier_wait(&barrier); pthread_create(&t[1], NULL, Thread2, NULL); pthread_join(t[0], NULL); pthread_join(t[1], NULL); |