diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2013-11-06 15:16:04 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2013-11-11 10:40:34 -0800 |
| commit | 7755ffd0131fa99ca5d58bdd5eab443b44d5a1ff (patch) | |
| tree | c00e95dee93195cb7744c4a37ea1d4d438db9456 /src/libstd/rt/io | |
| parent | 4059b5c4b3b8a57a645982b0770d25f0283dfb06 (diff) | |
| download | rust-7755ffd0131fa99ca5d58bdd5eab443b44d5a1ff.tar.gz rust-7755ffd0131fa99ca5d58bdd5eab443b44d5a1ff.zip | |
Remove #[fixed_stack_segment] and #[rust_stack]
These two attributes are no longer useful now that Rust has decided to leave segmented stacks behind. It is assumed that the rust task's stack is always large enough to make an FFI call (due to the stack being very large). There's always the case of stack overflow, however, to consider. This does not change the behavior of stack overflow in Rust. This is still normally triggered by the __morestack function and aborts the whole process. C stack overflow will continue to corrupt the stack, however (as it did before this commit as well). The future improvement of a guard page at the end of every rust stack is still unimplemented and is intended to be the mechanism through which we attempt to detect C stack overflow. Closes #8822 Closes #10155
Diffstat (limited to 'src/libstd/rt/io')
| -rw-r--r-- | src/libstd/rt/io/native/file.rs | 27 | ||||
| -rw-r--r-- | src/libstd/rt/io/native/process.rs | 15 | ||||
| -rw-r--r-- | src/libstd/rt/io/signal.rs | 1 | ||||
| -rw-r--r-- | src/libstd/rt/io/stdio.rs | 2 |
4 files changed, 1 insertions, 44 deletions
diff --git a/src/libstd/rt/io/native/file.rs b/src/libstd/rt/io/native/file.rs index 6d4f29182dd..69d1159bf91 100644 --- a/src/libstd/rt/io/native/file.rs +++ b/src/libstd/rt/io/native/file.rs @@ -98,7 +98,6 @@ impl FileDesc { } impl Reader for FileDesc { - #[fixed_stack_segment] #[inline(never)] fn read(&mut self, buf: &mut [u8]) -> Option<uint> { #[cfg(windows)] type rlen = libc::c_uint; #[cfg(not(windows))] type rlen = libc::size_t; @@ -121,7 +120,6 @@ impl Reader for FileDesc { } impl Writer for FileDesc { - #[fixed_stack_segment] #[inline(never)] fn write(&mut self, buf: &[u8]) { #[cfg(windows)] type wlen = libc::c_uint; #[cfg(not(windows))] type wlen = libc::size_t; @@ -137,7 +135,6 @@ impl Writer for FileDesc { } impl Drop for FileDesc { - #[fixed_stack_segment] #[inline(never)] fn drop(&mut self) { if self.close_on_drop { unsafe { libc::close(self.fd); } @@ -158,7 +155,6 @@ impl CFile { } impl Reader for CFile { - #[fixed_stack_segment] #[inline(never)] fn read(&mut self, buf: &mut [u8]) -> Option<uint> { let ret = do keep_going(buf) |buf, len| { unsafe { @@ -176,14 +172,12 @@ impl Reader for CFile { } } - #[fixed_stack_segment] #[inline(never)] fn eof(&mut self) -> bool { unsafe { libc::feof(self.file) != 0 } } } impl Writer for CFile { - #[fixed_stack_segment] #[inline(never)] fn write(&mut self, buf: &[u8]) { let ret = do keep_going(buf) |buf, len| { unsafe { @@ -196,7 +190,6 @@ impl Writer for CFile { } } - #[fixed_stack_segment] #[inline(never)] fn flush(&mut self) { if unsafe { libc::fflush(self.file) } < 0 { raise_error(); @@ -205,7 +198,6 @@ impl Writer for CFile { } impl Seek for CFile { - #[fixed_stack_segment] #[inline(never)] fn tell(&self) -> u64 { let ret = unsafe { libc::ftell(self.file) }; if ret < 0 { @@ -214,7 +206,6 @@ impl Seek for CFile { return ret as u64; } - #[fixed_stack_segment] #[inline(never)] fn seek(&mut self, pos: i64, style: SeekStyle) { let whence = match style { SeekSet => libc::SEEK_SET, @@ -228,7 +219,6 @@ impl Seek for CFile { } impl Drop for CFile { - #[fixed_stack_segment] #[inline(never)] fn drop(&mut self) { unsafe { libc::fclose(self.file); } } @@ -242,7 +232,6 @@ mod tests { use rt::io::{io_error, SeekSet}; use super::*; - #[test] #[fixed_stack_segment] #[ignore(cfg(target_os = "freebsd"))] // hmm, maybe pipes have a tiny buffer fn test_file_desc() { // Run this test with some pipes so we don't have to mess around with @@ -278,7 +267,6 @@ mod tests { } } - #[test] #[fixed_stack_segment] #[ignore(cfg(windows))] // apparently windows doesn't like tmpfile fn test_cfile() { unsafe { @@ -358,7 +346,6 @@ mod old_os { #[cfg(unix)] /// Indicates whether a path represents a directory pub fn path_is_dir(p: &Path) -> bool { - #[fixed_stack_segment]; #[inline(never)]; unsafe { do p.with_c_str |buf| { rustrt::rust_path_is_dir(buf) != 0 as c_int @@ -369,7 +356,6 @@ mod old_os { #[cfg(windows)] pub fn path_is_dir(p: &Path) -> bool { - #[fixed_stack_segment]; #[inline(never)]; unsafe { do os::win32::as_utf16_p(p.as_str().unwrap()) |buf| { rustrt::rust_path_is_dir_u16(buf) != 0 as c_int @@ -380,7 +366,6 @@ mod old_os { #[cfg(unix)] /// Indicates whether a path exists pub fn path_exists(p: &Path) -> bool { - #[fixed_stack_segment]; #[inline(never)]; unsafe { do p.with_c_str |buf| { rustrt::rust_path_exists(buf) != 0 as c_int @@ -390,7 +375,6 @@ mod old_os { #[cfg(windows)] pub fn path_exists(p: &Path) -> bool { - #[fixed_stack_segment]; #[inline(never)]; unsafe { do os::win32::as_utf16_p(p.as_str().unwrap()) |buf| { rustrt::rust_path_exists_u16(buf) != 0 as c_int @@ -404,7 +388,6 @@ mod old_os { #[cfg(windows)] fn mkdir(p: &Path, _mode: c_int) -> bool { - #[fixed_stack_segment]; #[inline(never)]; unsafe { use os::win32::as_utf16_p; // FIXME: turn mode into something useful? #2623 @@ -417,7 +400,6 @@ mod old_os { #[cfg(unix)] fn mkdir(p: &Path, mode: c_int) -> bool { - #[fixed_stack_segment]; #[inline(never)]; do p.with_c_str |buf| { unsafe { libc::mkdir(buf, mode as libc::mode_t) == (0 as c_int) @@ -457,7 +439,6 @@ mod old_os { #[cfg(target_os = "freebsd")] #[cfg(target_os = "macos")] unsafe fn get_list(p: &Path) -> ~[Path] { - #[fixed_stack_segment]; #[inline(never)]; use libc::{dirent_t}; use libc::{opendir, readdir, closedir}; extern { @@ -488,7 +469,6 @@ mod old_os { } #[cfg(windows)] unsafe fn get_list(p: &Path) -> ~[Path] { - #[fixed_stack_segment]; #[inline(never)]; use libc::consts::os::extra::INVALID_HANDLE_VALUE; use libc::{wcslen, free}; use libc::funcs::extra::kernel32::{ @@ -568,7 +548,6 @@ mod old_os { #[cfg(windows)] fn rmdir(p: &Path) -> bool { - #[fixed_stack_segment]; #[inline(never)]; unsafe { use os::win32::as_utf16_p; return do as_utf16_p(p.as_str().unwrap()) |buf| { @@ -579,7 +558,6 @@ mod old_os { #[cfg(unix)] fn rmdir(p: &Path) -> bool { - #[fixed_stack_segment]; #[inline(never)]; do p.with_c_str |buf| { unsafe { libc::rmdir(buf) == (0 as c_int) @@ -594,7 +572,6 @@ mod old_os { #[cfg(windows)] fn unlink(p: &Path) -> bool { - #[fixed_stack_segment]; #[inline(never)]; unsafe { use os::win32::as_utf16_p; return do as_utf16_p(p.as_str().unwrap()) |buf| { @@ -605,7 +582,6 @@ mod old_os { #[cfg(unix)] fn unlink(p: &Path) -> bool { - #[fixed_stack_segment]; #[inline(never)]; unsafe { do p.with_c_str |buf| { libc::unlink(buf) == (0 as c_int) @@ -616,7 +592,6 @@ mod old_os { /// Renames an existing file or directory pub fn rename_file(old: &Path, new: &Path) -> bool { - #[fixed_stack_segment]; #[inline(never)]; unsafe { do old.with_c_str |old_buf| { do new.with_c_str |new_buf| { @@ -632,7 +607,6 @@ mod old_os { #[cfg(windows)] fn do_copy_file(from: &Path, to: &Path) -> bool { - #[fixed_stack_segment]; #[inline(never)]; unsafe { use os::win32::as_utf16_p; return do as_utf16_p(from.as_str().unwrap()) |fromp| { @@ -646,7 +620,6 @@ mod old_os { #[cfg(unix)] fn do_copy_file(from: &Path, to: &Path) -> bool { - #[fixed_stack_segment]; #[inline(never)]; unsafe { let istream = do from.with_c_str |fromp| { do "rb".with_c_str |modebuf| { diff --git a/src/libstd/rt/io/native/process.rs b/src/libstd/rt/io/native/process.rs index f5c39de1bf4..9bf0ed63e8c 100644 --- a/src/libstd/rt/io/native/process.rs +++ b/src/libstd/rt/io/native/process.rs @@ -69,8 +69,6 @@ impl Process { stdin: Option<file::fd_t>, stdout: Option<file::fd_t>, stderr: Option<file::fd_t>) -> Process { - #[fixed_stack_segment]; #[inline(never)]; - let (in_pipe, in_fd) = match stdin { None => { let pipe = os::pipe(); @@ -208,7 +206,6 @@ impl Process { #[cfg(windows)] unsafe fn killpid(pid: pid_t, signal: int) -> Result<(), io::IoError> { - #[fixed_stack_segment]; #[inline(never)]; match signal { io::process::PleaseExitSignal | io::process::MustDieSignal => { @@ -226,7 +223,6 @@ impl Process { #[cfg(not(windows))] unsafe fn killpid(pid: pid_t, signal: int) -> Result<(), io::IoError> { - #[fixed_stack_segment]; #[inline(never)]; libc::funcs::posix88::signal::kill(pid, signal as c_int); Ok(()) } @@ -254,8 +250,6 @@ fn spawn_process_os(prog: &str, args: &[~str], env: Option<~[(~str, ~str)]>, dir: Option<&Path>, in_fd: c_int, out_fd: c_int, err_fd: c_int) -> SpawnProcessResult { - #[fixed_stack_segment]; #[inline(never)]; - use libc::types::os::arch::extra::{DWORD, HANDLE, STARTUPINFO}; use libc::consts::os::extra::{ TRUE, FALSE, @@ -439,8 +433,6 @@ fn spawn_process_os(prog: &str, args: &[~str], env: Option<~[(~str, ~str)]>, dir: Option<&Path>, in_fd: c_int, out_fd: c_int, err_fd: c_int) -> SpawnProcessResult { - #[fixed_stack_segment]; #[inline(never)]; - use libc::funcs::posix88::unistd::{fork, dup2, close, chdir, execvp}; use libc::funcs::bsd44::getdtablesize; @@ -455,7 +447,7 @@ fn spawn_process_os(prog: &str, args: &[~str], unsafe fn set_environ(_envp: *c_void) {} #[cfg(target_os = "macos")] unsafe fn set_environ(envp: *c_void) { - externfn!(fn _NSGetEnviron() -> *mut *c_void); + extern { fn _NSGetEnviron() -> *mut *c_void; } *_NSGetEnviron() = envp; } @@ -603,7 +595,6 @@ fn with_dirp<T>(d: Option<&Path>, cb: &fn(*libc::c_char) -> T) -> T { #[cfg(windows)] fn free_handle(handle: *()) { - #[fixed_stack_segment]; #[inline(never)]; unsafe { libc::funcs::extra::kernel32::CloseHandle(cast::transmute(handle)); } @@ -629,8 +620,6 @@ fn waitpid(pid: pid_t) -> int { #[cfg(windows)] fn waitpid_os(pid: pid_t) -> int { - #[fixed_stack_segment]; #[inline(never)]; - use libc::types::os::arch::extra::DWORD; use libc::consts::os::extra::{ SYNCHRONIZE, @@ -676,8 +665,6 @@ fn waitpid(pid: pid_t) -> int { #[cfg(unix)] fn waitpid_os(pid: pid_t) -> int { - #[fixed_stack_segment]; #[inline(never)]; - use libc::funcs::posix01::wait::*; #[cfg(target_os = "linux")] diff --git a/src/libstd/rt/io/signal.rs b/src/libstd/rt/io/signal.rs index 9fe8cb3ed90..3f013d5cac9 100644 --- a/src/libstd/rt/io/signal.rs +++ b/src/libstd/rt/io/signal.rs @@ -154,7 +154,6 @@ mod test { // kill is only available on Unixes #[cfg(unix)] - #[fixed_stack_segment] fn sigint() { unsafe { libc::funcs::posix88::signal::kill(libc::getpid(), libc::SIGINT); diff --git a/src/libstd/rt/io/stdio.rs b/src/libstd/rt/io/stdio.rs index acc2e11f067..e829c77cec1 100644 --- a/src/libstd/rt/io/stdio.rs +++ b/src/libstd/rt/io/stdio.rs @@ -69,7 +69,6 @@ enum StdSource { File(~RtioFileStream), } -#[fixed_stack_segment] #[inline(never)] fn src<T>(fd: libc::c_int, readable: bool, f: &fn(StdSource) -> T) -> T { do with_local_io |io| { let fd = unsafe { libc::dup(fd) }; @@ -91,7 +90,6 @@ fn src<T>(fd: libc::c_int, readable: bool, f: &fn(StdSource) -> T) -> T { /// Creates a new non-blocking handle to the stdin of the current process. /// /// See `stdout()` for notes about this function. -#[fixed_stack_segment] #[inline(never)] pub fn stdin() -> StdReader { do src(libc::STDIN_FILENO, true) |src| { StdReader { inner: src } } } |
