Skip to content

Commit 95c51a8

Browse files
committed
---
yaml --- r: 150271 b: refs/heads/try2 c: b1091c3 h: refs/heads/master i: 150269: c2c6a72 150267: badd866 150263: 8f3a7f0 150255: 02840b5 150239: 4e521bf 150207: 2fde5b9 150143: e529907 150015: 21fbe20 v: v3
1 parent 123b506 commit 95c51a8

Some content is hidden

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

63 files changed

+3102
-2268
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 39b48fb8836b130fa6bec09b4864b5a8eee0cd42
8+
refs/heads/try2: b1091c3141f2285fa9620c9e4df3fb86d911c5f6
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/compiletest/compiletest.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#[feature(phase)];
1313

1414
#[allow(non_camel_case_types)];
15-
#[allow(deprecated_owned_vector)]; // NOTE: remove after stage0
1615
#[deny(warnings)];
1716

1817
extern crate test;

branches/try2/src/doc/guide-tasks.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ fn main() {
359359
360360
spawn(proc() {
361361
let local_arc : Arc<~[f64]> = rx.recv();
362-
let task_numbers = local_arc.get();
362+
let task_numbers = &*local_arc;
363363
println!("{}-norm = {}", num, pnorm(task_numbers, num));
364364
});
365365
}
@@ -411,7 +411,7 @@ Each task recovers the underlying data by
411411
# let (tx, rx) = channel();
412412
# tx.send(numbers_arc.clone());
413413
# let local_arc : Arc<~[f64]> = rx.recv();
414-
let task_numbers = local_arc.get();
414+
let task_numbers = &*local_arc;
415415
# }
416416
~~~
417417

branches/try2/src/driver/driver.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,4 @@ extern crate this = "rustdoc";
1414
#[cfg(rustc)]
1515
extern crate this = "rustc";
1616

17-
#[cfg(not(stage0))]
1817
fn main() { this::main() }
19-
20-
#[cfg(stage0)]
21-
#[start]
22-
fn start(argc: int, argv: **u8) -> int { native::start(argc, argv, this::main) }

branches/try2/src/etc/licenseck.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"libstd/sync/mpsc_queue.rs", # BSD
4242
"libstd/sync/spsc_queue.rs", # BSD
4343
"libstd/sync/mpmc_bounded_queue.rs", # BSD
44-
"libsync/sync/mpsc_intrusive.rs", # BSD
44+
"libsync/mpsc_intrusive.rs", # BSD
4545
]
4646

4747
def check_license(name, contents):

branches/try2/src/libgreen/lib.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -207,16 +207,6 @@ pub mod sleeper_list;
207207
pub mod stack;
208208
pub mod task;
209209

210-
#[lang = "start"]
211-
#[cfg(not(test), stage0)]
212-
pub fn lang_start(main: *u8, argc: int, argv: **u8) -> int {
213-
use std::cast;
214-
start(argc, argv, proc() {
215-
let main: extern "Rust" fn() = unsafe { cast::transmute(main) };
216-
main();
217-
})
218-
}
219-
220210
/// Set up a default runtime configuration, given compiler-supplied arguments.
221211
///
222212
/// This function will block until the entire pool of M:N schedulers have

