diff options
Diffstat (limited to 'src/libstd/sys/unix/thread.rs')
| -rw-r--r-- | src/libstd/sys/unix/thread.rs | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/libstd/sys/unix/thread.rs b/src/libstd/sys/unix/thread.rs index 0faa1465c32..49d5832f037 100644 --- a/src/libstd/sys/unix/thread.rs +++ b/src/libstd/sys/unix/thread.rs @@ -12,7 +12,7 @@ use prelude::v1::*; use alloc::boxed::FnBox; use cmp; -#[cfg(not(target_env = "newlib"))] +#[cfg(not(any(target_env = "newlib", target_os = "sunos")))] use ffi::CString; use io; use libc; @@ -122,9 +122,9 @@ impl Thread { carg.as_ptr() as *mut libc::c_void); } } - #[cfg(target_env = "newlib")] - pub unsafe fn set_name(_name: &str) { - // Newlib has no way to set a thread name. + #[cfg(any(target_env = "newlib", target_os = "sunos"))] + pub fn set_name(_name: &str) { + // Newlib and Illumos has no way to set a thread name. } pub fn sleep(dur: Duration) { @@ -170,7 +170,8 @@ impl Drop for Thread { not(target_os = "macos"), not(target_os = "bitrig"), not(all(target_os = "netbsd", not(target_vendor = "rumprun"))), - not(target_os = "openbsd")))] + not(target_os = "openbsd"), + not(target_os = "sunos")))] #[cfg_attr(test, allow(dead_code))] pub mod guard { pub unsafe fn current() -> Option<usize> { None } @@ -182,7 +183,8 @@ pub mod guard { target_os = "macos", target_os = "bitrig", all(target_os = "netbsd", not(target_vendor = "rumprun")), - target_os = "openbsd"))] + target_os = "openbsd", + target_os = "sunos"))] #[cfg_attr(test, allow(dead_code))] pub mod guard { use prelude::v1::*; @@ -194,7 +196,8 @@ pub mod guard { #[cfg(any(target_os = "macos", target_os = "bitrig", - target_os = "openbsd"))] + target_os = "openbsd", + target_os = "sunos"))] unsafe fn get_stack_start() -> Option<*mut libc::c_void> { current().map(|s| s as *mut libc::c_void) } @@ -253,6 +256,13 @@ pub mod guard { Some(stackaddr as usize + offset * psize) } + #[cfg(target_os = "sunos")] + pub unsafe fn current() -> Option<usize> { + let mut current_stack: libc::stack_t = mem::zeroed(); + assert_eq!(libc::stack_getbounds(&mut current_stack), 0); + Some(current_stack.ss_sp as usize) + } + #[cfg(target_os = "macos")] pub unsafe fn current() -> Option<usize> { Some((libc::pthread_get_stackaddr_np(libc::pthread_self()) as libc::size_t - |
