forked from OSchip/llvm-project
[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()). llvm-svn: 213516
This commit is contained in:
parent
6c078a5960
commit
4789f63bf3
|
@ -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:.*]].
|
||||
|
|
|
@ -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:.*]].
|
||||
|
|
Loading…
Reference in New Issue