aboutsummaryrefslogtreecommitdiff
path: root/test/tsan/thread_name.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/tsan/thread_name.cc')
-rw-r--r--test/tsan/thread_name.cc8
1 files changed, 4 insertions, 4 deletions
diff --git a/test/tsan/thread_name.cc b/test/tsan/thread_name.cc
index a790c668c084..80d30b82d8b5 100644
--- a/test/tsan/thread_name.cc
+++ b/test/tsan/thread_name.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"
#if defined(__linux__)
#define USE_PTHREAD_SETNAME_NP __GLIBC_PREREQ(2, 12)
@@ -18,7 +16,7 @@ extern "C" void AnnotateThreadName(const char *f, int l, const char *name);
int Global;
void *Thread1(void *x) {
- sleep(1);
+ barrier_wait(&barrier);
AnnotateThreadName(__FILE__, __LINE__, "Thread1");
Global++;
return NULL;
@@ -31,10 +29,12 @@ void *Thread2(void *x) {
AnnotateThreadName(__FILE__, __LINE__, "Thread2");
#endif
Global--;
+ barrier_wait(&barrier);
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);