[lsan] Use a more standard-conformant sched_yield() instead of pthread_yield().
authorAlexander Potapenko <glider@google.com>
Mon, 21 Jul 2014 13:01:06 +0000 (13:01 +0000)
committerAlexander Potapenko <glider@google.com>
Mon, 21 Jul 2014 13:01:06 +0000 (13:01 +0000)
There's no pthread_yield() on OSX (only sched_yield() and pthread_yield_np()).

llvm-svn: 213516

compiler-rt/test/lsan/TestCases/use_registers.cc
compiler-rt/test/lsan/TestCases/use_stacks_threaded.cc

index d436144..ce11c3f 100644 (file)
@@ -7,6 +7,7 @@
 
 #include <assert.h>
 #include <pthread.h>
+#include <sched.h>
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -33,7 +34,7 @@ void *registers_thread_func(void *arg) {
   fflush(stderr);
   __sync_fetch_and_xor(sync, 1);
   while (true)
-    pthread_yield();
+    sched_yield();
 }
 
 int main() {
@@ -42,7 +43,7 @@ int main() {
   int res = pthread_create(&thread_id, 0, registers_thread_func, &sync);
   assert(res == 0);
   while (!__sync_fetch_and_xor(&sync, 0))
-    pthread_yield();
+    sched_yield();
   return 0;
 }
 // CHECK: Test alloc: [[ADDR:.*]].
index fc4e661..a1d4383 100644 (file)
@@ -7,6 +7,7 @@
 
 #include <assert.h>
 #include <pthread.h>
+#include <sched.h>
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -18,7 +19,7 @@ void *stacks_thread_func(void *arg) {
   fflush(stderr);
   __sync_fetch_and_xor(sync, 1);
   while (true)
-    pthread_yield();
+    sched_yield();
 }
 
 int main() {
@@ -27,7 +28,7 @@ int main() {
   int res = pthread_create(&thread_id, 0, stacks_thread_func, &sync);
   assert(res == 0);
   while (!__sync_fetch_and_xor(&sync, 0))
-    pthread_yield();
+    sched_yield();
   return 0;
 }
 // CHECK: Test alloc: [[ADDR:.*]].