2015-01-29 07:19:28 +00:00
|
|
|
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
|
2014-11-24 03:21:17 +00:00
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2015-03-10 03:04:35 +00:00
|
|
|
#![allow(dead_code)]
|
|
|
|
|
2015-04-15 05:13:57 +00:00
|
|
|
use prelude::v1::*;
|
2014-11-24 03:21:17 +00:00
|
|
|
|
2015-04-15 05:13:57 +00:00
|
|
|
use alloc::boxed::FnBox;
|
2014-11-24 03:21:17 +00:00
|
|
|
use cmp;
|
2015-03-13 03:21:17 +00:00
|
|
|
use ffi::CString;
|
|
|
|
use io;
|
|
|
|
use libc::consts::os::posix01::PTHREAD_STACK_MIN;
|
|
|
|
use libc;
|
2014-11-24 03:21:17 +00:00
|
|
|
use mem;
|
|
|
|
use ptr;
|
2015-03-13 03:21:17 +00:00
|
|
|
use sys::os;
|
|
|
|
use time::Duration;
|
2014-11-24 03:21:17 +00:00
|
|
|
|
|
|
|
use sys_common::stack::RED_ZONE;
|
|
|
|
use sys_common::thread::*;
|
|
|
|
|
2015-04-15 05:13:57 +00:00
|
|
|
pub struct Thread {
|
|
|
|
id: libc::pthread_t,
|
|
|
|
}
|
|
|
|
|
|
|
|
// Some platforms may have pthread_t as a pointer in which case we still want
|
|
|
|
// a thread to be Send/Sync
|
|
|
|
unsafe impl Send for Thread {}
|
|
|
|
unsafe impl Sync for Thread {}
|
|
|
|
|
|
|
|
impl Thread {
|
|
|
|
pub unsafe fn new<'a>(stack: usize, p: Box<FnBox() + 'a>)
|
|
|
|
-> io::Result<Thread> {
|
|
|
|
let p = box p;
|
|
|
|
let mut native: libc::pthread_t = mem::zeroed();
|
|
|
|
let mut attr: libc::pthread_attr_t = mem::zeroed();
|
|
|
|
assert_eq!(pthread_attr_init(&mut attr), 0);
|
|
|
|
|
|
|
|
// Reserve room for the red zone, the runtime's stack of last resort.
|
|
|
|
let stack_size = cmp::max(stack, RED_ZONE + min_stack_size(&attr));
|
|
|
|
match pthread_attr_setstacksize(&mut attr, stack_size as libc::size_t) {
|
|
|
|
0 => {}
|
|
|
|
n => {
|
|
|
|
assert_eq!(n, libc::EINVAL);
|
|
|
|
// EINVAL means |stack_size| is either too small or not a
|
|
|
|
// multiple of the system page size. Because it's definitely
|
|
|
|
// >= PTHREAD_STACK_MIN, it must be an alignment issue.
|
|
|
|
// Round up to the nearest page and try again.
|
|
|
|
let page_size = os::page_size();
|
|
|
|
let stack_size = (stack_size + page_size - 1) &
|
|
|
|
(-(page_size as isize - 1) as usize - 1);
|
|
|
|
let stack_size = stack_size as libc::size_t;
|
|
|
|
assert_eq!(pthread_attr_setstacksize(&mut attr, stack_size), 0);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
let ret = pthread_create(&mut native, &attr, thread_start,
|
|
|
|
&*p as *const _ as *mut _);
|
|
|
|
assert_eq!(pthread_attr_destroy(&mut attr), 0);
|
|
|
|
|
|
|
|
return if ret != 0 {
|
|
|
|
Err(io::Error::from_raw_os_error(ret))
|
|
|
|
} else {
|
|
|
|
mem::forget(p); // ownership passed to pthread_create
|
|
|
|
Ok(Thread { id: native })
|
|
|
|
};
|
|
|
|
|
|
|
|
#[no_stack_check]
|
|
|
|
extern fn thread_start(main: *mut libc::c_void) -> *mut libc::c_void {
|
|
|
|
unsafe { start_thread(main); }
|
|
|
|
0 as *mut _
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn yield_now() {
|
|
|
|
let ret = unsafe { sched_yield() };
|
|
|
|
debug_assert_eq!(ret, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(any(target_os = "linux", target_os = "android"))]
|
|
|
|
pub fn set_name(name: &str) {
|
|
|
|
// pthread wrapper only appeared in glibc 2.12, so we use syscall
|
|
|
|
// directly.
|
|
|
|
extern {
|
|
|
|
fn prctl(option: libc::c_int, arg2: libc::c_ulong,
|
|
|
|
arg3: libc::c_ulong, arg4: libc::c_ulong,
|
|
|
|
arg5: libc::c_ulong) -> libc::c_int;
|
|
|
|
}
|
|
|
|
const PR_SET_NAME: libc::c_int = 15;
|
|
|
|
let cname = CString::new(name).unwrap_or_else(|_| {
|
|
|
|
panic!("thread name may not contain interior null bytes")
|
|
|
|
});
|
|
|
|
unsafe {
|
|
|
|
prctl(PR_SET_NAME, cname.as_ptr() as libc::c_ulong, 0, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(any(target_os = "freebsd",
|
|
|
|
target_os = "dragonfly",
|
|
|
|
target_os = "bitrig",
|
|
|
|
target_os = "openbsd"))]
|
|
|
|
pub fn set_name(name: &str) {
|
|
|
|
extern {
|
|
|
|
fn pthread_set_name_np(tid: libc::pthread_t,
|
|
|
|
name: *const libc::c_char);
|
|
|
|
}
|
|
|
|
let cname = CString::new(name).unwrap();
|
|
|
|
unsafe {
|
|
|
|
pthread_set_name_np(pthread_self(), cname.as_ptr());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
|
|
|
pub fn set_name(name: &str) {
|
|
|
|
extern {
|
|
|
|
fn pthread_setname_np(name: *const libc::c_char) -> libc::c_int;
|
|
|
|
}
|
|
|
|
let cname = CString::new(name).unwrap();
|
|
|
|
unsafe {
|
|
|
|
pthread_setname_np(cname.as_ptr());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn sleep(dur: Duration) {
|
|
|
|
if dur < Duration::zero() {
|
|
|
|
return Thread::yield_now()
|
|
|
|
}
|
|
|
|
let seconds = dur.num_seconds();
|
|
|
|
let ns = dur - Duration::seconds(seconds);
|
|
|
|
let mut ts = libc::timespec {
|
|
|
|
tv_sec: seconds as libc::time_t,
|
|
|
|
tv_nsec: ns.num_nanoseconds().unwrap() as libc::c_long,
|
|
|
|
};
|
|
|
|
|
|
|
|
// If we're awoken with a signal then the return value will be -1 and
|
|
|
|
// nanosleep will fill in `ts` with the remaining time.
|
|
|
|
unsafe {
|
|
|
|
while libc::nanosleep(&ts, &mut ts) == -1 {
|
|
|
|
assert_eq!(os::errno(), libc::EINTR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn join(self) {
|
|
|
|
unsafe {
|
|
|
|
let ret = pthread_join(self.id, ptr::null_mut());
|
|
|
|
mem::forget(self);
|
|
|
|
debug_assert_eq!(ret, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Drop for Thread {
|
|
|
|
fn drop(&mut self) {
|
|
|
|
let ret = unsafe { pthread_detach(self.id) };
|
|
|
|
debug_assert_eq!(ret, 0);
|
|
|
|
}
|
|
|
|
}
|
2014-11-24 03:21:17 +00:00
|
|
|
|
2015-01-29 07:19:28 +00:00
|
|
|
#[cfg(all(not(target_os = "linux"),
|
|
|
|
not(target_os = "macos"),
|
2015-01-17 07:51:04 +00:00
|
|
|
not(target_os = "bitrig"),
|
2015-01-29 07:19:28 +00:00
|
|
|
not(target_os = "openbsd")))]
|
2014-11-24 03:21:17 +00:00
|
|
|
pub mod guard {
|
2015-03-13 03:21:17 +00:00
|
|
|
pub unsafe fn current() -> usize { 0 }
|
|
|
|
pub unsafe fn main() -> usize { 0 }
|
|
|
|
pub unsafe fn init() {}
|
2014-11-24 03:21:17 +00:00
|
|
|
}
|
|
|
|
|
2015-01-29 07:19:28 +00:00
|
|
|
|
|
|
|
#[cfg(any(target_os = "linux",
|
|
|
|
target_os = "macos",
|
2015-01-17 07:51:04 +00:00
|
|
|
target_os = "bitrig",
|
2015-01-29 07:19:28 +00:00
|
|
|
target_os = "openbsd"))]
|
2015-03-13 03:21:17 +00:00
|
|
|
#[allow(unused_imports)]
|
2014-11-24 03:21:17 +00:00
|
|
|
pub mod guard {
|
2015-03-13 03:21:17 +00:00
|
|
|
use libc::{self, pthread_t};
|
|
|
|
use libc::funcs::posix88::mman::mmap;
|
2014-11-24 03:21:17 +00:00
|
|
|
use libc::consts::os::posix88::{PROT_NONE,
|
|
|
|
MAP_PRIVATE,
|
|
|
|
MAP_ANON,
|
|
|
|
MAP_FAILED,
|
|
|
|
MAP_FIXED};
|
2015-03-13 03:21:17 +00:00
|
|
|
use mem;
|
|
|
|
use ptr;
|
|
|
|
use super::{pthread_self, pthread_attr_destroy};
|
|
|
|
use sys::os;
|
2014-11-24 03:21:17 +00:00
|
|
|
|
|
|
|
// These are initialized in init() and only read from after
|
2015-03-13 03:21:17 +00:00
|
|
|
static mut GUARD_PAGE: usize = 0;
|
2014-11-24 03:21:17 +00:00
|
|
|
|
2015-02-05 07:53:02 +00:00
|
|
|
#[cfg(any(target_os = "macos",
|
2015-01-17 07:51:04 +00:00
|
|
|
target_os = "bitrig",
|
|
|
|
target_os = "openbsd"))]
|
2014-11-24 03:21:17 +00:00
|
|
|
unsafe fn get_stack_start() -> *mut libc::c_void {
|
|
|
|
current() as *mut libc::c_void
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(any(target_os = "linux", target_os = "android"))]
|
|
|
|
unsafe fn get_stack_start() -> *mut libc::c_void {
|
|
|
|
let mut attr: libc::pthread_attr_t = mem::zeroed();
|
2015-03-13 03:21:17 +00:00
|
|
|
assert_eq!(pthread_getattr_np(pthread_self(), &mut attr), 0);
|
2014-11-24 03:21:17 +00:00
|
|
|
let mut stackaddr = ptr::null_mut();
|
|
|
|
let mut stacksize = 0;
|
2015-03-13 03:21:17 +00:00
|
|
|
assert_eq!(pthread_attr_getstack(&attr, &mut stackaddr, &mut stacksize), 0);
|
|
|
|
assert_eq!(pthread_attr_destroy(&mut attr), 0);
|
2014-11-24 03:21:17 +00:00
|
|
|
stackaddr
|
|
|
|
}
|
|
|
|
|
|
|
|
pub unsafe fn init() {
|
2015-03-13 03:21:17 +00:00
|
|
|
let psize = os::page_size();
|
2015-01-11 03:52:50 +00:00
|
|
|
let mut stackaddr = get_stack_start();
|
|
|
|
|
|
|
|
// Ensure stackaddr is page aligned! A parent process might
|
|
|
|
// have reset RLIMIT_STACK to be non-page aligned. The
|
|
|
|
// pthread_attr_getstack() reports the usable stack area
|
|
|
|
// stackaddr < stackaddr + stacksize, so if stackaddr is not
|
|
|
|
// page-aligned, calculate the fix such that stackaddr <
|
|
|
|
// new_page_aligned_stackaddr < stackaddr + stacksize
|
2015-03-13 03:21:17 +00:00
|
|
|
let remainder = (stackaddr as usize) % psize;
|
2015-01-11 03:52:50 +00:00
|
|
|
if remainder != 0 {
|
2015-03-13 03:21:17 +00:00
|
|
|
stackaddr = ((stackaddr as usize) + psize - remainder)
|
2015-01-11 03:52:50 +00:00
|
|
|
as *mut libc::c_void;
|
|
|
|
}
|
2014-11-24 03:21:17 +00:00
|
|
|
|
|
|
|
// Rellocate the last page of the stack.
|
|
|
|
// This ensures SIGBUS will be raised on
|
|
|
|
// stack overflow.
|
|
|
|
let result = mmap(stackaddr,
|
2015-03-13 03:21:17 +00:00
|
|
|
psize as libc::size_t,
|
2014-11-24 03:21:17 +00:00
|
|
|
PROT_NONE,
|
|
|
|
MAP_PRIVATE | MAP_ANON | MAP_FIXED,
|
|
|
|
-1,
|
|
|
|
0);
|
|
|
|
|
|
|
|
if result != stackaddr || result == MAP_FAILED {
|
|
|
|
panic!("failed to allocate a guard page");
|
|
|
|
}
|
|
|
|
|
2015-03-13 03:21:17 +00:00
|
|
|
let offset = if cfg!(target_os = "linux") {2} else {1};
|
2014-11-24 03:21:17 +00:00
|
|
|
|
2015-03-13 03:21:17 +00:00
|
|
|
GUARD_PAGE = stackaddr as usize + offset * psize;
|
2014-11-24 03:21:17 +00:00
|
|
|
}
|
|
|
|
|
2015-03-13 03:21:17 +00:00
|
|
|
pub unsafe fn main() -> usize {
|
2014-11-24 03:21:17 +00:00
|
|
|
GUARD_PAGE
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(target_os = "macos")]
|
2015-03-13 03:21:17 +00:00
|
|
|
pub unsafe fn current() -> usize {
|
|
|
|
extern {
|
|
|
|
fn pthread_get_stackaddr_np(thread: pthread_t) -> *mut libc::c_void;
|
|
|
|
fn pthread_get_stacksize_np(thread: pthread_t) -> libc::size_t;
|
|
|
|
}
|
2014-11-24 03:21:17 +00:00
|
|
|
(pthread_get_stackaddr_np(pthread_self()) as libc::size_t -
|
2015-03-13 03:21:17 +00:00
|
|
|
pthread_get_stacksize_np(pthread_self())) as usize
|
2014-11-24 03:21:17 +00:00
|
|
|
}
|
|
|
|
|
2015-03-13 03:21:17 +00:00
|
|
|
#[cfg(any(target_os = "openbsd", target_os = "bitrig"))]
|
|
|
|
pub unsafe fn current() -> usize {
|
|
|
|
#[repr(C)]
|
2015-03-18 09:59:09 +00:00
|
|
|
struct stack_t {
|
2015-03-13 03:21:17 +00:00
|
|
|
ss_sp: *mut libc::c_void,
|
|
|
|
ss_size: libc::size_t,
|
|
|
|
ss_flags: libc::c_int,
|
|
|
|
}
|
|
|
|
extern {
|
2015-03-18 09:59:09 +00:00
|
|
|
fn pthread_main_np() -> libc::c_uint;
|
2015-03-13 03:21:17 +00:00
|
|
|
fn pthread_stackseg_np(thread: pthread_t,
|
|
|
|
sinfo: *mut stack_t) -> libc::c_uint;
|
2015-01-29 07:19:28 +00:00
|
|
|
}
|
|
|
|
|
2015-03-13 03:21:17 +00:00
|
|
|
let mut current_stack: stack_t = mem::zeroed();
|
|
|
|
assert_eq!(pthread_stackseg_np(pthread_self(), &mut current_stack), 0);
|
|
|
|
|
|
|
|
let extra = if cfg!(target_os = "bitrig") {3} else {1} * os::page_size();
|
2015-01-29 07:19:28 +00:00
|
|
|
if pthread_main_np() == 1 {
|
|
|
|
// main thread
|
2015-03-13 03:21:17 +00:00
|
|
|
current_stack.ss_sp as usize - current_stack.ss_size as usize + extra
|
2015-01-29 07:19:28 +00:00
|
|
|
} else {
|
|
|
|
// new thread
|
2015-03-13 03:21:17 +00:00
|
|
|
current_stack.ss_sp as usize - current_stack.ss_size as usize
|
2015-01-29 07:19:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-24 03:21:17 +00:00
|
|
|
#[cfg(any(target_os = "linux", target_os = "android"))]
|
2015-03-13 03:21:17 +00:00
|
|
|
pub unsafe fn current() -> usize {
|
2014-11-24 03:21:17 +00:00
|
|
|
let mut attr: libc::pthread_attr_t = mem::zeroed();
|
2015-03-13 03:21:17 +00:00
|
|
|
assert_eq!(pthread_getattr_np(pthread_self(), &mut attr), 0);
|
2014-11-24 03:21:17 +00:00
|
|
|
let mut guardsize = 0;
|
2015-03-13 03:21:17 +00:00
|
|
|
assert_eq!(pthread_attr_getguardsize(&attr, &mut guardsize), 0);
|
2014-11-24 03:21:17 +00:00
|
|
|
if guardsize == 0 {
|
|
|
|
panic!("there is no guard page");
|
|
|
|
}
|
|
|
|
let mut stackaddr = ptr::null_mut();
|
2015-03-13 03:21:17 +00:00
|
|
|
let mut size = 0;
|
|
|
|
assert_eq!(pthread_attr_getstack(&attr, &mut stackaddr, &mut size), 0);
|
|
|
|
assert_eq!(pthread_attr_destroy(&mut attr), 0);
|
2014-11-24 03:21:17 +00:00
|
|
|
|
2015-03-13 03:21:17 +00:00
|
|
|
stackaddr as usize + guardsize as usize
|
2014-11-24 03:21:17 +00:00
|
|
|
}
|
2015-01-17 07:51:04 +00:00
|
|
|
|
2015-03-13 03:21:17 +00:00
|
|
|
#[cfg(any(target_os = "linux", target_os = "android"))]
|
|
|
|
extern {
|
|
|
|
fn pthread_getattr_np(native: libc::pthread_t,
|
|
|
|
attr: *mut libc::pthread_attr_t) -> libc::c_int;
|
|
|
|
fn pthread_attr_getguardsize(attr: *const libc::pthread_attr_t,
|
|
|
|
guardsize: *mut libc::size_t) -> libc::c_int;
|
|
|
|
fn pthread_attr_getstack(attr: *const libc::pthread_attr_t,
|
|
|
|
stackaddr: *mut *mut libc::c_void,
|
|
|
|
stacksize: *mut libc::size_t) -> libc::c_int;
|
2015-01-17 07:51:04 +00:00
|
|
|
}
|
2014-11-24 03:21:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
|
|
|
// is created in an application with big thread-local storage requirements.
|
|
|
|
// See #6233 for rationale and details.
|
|
|
|
//
|
2015-03-23 08:02:02 +00:00
|
|
|
// Use dlsym to get the symbol value at runtime, both for
|
|
|
|
// compatibility with older versions of glibc, and to avoid creating
|
|
|
|
// dependencies on GLIBC_PRIVATE symbols. Assumes that we've been
|
|
|
|
// dynamically linked to libpthread but that is currently always the
|
|
|
|
// case. We previously used weak linkage (under the same assumption),
|
|
|
|
// but that caused Debian to detect an unnecessarily strict versioned
|
2015-03-23 04:58:19 +00:00
|
|
|
// dependency on libc6 (#23628).
|
2014-11-24 03:21:17 +00:00
|
|
|
#[cfg(target_os = "linux")]
|
2015-04-15 05:13:57 +00:00
|
|
|
fn min_stack_size(attr: *const libc::pthread_attr_t) -> usize {
|
2015-03-23 22:54:39 +00:00
|
|
|
use dynamic_lib::DynamicLibrary;
|
|
|
|
use sync::{Once, ONCE_INIT};
|
|
|
|
|
2014-11-24 03:21:17 +00:00
|
|
|
type F = unsafe extern "C" fn(*const libc::pthread_attr_t) -> libc::size_t;
|
2015-03-23 04:58:19 +00:00
|
|
|
static INIT: Once = ONCE_INIT;
|
|
|
|
static mut __pthread_get_minstack: Option<F> = None;
|
|
|
|
|
|
|
|
INIT.call_once(|| {
|
2015-04-22 03:01:34 +00:00
|
|
|
let lib = match DynamicLibrary::open(None) {
|
|
|
|
Ok(l) => l,
|
|
|
|
Err(..) => return,
|
|
|
|
};
|
2015-03-23 04:58:19 +00:00
|
|
|
unsafe {
|
|
|
|
if let Ok(f) = lib.symbol("__pthread_get_minstack") {
|
|
|
|
__pthread_get_minstack = Some(mem::transmute::<*const (), F>(f));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
match unsafe { __pthread_get_minstack } {
|
2015-04-15 05:13:57 +00:00
|
|
|
None => PTHREAD_STACK_MIN as usize,
|
|
|
|
Some(f) => unsafe { f(attr) as usize },
|
2014-11-24 03:21:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-23 07:48:06 +00:00
|
|
|
// No point in looking up __pthread_get_minstack() on non-glibc
|
|
|
|
// platforms.
|
2014-11-24 03:21:17 +00:00
|
|
|
#[cfg(not(target_os = "linux"))]
|
2015-04-15 05:13:57 +00:00
|
|
|
fn min_stack_size(_: *const libc::pthread_attr_t) -> usize {
|
|
|
|
PTHREAD_STACK_MIN as usize
|
2014-11-24 03:21:17 +00:00
|
|
|
}
|
|
|
|
|
2015-01-17 07:51:04 +00:00
|
|
|
extern {
|
2015-03-13 03:21:17 +00:00
|
|
|
fn pthread_self() -> libc::pthread_t;
|
2014-11-24 03:21:17 +00:00
|
|
|
fn pthread_create(native: *mut libc::pthread_t,
|
|
|
|
attr: *const libc::pthread_attr_t,
|
2015-03-13 03:21:17 +00:00
|
|
|
f: extern fn(*mut libc::c_void) -> *mut libc::c_void,
|
2014-11-24 03:21:17 +00:00
|
|
|
value: *mut libc::c_void) -> libc::c_int;
|
|
|
|
fn pthread_join(native: libc::pthread_t,
|
|
|
|
value: *mut *mut libc::c_void) -> libc::c_int;
|
|
|
|
fn pthread_attr_init(attr: *mut libc::pthread_attr_t) -> libc::c_int;
|
2015-03-13 03:21:17 +00:00
|
|
|
fn pthread_attr_destroy(attr: *mut libc::pthread_attr_t) -> libc::c_int;
|
2014-11-24 03:21:17 +00:00
|
|
|
fn pthread_attr_setstacksize(attr: *mut libc::pthread_attr_t,
|
|
|
|
stack_size: libc::size_t) -> libc::c_int;
|
|
|
|
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;
|
|
|
|
fn sched_yield() -> libc::c_int;
|
|
|
|
}
|