]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Made the annotate_rwlock test compile on Darwin.
authorBart Van Assche <bvanassche@acm.org>
Wed, 22 Jul 2009 19:04:58 +0000 (19:04 +0000)
committerBart Van Assche <bvanassche@acm.org>
Wed, 22 Jul 2009 19:04:58 +0000 (19:04 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10531

drd/tests/annotate_rwlock.c

index 1d4ee859af0d76e04d554d581b6c38a9d5420a4e..952ed21e2ec24422386b0f281fe56862914ed7ed 100644 (file)
@@ -13,6 +13,7 @@
 #include <assert.h>
 #include <pthread.h>
 #include <stdio.h>
+#include <unistd.h>        /* usleep() */
 #include "../../config.h"
 #include "../../drd/drd.h"
 
@@ -59,7 +60,12 @@ static void rwlock_rdlock(rwlock_t* p)
       ;
     if (p->writer_count == 0)
       break;
+#ifdef __APPLE__
+    /* Darwin doesn't have an implementation of pthread_yield(). */
+    usleep(100 * 1000);
+#else
     pthread_yield();
+#endif
     __sync_fetch_and_sub(&p->locked, 1);
   }
   p->reader_count++;
@@ -78,7 +84,12 @@ static void rwlock_wrlock(rwlock_t* p)
       ;
     if (p->reader_count == 0)
       break;
+#ifdef __APPLE__
+    /* Darwin doesn't have an implementation of pthread_yield(). */
+    usleep(100 * 1000);
+#else
     pthread_yield();
+#endif
     __sync_fetch_and_sub(&p->locked, 1);
   }
   p->writer_count++;