[compiler-rt] r213516 - [lsan] Use a more standard-conformant sched_yield() instead of pthread_yield().

Alexander Potapenko glider at google.com
Mon Jul 21 06:01:06 PDT 2014


Author: glider
Date: Mon Jul 21 08:01:06 2014
New Revision: 213516

URL: http://llvm.org/viewvc/llvm-project?rev=213516&view=rev
Log:
[lsan] Use a more standard-conformant sched_yield() instead of pthread_yield().
There's no pthread_yield() on OSX (only sched_yield() and pthread_yield_np()).

Modified:
    compiler-rt/trunk/test/lsan/TestCases/use_registers.cc
    compiler-rt/trunk/test/lsan/TestCases/use_stacks_threaded.cc

Modified: compiler-rt/trunk/test/lsan/TestCases/use_registers.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lsan/TestCases/use_registers.cc?rev=213516&r1=213515&r2=213516&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/TestCases/use_registers.cc (original)
+++ compiler-rt/trunk/test/lsan/TestCases/use_registers.cc Mon Jul 21 08:01:06 2014
@@ -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:.*]].

Modified: compiler-rt/trunk/test/lsan/TestCases/use_stacks_threaded.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lsan/TestCases/use_stacks_threaded.cc?rev=213516&r1=213515&r2=213516&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/TestCases/use_stacks_threaded.cc (original)
+++ compiler-rt/trunk/test/lsan/TestCases/use_stacks_threaded.cc Mon Jul 21 08:01:06 2014
@@ -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:.*]].





More information about the llvm-commits mailing list