diff options
Diffstat (limited to 'test/tsan/global_race.cc')
-rw-r--r-- | test/tsan/global_race.cc | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/test/tsan/global_race.cc b/test/tsan/global_race.cc index e12bb1d220f8a..d70bee4a556bd 100644 --- a/test/tsan/global_race.cc +++ b/test/tsan/global_race.cc @@ -1,24 +1,23 @@ // RUN: %clangxx_tsan -O1 %s -o %T/global_race.cc.exe && %deflake %run %T/global_race.cc.exe | FileCheck %s -#include <pthread.h> -#include <stdio.h> -#include <stddef.h> -#include <unistd.h> +#include "test.h" int GlobalData[10]; void *Thread(void *a) { - sleep(1); + barrier_wait(&barrier); GlobalData[2] = 42; return 0; } int main() { + barrier_init(&barrier, 2); // On FreeBSD, the %p conversion specifier works as 0x%x and thus does not // match to the format used in the diagnotic message. fprintf(stderr, "addr=0x%012lx\n", (unsigned long) GlobalData); pthread_t t; pthread_create(&t, 0, Thread, 0); GlobalData[2] = 43; + barrier_wait(&barrier); pthread_join(t, 0); } |