diff options
| author | Aaron Turon <aturon@mozilla.com> | 2014-10-17 13:39:27 -0700 |
|---|---|---|
| committer | Aaron Turon <aturon@mozilla.com> | 2014-11-08 20:40:39 -0800 |
| commit | fa94fdad3e880d2d6cbd82c12bd12caefbeb81a8 (patch) | |
| tree | 0106666f15341d9d050e99ca73acaf3a2d22d7a5 /src/libnative | |
| parent | 431dcdc840a27f7c7418b7dff73a329eada8a407 (diff) | |
| download | rust-fa94fdad3e880d2d6cbd82c12bd12caefbeb81a8.tar.gz rust-fa94fdad3e880d2d6cbd82c12bd12caefbeb81a8.zip | |
Runtime removal: fully remove rtio
This patch cleans up the remnants of the runtime IO interface. Because this eliminates APIs in `libnative` and `librustrt`, it is a: [breaking-change] This functionality is likely to be available publicly, in some form, from `std` in the future.
Diffstat (limited to 'src/libnative')
| -rw-r--r-- | src/libnative/io/mod.rs | 102 | ||||
| -rw-r--r-- | src/libnative/lib.rs | 1 | ||||
| -rw-r--r-- | src/libnative/task.rs | 8 |
3 files changed, 0 insertions, 111 deletions
diff --git a/src/libnative/io/mod.rs b/src/libnative/io/mod.rs deleted file mode 100644 index 8c7751588ce..00000000000 --- a/src/libnative/io/mod.rs +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// 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. - -//! Native thread-blocking I/O implementation -//! -//! This module contains the implementation of native thread-blocking -//! implementations of I/O on all platforms. This module is not intended to be -//! used directly, but rather the rust runtime will fall back to using it if -//! necessary. -//! -//! Rust code normally runs inside of green tasks with a local scheduler using -//! asynchronous I/O to cooperate among tasks. This model is not always -//! available, however, and that's where these native implementations come into -//! play. The only dependencies of these modules are the normal system libraries -//! that you would find on the respective platform. - -#![allow(non_snake_case)] - -use libc::{mod, c_int}; -use std::c_str::CString; -use std::os; -use std::rt::rtio::{mod, IoResult, IoError}; -use std::num; - -#[cfg(windows)] -#[path = "tty_windows.rs"] -mod tty; - -fn unimpl() -> IoError { - #[cfg(unix)] use libc::ENOSYS as ERROR; - #[cfg(windows)] use libc::ERROR_CALL_NOT_IMPLEMENTED as ERROR; - IoError { - code: ERROR as uint, - extra: 0, - detail: Some("not yet supported by the `native` runtime, maybe try `green`.".to_string()), - } -} - -fn last_error() -> IoError { - let errno = os::errno() as uint; - IoError { - code: os::errno() as uint, - extra: 0, - detail: Some(os::error_string(errno)), - } -} - -#[cfg(windows)] -#[inline] -fn retry<I> (f: || -> I) -> I { f() } // PR rust-lang/rust/#17020 - -#[cfg(unix)] -#[inline] -fn retry<I: PartialEq + num::One + Neg<I>> (f: || -> I) -> I { - let minus_one = -num::one::<I>(); - loop { - let n = f(); - if n == minus_one && os::errno() == libc::EINTR as int { } - else { return n } - } -} - - -fn keep_going(data: &[u8], f: |*const u8, uint| -> i64) -> i64 { - let origamt = data.len(); - let mut data = data.as_ptr(); - let mut amt = origamt; - while amt > 0 { - let ret = retry(|| f(data, amt)); - if ret == 0 { - break - } else if ret != -1 { - amt -= ret as uint; - data = unsafe { data.offset(ret as int) }; - } else { - return ret; - } - } - return (origamt - amt) as i64; -} - -/// Implementation of rt::rtio's IoFactory trait to generate handles to the -/// native I/O functionality. -pub struct IoFactory { - _cannot_construct_outside_of_this_module: () -} - -impl IoFactory { - pub fn new() -> IoFactory { - IoFactory { _cannot_construct_outside_of_this_module: () } - } -} - -impl rtio::IoFactory for IoFactory { -} diff --git a/src/libnative/lib.rs b/src/libnative/lib.rs index c0ec4c16ab0..4e25feb9d75 100644 --- a/src/libnative/lib.rs +++ b/src/libnative/lib.rs @@ -74,7 +74,6 @@ use std::str; pub use task::NativeTaskBuilder; -pub mod io; pub mod task; #[cfg(any(windows, android))] diff --git a/src/libnative/task.rs b/src/libnative/task.rs index e702c12bdff..6d640b61b18 100644 --- a/src/libnative/task.rs +++ b/src/libnative/task.rs @@ -19,13 +19,11 @@ use std::mem; use std::rt::bookkeeping; use std::rt::local::Local; use std::rt::mutex::NativeMutex; -use std::rt::rtio; use std::rt::stack; use std::rt::task::{Task, BlockedTask, TaskOpts}; use std::rt::thread::Thread; use std::rt; -use io; use std::task::{TaskBuilder, Spawner}; /// Creates a new Task which is ready to execute as a 1:1 task. @@ -42,7 +40,6 @@ fn ops() -> Box<Ops> { box Ops { lock: unsafe { NativeMutex::new() }, awoken: false, - io: io::IoFactory::new(), // these *should* get overwritten stack_bounds: (0, 0), stack_guard: 0 @@ -112,7 +109,6 @@ impl<S: Spawner> NativeTaskBuilder for TaskBuilder<S> { struct Ops { lock: NativeMutex, // native synchronization awoken: bool, // used to prevent spurious wakeups - io: io::IoFactory, // local I/O factory // This field holds the known bounds of the stack in (lo, hi) form. Not all // native tasks necessarily know their precise bounds, hence this is @@ -272,10 +268,6 @@ impl rt::Runtime for Ops { NativeSpawner.spawn(opts, f); } - - fn local_io<'a>(&'a mut self) -> Option<rtio::LocalIo<'a>> { - Some(rtio::LocalIo::new(&mut self.io as &mut rtio::IoFactory)) - } } #[cfg(test)] |
