summaryrefslogtreecommitdiff
path: root/test/tsan/vptr_harmful_race2.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/tsan/vptr_harmful_race2.cc')
-rw-r--r--test/tsan/vptr_harmful_race2.cc8
1 files changed, 4 insertions, 4 deletions
diff --git a/test/tsan/vptr_harmful_race2.cc b/test/tsan/vptr_harmful_race2.cc
index aa53bbb90..a56b74c09 100644
--- a/test/tsan/vptr_harmful_race2.cc
+++ b/test/tsan/vptr_harmful_race2.cc
@@ -1,8 +1,6 @@
// RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
-#include <pthread.h>
+#include "test.h"
#include <semaphore.h>
-#include <stdio.h>
-#include <unistd.h>
struct A {
A() {
@@ -29,18 +27,20 @@ struct B : A {
static A *obj = new B;
void *Thread1(void *x) {
- sleep(1);
obj->F();
+ barrier_wait(&barrier);
obj->Done();
return NULL;
}
void *Thread2(void *x) {
+ barrier_wait(&barrier);
delete obj;
return NULL;
}
int main() {
+ barrier_init(&barrier, 2);
pthread_t t[2];
pthread_create(&t[0], NULL, Thread1, NULL);
pthread_create(&t[1], NULL, Thread2, NULL);