Skip to content

Commit 6cad8f4

Browse files
committed
Test fixes and rebase conflicts
* vec::raw::to_ptr is gone * Pausible => Pausable * Removing @ * Calling the main task "<main>" * Removing unused imports * Removing unused mut * Bringing some libextra tests up to date * Allowing compiletest to work at stage0 * Fixing the bootstrap-from-c rmake tests * assert => rtassert in a few cases * printing to stderr instead of stdout in fail!()
1 parent b47ff23 commit 6cad8f4

File tree

41 files changed

+274
-191
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+274
-191
lines changed

src/compiletest/compiletest.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#[allow(non_camel_case_types)];
1414
#[deny(warnings)];
1515

16+
#[cfg(stage0)] extern mod green;
1617
extern mod extra;
1718

1819
use std::os;

src/libextra/comm.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ pub fn rendezvous<T: Send>() -> (SyncPort<T>, SyncChan<T>) {
9696
#[cfg(test)]
9797
mod test {
9898
use comm::{DuplexStream, rendezvous};
99-
use std::rt::test::run_in_uv_task;
10099

101100

102101
#[test]
@@ -124,13 +123,11 @@ mod test {
124123
#[test]
125124
fn recv_a_lot() {
126125
// Rendezvous streams should be able to handle any number of messages being sent
127-
do run_in_uv_task {
128-
let (port, chan) = rendezvous();
129-
do spawn {
130-
1000000.times(|| { chan.send(()) })
131-
}
132-
1000000.times(|| { port.recv() })
126+
let (port, chan) = rendezvous();
127+
do spawn {
128+
1000000.times(|| { chan.send(()) })
133129
}
130+
1000000.times(|| { port.recv() })
134131
}
135132

136133
#[test]

src/libextra/sync.rs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -761,23 +761,21 @@ mod tests {
761761
fn test_sem_runtime_friendly_blocking() {
762762
// Force the runtime to schedule two threads on the same sched_loop.
763763
// When one blocks, it should schedule the other one.
764-
do task::spawn_sched(task::SingleThreaded) {
765-
let s = Semaphore::new(1);
766-
let s2 = s.clone();
767-
let (p, c) = Chan::new();
768-
let mut child_data = Some((s2, c));
769-
s.access(|| {
770-
let (s2, c) = child_data.take_unwrap();
771-
do task::spawn {
772-
c.send(());
773-
s2.access(|| { });
774-
c.send(());
775-
}
776-
let _ = p.recv(); // wait for child to come alive
777-
5.times(|| { task::deschedule(); }); // let the child contend
778-
});
779-
let _ = p.recv(); // wait for child to be done
780-
}
764+
let s = Semaphore::new(1);
765+
let s2 = s.clone();
766+
let (p, c) = Chan::new();
767+
let mut child_data = Some((s2, c));
768+
s.access(|| {
769+
let (s2, c) = child_data.take_unwrap();
770+
do task::spawn {
771+
c.send(());
772+
s2.access(|| { });
773+
c.send(());
774+
}
775+
let _ = p.recv(); // wait for child to come alive
776+
5.times(|| { task::deschedule(); }); // let the child contend
777+
});
778+
let _ = p.recv(); // wait for child to be done
781779
}
782780
/************************************************************************
783781
* Mutex tests

src/libextra/task_pool.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
use std::task;
1818
use std::vec;
1919

20-
#[cfg(test)] use std::task::SingleThreaded;
21-
2220
enum Msg<T> {
2321
Execute(proc(&T)),
2422
Quit

src/libgreen/basic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
//! loop if no other one is provided (and M:N scheduling is desired).
1717
1818
use std::cast;
19-
use std::rt::rtio::{EventLoop, IoFactory, RemoteCallback, PausibleIdleCallback,
19+
use std::rt::rtio::{EventLoop, IoFactory, RemoteCallback, PausableIdleCallback,
2020
Callback};
2121
use std::unstable::sync::Exclusive;
2222
use std::util;

src/libgreen/lib.rs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,7 @@
1818
//! functionality inside of 1:1 programs.
1919
2020
#[pkgid = "green#0.9-pre"];
21-
#[link(name = "green",
22-
package_id = "green",
23-
vers = "0.9-pre",
24-
uuid = "20c38f8c-bfea-83ed-a068-9dc05277be26",
25-
url = "https://github.com/mozilla/rust/tree/master/src/libgreen")];
26-
21+
#[crate_id = "green#0.9-pre"];
2722
#[license = "MIT/ASL2"];
2823
#[crate_type = "rlib"];
2924
#[crate_type = "dylib"];
@@ -61,16 +56,13 @@ pub mod stack;
6156
pub mod task;
6257

6358
#[lang = "start"]
59+
#[cfg(not(test))]
6460
pub fn lang_start(main: *u8, argc: int, argv: **u8) -> int {
6561
use std::cast;
66-
let mut ret = None;
67-
simple::task().run(|| {
68-
ret = Some(do start(argc, argv) {
69-
let main: extern "Rust" fn() = unsafe { cast::transmute(main) };
70-
main();
71-
})
72-
});
73-
ret.unwrap()
62+
do start(argc, argv) {
63+
let main: extern "Rust" fn() = unsafe { cast::transmute(main) };
64+
main();
65+
}
7466
}
7567

7668
/// Set up a default runtime configuration, given compiler-supplied arguments.
@@ -93,10 +85,14 @@ pub fn lang_start(main: *u8, argc: int, argv: **u8) -> int {
9385
/// error.
9486
pub fn start(argc: int, argv: **u8, main: proc()) -> int {
9587
rt::init(argc, argv);
96-
let exit_code = run(main);
88+
let mut main = Some(main);
89+
let mut ret = None;
90+
simple::task().run(|| {
91+
ret = Some(run(main.take_unwrap()));
92+
});
9793
// unsafe is ok b/c we're sure that the runtime is gone
9894
unsafe { rt::cleanup() }
99-
exit_code
95+
ret.unwrap()
10096
}
10197

10298
/// Execute the main function in a pool of M:N schedulers.
@@ -114,6 +110,7 @@ pub fn run(main: proc()) -> int {
114110
let (port, chan) = Chan::new();
115111
let mut opts = TaskOpts::new();
116112
opts.notify_chan = Some(chan);
113+
opts.name = Some(SendStrStatic("<main>"));
117114
pool.spawn(opts, main);
118115

119116
// Wait for the main task to return, and set the process error code

src/libgreen/macros.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,13 @@ macro_rules! rtabort (
5454
pub fn dumb_println(args: &fmt::Arguments) {
5555
use std::io;
5656
use std::libc;
57-
use std::vec;
5857

5958
struct Stderr;
6059
impl io::Writer for Stderr {
6160
fn write(&mut self, data: &[u8]) {
6261
unsafe {
6362
libc::write(libc::STDERR_FILENO,
64-
vec::raw::to_ptr(data) as *libc::c_void,
63+
data.as_ptr() as *libc::c_void,
6564
data.len() as libc::size_t);
6665
}
6766
}

src/libgreen/sched.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use std::cast;
1212
use std::rand::{XorShiftRng, Rng, Rand};
1313
use std::rt::local::Local;
14-
use std::rt::rtio::{RemoteCallback, PausibleIdleCallback, Callback, EventLoop};
14+
use std::rt::rtio::{RemoteCallback, PausableIdleCallback, Callback, EventLoop};
1515
use std::rt::task::BlockedTask;
1616
use std::rt::task::Task;
1717
use std::sync::deque;
@@ -779,6 +779,9 @@ impl Scheduler {
779779
/// randomness is a result of performing a round of work stealing (which
780780
/// may end up stealing from the current scheduler).
781781
pub fn yield_now(mut ~self, cur: ~GreenTask) {
782+
// Async handles trigger the scheduler by calling yield_now on the local
783+
// task, which eventually gets us to here. See comments in SchedRunner
784+
// for more info on this.
782785
if cur.is_sched() {
783786
assert!(self.sched_task.is_none());
784787
self.run_sched_once(cur);
@@ -1345,7 +1348,7 @@ mod test {
13451348

13461349
impl Drop for S {
13471350
fn drop(&mut self) {
1348-
let _foo = @0;
1351+
let _foo = ~0;
13491352
}
13501353
}
13511354

src/libnative/io/process.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use std::cast;
1211
use std::io;
1312
use std::libc::{pid_t, c_void, c_int};
1413
use std::libc;
@@ -17,6 +16,8 @@ use std::ptr;
1716
use std::rt::rtio;
1817
use p = std::io::process;
1918

19+
#[cfg(windows)] use std::cast;
20+
2021
use super::file;
2122

2223
/**

src/libnative/lib.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,7 @@
1515
//! version of I/O.
1616
1717
#[pkgid = "native#0.9-pre"];
18-
#[link(name = "native",
19-
package_id = "native",
20-
vers = "0.9-pre",
21-
uuid = "535344a7-890f-5a23-e1f3-e0d118805141",
22-
url = "https://github.com/mozilla/rust/tree/master/src/native")];
23-
18+
#[crate_id = "native#0.9-pre"];
2419
#[license = "MIT/ASL2"];
2520
#[crate_type = "rlib"];
2621
#[crate_type = "dylib"];
@@ -46,7 +41,7 @@ pub mod task;
4641
#[lang = "start"]
4742
pub fn lang_start(main: *u8, argc: int, argv: **u8) -> int {
4843
use std::cast;
49-
use std::task::try;
44+
use std::task;
5045

5146
do start(argc, argv) {
5247
// Instead of invoking main directly on this thread, invoke it on
@@ -55,7 +50,9 @@ pub fn lang_start(main: *u8, argc: int, argv: **u8) -> int {
5550
// of the main thread's stack, so for stack overflow detection to work
5651
// we must spawn the task in a subtask which we know the stack size of.
5752
let main: extern "Rust" fn() = unsafe { cast::transmute(main) };
58-
match do try { main() } {
53+
let mut task = task::task();
54+
task.name("<main>");
55+
match do task.try { main() } {
5956
Ok(()) => { os::set_exit_status(0); }
6057
Err(..) => { os::set_exit_status(rt::DEFAULT_ERROR_CODE); }
6158
}

src/librustc/back/link.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,10 @@ pub mod write {
333333
}
334334

335335
unsafe fn configure_llvm(sess: Session) {
336+
use std::unstable::mutex::{MUTEX_INIT, Mutex};
337+
static mut LOCK: Mutex = MUTEX_INIT;
338+
static mut CONFIGURED: bool = false;
339+
336340
// Copy what clan does by turning on loop vectorization at O2 and
337341
// slp vectorization at O3
338342
let vectorize_loop = !sess.no_vectorize_loops() &&
@@ -360,7 +364,13 @@ pub mod write {
360364
add(*arg);
361365
}
362366

363-
llvm::LLVMRustSetLLVMOptions(llvm_args.len() as c_int, llvm_args.as_ptr());
367+
LOCK.lock();
368+
if !CONFIGURED {
369+
llvm::LLVMRustSetLLVMOptions(llvm_args.len() as c_int,
370+
llvm_args.as_ptr());
371+
CONFIGURED = true;
372+
}
373+
LOCK.unlock();
364374
}
365375

366376
unsafe fn populate_llvm_passes(fpm: lib::llvm::PassManagerRef,

src/librustpkg/tests.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -487,8 +487,9 @@ fn lib_output_file_name(workspace: &Path, short_name: &str) -> Path {
487487
}
488488

489489
fn output_file_name(workspace: &Path, short_name: ~str) -> Path {
490-
target_build_dir(workspace).join(short_name.as_slice()).join(format!("{}{}", short_name,
491-
os::EXE_SUFFIX))
490+
target_build_dir(workspace).join(short_name.as_slice())
491+
.join(format!("{}{}", short_name,
492+
os::consts::EXE_SUFFIX))
492493
}
493494

494495
#[cfg(target_os = "linux")]
@@ -1353,7 +1354,7 @@ fn test_import_rustpkg() {
13531354
command_line_test([~"build", ~"foo"], workspace);
13541355
debug!("workspace = {}", workspace.display());
13551356
assert!(target_build_dir(workspace).join("foo").join(format!("pkg{}",
1356-
os::EXE_SUFFIX)).exists());
1357+
os::consts::EXE_SUFFIX)).exists());
13571358
}
13581359

13591360
#[test]
@@ -1366,7 +1367,7 @@ fn test_macro_pkg_script() {
13661367
command_line_test([~"build", ~"foo"], workspace);
13671368
debug!("workspace = {}", workspace.display());
13681369
assert!(target_build_dir(workspace).join("foo").join(format!("pkg{}",
1369-
os::EXE_SUFFIX)).exists());
1370+
os::consts::EXE_SUFFIX)).exists());
13701371
}
13711372

13721373
#[test]

src/librustuv/file.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use std::rt::task::BlockedTask;
1818
use std::io::{FileStat, IoError};
1919
use std::io;
2020
use std::rt::rtio;
21-
use std::vec;
2221

2322
use homing::{HomingIO, HomeHandle};
2423
use super::{Loop, UvError, uv_error_to_io_error, wait_until_woken_after, wakeup};

src/librustuv/idle.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ mod test {
100100
use std::cast;
101101
use std::cell::RefCell;
102102
use std::rc::Rc;
103-
use std::rt::rtio::{Callback, PausibleIdleCallback};
103+
use std::rt::rtio::{Callback, PausableIdleCallback};
104104
use std::rt::task::{BlockedTask, Task};
105105
use std::rt::local::Local;
106106
use super::IdleWatcher;

src/librustuv/macros.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,13 @@ macro_rules! uvdebug (
3030
pub fn dumb_println(args: &fmt::Arguments) {
3131
use std::io;
3232
use std::libc;
33-
use std::vec;
3433

3534
struct Stderr;
3635
impl io::Writer for Stderr {
3736
fn write(&mut self, data: &[u8]) {
3837
unsafe {
3938
libc::write(libc::STDERR_FILENO,
40-
vec::raw::to_ptr(data) as *libc::c_void,
39+
data.as_ptr() as *libc::c_void,
4140
data.len() as libc::size_t);
4241
}
4342
}

src/librustuv/signal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl RtioSignal for SignalWatcher {}
6868
impl Drop for SignalWatcher {
6969
fn drop(&mut self) {
7070
let _m = self.fire_homing_missile();
71-
self.close_async_();
71+
self.close();
7272
}
7373
}
7474

src/librustuv/timer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ impl Drop for TimerWatcher {
169169
let _action = {
170170
let _m = self.fire_homing_missile();
171171
self.stop();
172-
self.close_async_();
172+
self.close();
173173
self.action.take()
174174
};
175175
}

src/librustuv/uvio.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ impl rtio::EventLoop for UvEventLoop {
8686
IdleWatcher::onetime(&mut self.uvio.loop_, f);
8787
}
8888

89-
fn pausible_idle_callback(&mut self, cb: ~rtio::Callback)
90-
-> ~rtio::PausibleIdleCallback
89+
fn pausable_idle_callback(&mut self, cb: ~rtio::Callback)
90+
-> ~rtio::PausableIdleCallback
9191
{
92-
IdleWatcher::new(&mut self.uvio.loop_, cb) as ~rtio::PausibleIdleCallback
92+
IdleWatcher::new(&mut self.uvio.loop_, cb) as ~rtio::PausableIdleCallback
9393
}
9494

9595
fn remote_callback(&mut self, f: ~rtio::Callback) -> ~rtio::RemoteCallback {

src/libstd/io/net/unix.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ mod tests {
175175
fn connect_error() {
176176
let mut called = false;
177177
io_error::cond.trap(|e| {
178-
assert_eq!(e.kind, OtherIoError);
178+
assert_eq!(e.kind,
179+
if cfg!(windows) {OtherIoError} else {FileNotFound});
179180
called = true;
180181
}).inside(|| {
181182
let stream = UnixStream::connect(&("path/to/nowhere"));

src/libstd/io/stdio.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ use libc;
3434
use option::{Option, Some, None};
3535
use result::{Ok, Err};
3636
use rt::rtio::{DontClose, IoFactory, LocalIo, RtioFileStream, RtioTTY};
37-
use vec;
3837

3938
// And so begins the tale of acquiring a uv handle to a stdio stream on all
4039
// platforms in all situations. Our story begins by splitting the world into two
@@ -137,7 +136,7 @@ fn with_task_stdout(f: |&mut Writer|) {
137136
fn write(&mut self, data: &[u8]) {
138137
unsafe {
139138
libc::write(libc::STDOUT_FILENO,
140-
vec::raw::to_ptr(data) as *libc::c_void,
139+
data.as_ptr() as *libc::c_void,
141140
data.len() as libc::size_t);
142141
}
143142
}

0 commit comments

Comments
 (0)