use sys::{cvt, syscall};
use time::Duration;
+pub const DEFAULT_MIN_STACK_SIZE: usize = 2 * 1024 * 1024;
+
pub struct Thread {
id: usize,
}
impl AsInner<libc::c_int> for Socket {
fn as_inner(&self) -> &libc::c_int { self.0.as_inner() }
}
-
+
impl FromInner<libc::c_int> for Socket {
fn from_inner(fd: libc::c_int) -> Socket { Socket(FileDesc::new(fd)) }
}
-
+
impl IntoInner<libc::c_int> for Socket {
fn into_inner(self) -> libc::c_int { self.0.into_raw() }
}
use sys_common::thread::*;
+#[cfg(not(target_os = "l4re"))]
+pub const DEFAULT_MIN_STACK_SIZE: usize = 2 * 1024 * 1024;
+#[cfg(target_os = "l4re")]
+pub const DEFAULT_MIN_STACK_SIZE: usize = 1024 * 1024;
+
pub struct Thread {
id: libc::pthread_t,
}
use sys_common::thread::*;
use time::Duration;
+pub const DEFAULT_MIN_STACK_SIZE: usize = 2 * 1024 * 1024;
+
pub struct Thread {
handle: Handle
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use env;
use alloc::boxed::FnBox;
use libc;
+use sync::atomic::{self, Ordering};
use sys::stack_overflow;
+use sys::thread as imp;
pub unsafe fn start_thread(main: *mut libc::c_void) {
// Next, set up our stack overflow handler which may get triggered if we run
// Finally, let's run some code.
Box::from_raw(main as *mut Box<FnBox()>)()
}
+
+pub fn min_stack() -> usize {
+ static MIN: atomic::AtomicUsize = atomic::AtomicUsize::new(0);
+ match MIN.load(Ordering::SeqCst) {
+ 0 => {}
+ n => return n - 1,
+ }
+ let amt = env::var("RUST_MIN_STACK").ok().and_then(|s| s.parse().ok());
+ let amt = amt.unwrap_or(imp::DEFAULT_MIN_STACK_SIZE);
+
+ // 0 is our sentinel value, so ensure that we'll never see 0 after
+ // initialization has run
+ MIN.store(amt + 1, Ordering::SeqCst);
+ amt
+}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use env;
use fmt;
use io::prelude::*;
-use sync::atomic::{self, Ordering};
use sys::stdio::Stderr;
use thread;
-pub fn min_stack() -> usize {
- static MIN: atomic::AtomicUsize = atomic::AtomicUsize::new(0);
- match MIN.load(Ordering::SeqCst) {
- 0 => {}
- n => return n - 1,
- }
- let amt = env::var("RUST_MIN_STACK").ok().and_then(|s| s.parse().ok());
- #[cfg(not(target_os = "l4re"))]
- let amt = amt.unwrap_or(2 * 1024 * 1024);
- // L4Re only supports a maximum of 1Mb per default.
- #[cfg(target_os = "l4re")]
- let amt = amt.unwrap_or(1024 * 1024);
-
- // 0 is our sentinel value, so ensure that we'll never see 0 after
- // initialization has run
- MIN.store(amt + 1, Ordering::SeqCst);
- amt
-}
-
pub fn dumb_print(args: fmt::Arguments) {
let _ = Stderr::new().map(|mut stderr| stderr.write_fmt(args));
}
use sys::thread as imp;
use sys_common::mutex;
use sys_common::thread_info;
-use sys_common::util;
+use sys_common::thread;
use sys_common::{AsInner, IntoInner};
use time::Duration;
{
let Builder { name, stack_size } = self;
- let stack_size = stack_size.unwrap_or_else(util::min_stack);
+ let stack_size = stack_size.unwrap_or_else(thread::min_stack);
let my_thread = Thread::new(name);
let their_thread = my_thread.clone();