branches/try2/src/libgreen/simple.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl Runtime for SimpleTask {
4040
// See libnative/task.rs for what's going on here with the `awoken`
4141
// field and the while loop around wait()
4242
unsafe {
43-
let mut guard = (*me).lock.lock();
43+
let guard = (*me).lock.lock();
4444
(*me).awoken = false;
4545
match f(task) {
4646
Ok(()) => {
@@ -60,7 +60,7 @@ impl Runtime for SimpleTask {
6060
to_wake.put_runtime(self as ~Runtime);
6161
unsafe {
6262
cast::forget(to_wake);
63-
let mut guard = (*me).lock.lock();
63+
let guard = (*me).lock.lock();
6464
(*me).awoken = true;
6565
guard.signal();
6666
}

branches/try2/src/libnative/io/process.rs

Lines changed: 105 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -446,132 +446,129 @@ fn spawn_process_os(config: p::ProcessConfig,
446446
assert_eq!(ret, 0);
447447
}
448448

449-
let pipe = os::pipe();
450-
let mut input = file::FileDesc::new(pipe.input, true);
451-
let mut output = file::FileDesc::new(pipe.out, true);
449+
let dirp = dir.map(|p| p.to_c_str());
450+
let dirp = dirp.as_ref().map(|c| c.with_ref(|p| p)).unwrap_or(ptr::null());
451+
452+
with_envp(env, proc(envp) {
453+
with_argv(config.program, config.args, proc(argv) unsafe {
454+
let pipe = os::pipe();
455+
let mut input = file::FileDesc::new(pipe.input, true);
456+
let mut output = file::FileDesc::new(pipe.out, true);
457+
458+
set_cloexec(output.fd());
459+
460+
let pid = fork();
461+
if pid < 0 {
462+
fail!("failure in fork: {}", os::last_os_error());
463+
} else if pid > 0 {
464+
drop(output);
465+
let mut bytes = [0, ..4];
466+
return match input.inner_read(bytes) {
467+
Ok(4) => {
468+
let errno = (bytes[0] << 24) as i32 |
469+
(bytes[1] << 16) as i32 |
470+
(bytes[2] << 8) as i32 |
471+
(bytes[3] << 0) as i32;
472+
Err(super::translate_error(errno, false))
473+
}
474+
Err(e) => {
475+
assert!(e.kind == io::BrokenPipe ||
476+
e.kind == io::EndOfFile,
477+
"unexpected error: {}", e);
478+
Ok(SpawnProcessResult {
479+
pid: pid,
480+
handle: ptr::null()
481+
})
482+
}
483+
Ok(..) => fail!("short read on the cloexec pipe"),
484+
};
485+
}
486+
drop(input);
487+
488+
fn fail(output: &mut file::FileDesc) -> ! {
489+
let errno = os::errno();
490+
let bytes = [
491+
(errno << 24) as u8,
492+
(errno << 16) as u8,
493+
(errno << 8) as u8,
494+
(errno << 0) as u8,
495+
];
496+
assert!(output.inner_write(bytes).is_ok());
497+
unsafe { libc::_exit(1) }
498+
}
452499

453-
unsafe { set_cloexec(output.fd()) };
500+
rustrt::rust_unset_sigprocmask();
454501

455-
unsafe {
456-
let pid = fork();
457-
if pid < 0 {
458-
fail!("failure in fork: {}", os::last_os_error());
459-
} else if pid > 0 {
460-
drop(output);
461-
let mut bytes = [0, ..4];
462-
return match input.inner_read(bytes) {
463-
Ok(4) => {
464-
let errno = (bytes[0] << 24) as i32 |
465-
(bytes[1] << 16) as i32 |
466-
(bytes[2] << 8) as i32 |
467-
(bytes[3] << 0) as i32;
468-
Err(super::translate_error(errno, false))
469-
}
470-
Err(e) => {
471-
assert!(e.kind == io::BrokenPipe ||
472-
e.kind == io::EndOfFile,
473-
"unexpected error: {}", e);
474-
Ok(SpawnProcessResult {
475-
pid: pid,
476-
handle: ptr::null()
477-
})
502+
if in_fd == -1 {
503+
let _ = libc::close(libc::STDIN_FILENO);
504+
} else if retry(|| dup2(in_fd, 0)) == -1 {
505+
fail(&mut output);
506+
}
507+
if out_fd == -1 {
508+
let _ = libc::close(libc::STDOUT_FILENO);
509+
} else if retry(|| dup2(out_fd, 1)) == -1 {
510+
fail(&mut output);
511+
}
512+
if err_fd == -1 {
513+
let _ = libc::close(libc::STDERR_FILENO);
514+
} else if retry(|| dup2(err_fd, 2)) == -1 {
515+
fail(&mut output);
516+
}
517+
// close all other fds
518+
for fd in range(3, getdtablesize()).rev() {
519+
if fd != output.fd() {
520+
let _ = close(fd as c_int);
478521
}
479-
Ok(..) => fail!("short read on the cloexec pipe"),
480-
};
481-
}
482-
drop(input);
483-
484-
fn fail(output: &mut file::FileDesc) -> ! {
485-
let errno = os::errno();
486-
let bytes = [
487-
(errno << 24) as u8,
488-
(errno << 16) as u8,
489-
(errno << 8) as u8,
490-
(errno << 0) as u8,
491-
];
492-
assert!(output.inner_write(bytes).is_ok());
493-
unsafe { libc::_exit(1) }
494-
}
495-
496-
rustrt::rust_unset_sigprocmask();
497-
498-
if in_fd == -1 {
499-
let _ = libc::close(libc::STDIN_FILENO);
500-
} else if retry(|| dup2(in_fd, 0)) == -1 {
501-
fail(&mut output);
502-
}
503-
if out_fd == -1 {
504-
let _ = libc::close(libc::STDOUT_FILENO);
505-
} else if retry(|| dup2(out_fd, 1)) == -1 {
506-
fail(&mut output);
507-
}
508-
if err_fd == -1 {
509-
let _ = libc::close(libc::STDERR_FILENO);
510-
} else if retry(|| dup2(err_fd, 2)) == -1 {
511-
fail(&mut output);
512-
}
513-
// close all other fds
514-
for fd in range(3, getdtablesize()).rev() {
515-
if fd != output.fd() {
516-
let _ = close(fd as c_int);
517522
}
518-
}
519523

520-
match config.gid {
521-
Some(u) => {
522-
if libc::setgid(u as libc::gid_t) != 0 {
523-
fail(&mut output);
524+
match config.gid {
525+
Some(u) => {
526+
if libc::setgid(u as libc::gid_t) != 0 {
527+
fail(&mut output);
528+
}
524529
}
530+
None => {}
525531
}
526-
None => {}
527-
}
528-
match config.uid {
529-
Some(u) => {
530-
// When dropping privileges from root, the `setgroups` call will
531-
// remove any extraneous groups. If we don't call this, then
532-
// even though our uid has dropped, we may still have groups
533-
// that enable us to do super-user things. This will fail if we
534-
// aren't root, so don't bother checking the return value, this
535-
// is just done as an optimistic privilege dropping function.
536-
extern {
537-
fn setgroups(ngroups: libc::c_int,
538-
ptr: *libc::c_void) -> libc::c_int;
539-
}
540-
let _ = setgroups(0, 0 as *libc::c_void);
532+
match config.uid {
533+
Some(u) => {
534+
// When dropping privileges from root, the `setgroups` call will
535+
// remove any extraneous groups. If we don't call this, then
536+
// even though our uid has dropped, we may still have groups
537+
// that enable us to do super-user things. This will fail if we
538+
// aren't root, so don't bother checking the return value, this
539+
// is just done as an optimistic privilege dropping function.
540+
extern {
541+
fn setgroups(ngroups: libc::c_int,
542+
ptr: *libc::c_void) -> libc::c_int;
543+
}
544+
let _ = setgroups(0, 0 as *libc::c_void);
541545

542-
if libc::setuid(u as libc::uid_t) != 0 {
543-
fail(&mut output);
546+
if libc::setuid(u as libc::uid_t) != 0 {
547+
fail(&mut output);
548+
}
544549
}
550+
None => {}
551+
}
552+
if config.detach {
553+
// Don't check the error of setsid because it fails if we're the
554+
// process leader already. We just forked so it shouldn't return
555+
// error, but ignore it anyway.
556+
let _ = libc::setsid();
545557
}
546-
None => {}
547-
}
548-
if config.detach {
549-
// Don't check the error of setsid because it fails if we're the
550-
// process leader already. We just forked so it shouldn't return
551-
// error, but ignore it anyway.
552-
let _ = libc::setsid();
553-
}
554-
555-
with_dirp(dir, |dirp| {
556558
if !dirp.is_null() && chdir(dirp) == -1 {
557559
fail(&mut output);
558560
}
559-
});
560-
561-
with_envp(env, |envp| {
562561
if !envp.is_null() {
563562
set_environ(envp);
564563
}
565-
with_argv(config.program, config.args, |argv| {
566-
let _ = execvp(*argv, argv);
567-
fail(&mut output);
568-
})
564+
let _ = execvp(*argv, argv);
565+
fail(&mut output);
569566
})
570-
}
567+
})
571568
}
572569

573570
#[cfg(unix)]
574-
fn with_argv<T>(prog: &str, args: &[~str], cb: |**libc::c_char| -> T) -> T {
571+
fn with_argv<T>(prog: &str, args: &[~str], cb: proc:(**libc::c_char) -> T) -> T {
575572
use std::slice;
576573

577574
// We can't directly convert `str`s into `*char`s, as someone needs to hold
@@ -597,7 +594,7 @@ fn with_argv<T>(prog: &str, args: &[~str], cb: |**libc::c_char| -> T) -> T {
597594
}
598595

599596
#[cfg(unix)]
600-
fn with_envp<T>(env: Option<~[(~str, ~str)]>, cb: |*c_void| -> T) -> T {
597+
fn with_envp<T>(env: Option<~[(~str, ~str)]>, cb: proc:(*c_void) -> T) -> T {
601598
use std::slice;
602599

603600
// On posixy systems we can pass a char** for envp, which is a
@@ -645,6 +642,7 @@ fn with_envp<T>(env: Option<~[(~str, ~str)]>, cb: |*mut c_void| -> T) -> T {
645642
}
646643
}
647644

645+
#[cfg(windows)]
648646
fn with_dirp<T>(d: Option<&Path>, cb: |*libc::c_char| -> T) -> T {
649647
match d {
650648
Some(dir) => dir.with_c_str(|buf| cb(buf)),

branches/try2/src/libnative/io/timer_helper.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub fn send(req: Req) {
7575
fn shutdown() {
7676
// Request a shutdown, and then wait for the task to exit
7777
unsafe {
78-
let mut guard = TIMER_HELPER_EXIT.lock();
78+
let guard = TIMER_HELPER_EXIT.lock();
7979
send(Shutdown);
8080
guard.wait();
8181
drop(guard);

branches/try2/src/libnative/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static OS_DEFAULT_STACK_ESTIMATE: uint = 1 << 20;
6969
static OS_DEFAULT_STACK_ESTIMATE: uint = 2 * (1 << 20);
7070

7171
#[lang = "start"]
72-
#[cfg(not(test), not(stage0))]
72+
#[cfg(not(test))]
7373
pub fn lang_start(main: *u8, argc: int, argv: **u8) -> int {
7474
use std::cast;
7575
start(argc, argv, proc() {

branches/try2/src/libnative/task.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ impl rt::Runtime for Ops {
190190
let task = BlockedTask::block(cur_task);
191191

192192
if times == 1 {
193-
let mut guard = (*me).lock.lock();
193+
let guard = (*me).lock.lock();
194194
(*me).awoken = false;
195195
match f(task) {
196196
Ok(()) => {
@@ -202,7 +202,7 @@ impl rt::Runtime for Ops {
202202
}
203203
} else {
204204
let mut iter = task.make_selectable(times);
205-
let mut guard = (*me).lock.lock();
205+
let guard = (*me).lock.lock();
206206
(*me).awoken = false;
207207
let success = iter.all(|task| {
208208
match f(task) {
@@ -232,7 +232,7 @@ impl rt::Runtime for Ops {
232232
let me = &mut *self as *mut Ops;
233233
to_wake.put_runtime(self as ~rt::Runtime);
234234
cast::forget(to_wake);
235-
let mut guard = (*me).lock.lock();
235+
let guard = (*me).lock.lock();
236236
(*me).awoken = true;
237237
guard.signal();
238238
}

branches/try2/src/librand/reader.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,8 @@ impl<R: Reader> Rng for ReaderRng<R> {
6060
}
6161
fn fill_bytes(&mut self, v: &mut [u8]) {
6262
if v.len() == 0 { return }
63-
match self.reader.read(v) {
64-
Ok(n) if n == v.len() => return,
65-
Ok(n) => fail!("ReaderRng.fill_bytes could not fill buffer: \
66-
read {} out of {} bytes.", n, v.len()),
63+
match self.reader.fill(v) {
64+
Ok(()) => {}
6765
Err(e) => fail!("ReaderRng.fill_bytes error: {}", e)
6866
}
6967
}

0 commit comments

Comments
 (0)