diff options
| author | bors <bors@rust-lang.org> | 2013-07-09 18:28:46 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-07-09 18:28:46 -0700 |
| commit | 41dcec2fe16e272016ae77d10a6a5ff3a737f192 (patch) | |
| tree | 6eebc49e7033a0d696c93c8e23d7caeb28d4eca1 /src/libstd/os.rs | |
| parent | 137d1fb210a844a76f89d7355a1aaf9f7a88af33 (diff) | |
| parent | 413d51e32debf0c3f7dda2434b64d73585df21ef (diff) | |
| download | rust-41dcec2fe16e272016ae77d10a6a5ff3a737f192.tar.gz rust-41dcec2fe16e272016ae77d10a6a5ff3a737f192.zip | |
auto merge of #7265 : brson/rust/io-upstream, r=brson
r? @graydon, @nikomatsakis, @pcwalton, or @catamorphism Sorry this is so huge, but it's been accumulating for about a month. There's lots of stuff here, mostly oriented toward enabling multithreaded scheduling and improving compatibility between the old and new runtimes. Adds task pinning so that we can create the 'platform thread' in servo. [Here](https://github.com/brson/rust/blob/e1555f9b5628af2b6c6ed344cad621399cb7684d/src/libstd/rt/mod.rs#L201) is the current runtime setup code. About half of this has already been reviewed.
Diffstat (limited to 'src/libstd/os.rs')
| -rw-r--r-- | src/libstd/os.rs | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/src/libstd/os.rs b/src/libstd/os.rs index 50acbee697f..fc7f2742470 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -741,6 +741,7 @@ pub fn list_dir(p: &Path) -> ~[~str] { as_utf16_p }; use rt::global_heap::malloc_raw; + #[nolink] extern { unsafe fn rust_list_dir_wfd_size() -> libc::size_t; @@ -1134,8 +1135,15 @@ pub fn last_os_error() -> ~str { * ignored and the process exits with the default failure status */ pub fn set_exit_status(code: int) { - unsafe { - rustrt::rust_set_exit_status(code as libc::intptr_t); + use rt; + use rt::OldTaskContext; + + if rt::context() == OldTaskContext { + unsafe { + rustrt::rust_set_exit_status(code as libc::intptr_t); + } + } else { + rt::util::set_exit_status(code); } } @@ -1165,10 +1173,20 @@ pub fn real_args() -> ~[~str] { #[cfg(target_os = "android")] #[cfg(target_os = "freebsd")] pub fn real_args() -> ~[~str] { - unsafe { - let argc = rustrt::rust_get_argc(); - let argv = rustrt::rust_get_argv(); - load_argc_and_argv(argc, argv) + use rt; + use rt::TaskContext; + + if rt::context() == TaskContext { + match rt::args::clone() { + Some(args) => args, + None => fail!("process arguments not initialized") + } + } else { + unsafe { + let argc = rustrt::rust_get_argc(); + let argv = rustrt::rust_get_argv(); + load_argc_and_argv(argc, argv) + } } } |
