[PATCH] D14924: [tsan] Replace pthread semaphore in signal_cond.cc with barrier_wait

Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 24 05:31:22 PST 2015


This revision was automatically updated to reflect the committed changes.
Closed by commit rL253980: [tsan] Replace pthread semaphore in signal_cond.cc with barrier_wait (authored by kuba.brecka).

Changed prior to commit:
  http://reviews.llvm.org/D14924?vs=40922&id=41030#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14924

Files:
  compiler-rt/trunk/test/tsan/signal_cond.cc

Index: compiler-rt/trunk/test/tsan/signal_cond.cc
===================================================================
--- compiler-rt/trunk/test/tsan/signal_cond.cc
+++ compiler-rt/trunk/test/tsan/signal_cond.cc
@@ -11,12 +11,11 @@
 int g_thread_run = 1;
 pthread_mutex_t mutex;
 pthread_cond_t cond;
-sem_t sem;
 
 void sig_handler(int sig) {
   (void)sig;
   write(1, "SIGNAL\n", sizeof("SIGNAL\n") - 1);
-  sem_post(&sem);
+  barrier_wait(&barrier);
 }
 
 void* my_thread(void* arg) {
@@ -28,16 +27,19 @@
 }
 
 int main() {
-  sem_init(&sem, 0, 0);
+  barrier_init(&barrier, 2);
+
+  pthread_mutex_init(&mutex, 0);
+  pthread_cond_init(&cond, 0);
+
   signal(SIGUSR1, &sig_handler);
   pthread_t thr;
   pthread_create(&thr, 0, &my_thread, 0);
   // wait for thread to get inside pthread_cond_wait
   // (can't use barrier_wait for that)
   sleep(1);
   pthread_kill(thr, SIGUSR1);
-  while (sem_wait(&sem) == -1 && errno == EINTR) {
-  }
+  barrier_wait(&barrier);
   pthread_mutex_lock(&mutex);
   g_thread_run = 0;
   pthread_cond_signal(&cond);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14924.41030.patch
Type: text/x-patch
Size: 1052 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151124/85ce6037/attachment.bin>


More information about the llvm-commits mailing list