1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#![crate_id = "rustrt#0.11.0"]
#![license = "MIT/ASL2"]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/0.11.0/")]
#![feature(macro_rules, phase, globs, thread_local, managed_boxes, asm)]
#![feature(linkage, lang_items, unsafe_destructor)]
#![allow(unknown_features)]#![no_std]
#![experimental]
#[phase(plugin, link)] extern crate core;
extern crate alloc;
extern crate libc;
extern crate collections;
#[cfg(test)] extern crate realrustrt = "rustrt";
#[cfg(test)] extern crate test;
#[cfg(test)] extern crate native;
#[cfg(test)] #[phase(plugin, link)] extern crate std;
pub use self::util::{Stdio, Stdout, Stderr};
pub use self::unwind::{begin_unwind, begin_unwind_fmt};
use core::prelude::*;
use alloc::owned::Box;
use core::any::Any;
use task::{Task, BlockedTask, TaskOpts};
mod macros;
mod at_exit_imp;
mod local_ptr;
mod thread_local_storage;
mod util;
mod libunwind;
pub mod args;
pub mod bookkeeping;
pub mod c_str;
pub mod exclusive;
pub mod local;
pub mod local_data;
pub mod local_heap;
pub mod mutex;
pub mod rtio;
pub mod stack;
pub mod task;
pub mod thread;
pub mod unwind;
pub trait Runtime {fn yield_now(~self, cur_task: Box<Task>);
fn maybe_yield(~self, cur_task: Box<Task>);
fn deschedule(~self, times: uint, cur_task: Box<Task>,
f: |BlockedTask| -> Result<(), BlockedTask>);
fn reawaken(~self, to_wake: Box<Task>);fn spawn_sibling(~self,
cur_task: Box<Task>,
opts: TaskOpts,
f: proc():Send);
fn local_io<'a>(&'a mut self) -> Option<rtio::LocalIo<'a>>;
fn stack_bounds(&self) -> (uint, uint);fn can_block(&self) -> bool;fn wrap(~self) -> Box<Any>;
}
pub static DEFAULT_ERROR_CODE: int = 101;
pub fn init(argc: int, argv: **u8) {unsafe {
args::init(argc, argv);
local_ptr::init();
at_exit_imp::init();
}collections::fixme_14344_be_sure_to_link_to_collections();
alloc::fixme_14344_be_sure_to_link_to_collections();
libc::issue_14344_workaround();
}
pub fn at_exit(f: proc():Send) {
at_exit_imp::push(f);
}
pub unsafe fn cleanup() {
bookkeeping::wait_for_other_tasks();
at_exit_imp::run();
args::cleanup();
local_ptr::cleanup();
}#[doc(hidden)]
pub mod shouldnt_be_public {
#[cfg(not(test))]
pub use super::local_ptr::native::maybe_tls_key;
#[cfg(not(windows), not(target_os = "android"), not(target_os = "ios"))]
pub use super::local_ptr::compiled::RT_TLS_PTR;
}
#[cfg(not(test))]
mod std {
pub use core::{fmt, option, cmp};
}