Skip to content

Commit

Permalink
use sched_yield on linux and freebsd
Browse files Browse the repository at this point in the history
pthread_yield is non-standard, while sched_yield is POSIX

The Linux documentation recommends using the standard function. This is
the only feature we're currently using that's present in glibc but not
in musl.
  • Loading branch information
thestinger authored and alexcrichton committed May 15, 2014
1 parent 4c34ff8 commit 700def2
Showing 1 changed file with 0 additions and 10 deletions.
10 changes: 0 additions & 10 deletions src/libstd/rt/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,8 @@ mod imp {
assert_eq!(pthread_detach(native), 0);
}

#[cfg(target_os = "macos")]
#[cfg(target_os = "android")]
pub unsafe fn yield_now() { assert_eq!(sched_yield(), 0); }

#[cfg(not(target_os = "macos"), not(target_os = "android"))]
pub unsafe fn yield_now() { assert_eq!(pthread_yield(), 0); }

// glibc >= 2.15 has a __pthread_get_minstack() function that returns
// PTHREAD_STACK_MIN plus however many bytes are needed for thread-local
// storage. We need that information to avoid blowing up when a small stack
Expand Down Expand Up @@ -326,12 +321,7 @@ mod imp {
fn pthread_attr_setdetachstate(attr: *mut libc::pthread_attr_t,
state: libc::c_int) -> libc::c_int;
fn pthread_detach(thread: libc::pthread_t) -> libc::c_int;

#[cfg(target_os = "macos")]
#[cfg(target_os = "android")]
fn sched_yield() -> libc::c_int;
#[cfg(not(target_os = "macos"), not(target_os = "android"))]
fn pthread_yield() -> libc::c_int;
}
}

Expand Down

0 comments on commit 700def2

Please sign in to comment.