Skip to content

Commit a71d753

Browse files
committed
---
yaml --- r: 105110 b: refs/heads/snap-stage3 c: e30ab71 h: refs/heads/master v: v3
1 parent 8c0ae85 commit a71d753

Some content is hidden

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

64 files changed

+2269
-3103
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 62f1d68439dcfd509eaca29887afa97f22938373
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 1e6e98c0c2bd6b736fc6bef9bc1fb8e34d24e488
4+
refs/heads/snap-stage3: e30ab71e086746c6db7d49f5b0be5fc8cceda514
55
refs/heads/try: db814977d07bd798feb24f6b74c00800ef458a13
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/mk/dist.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ distcheck: dist
106106

107107
else
108108

109-
dist: $(PKG_TAR) $(PKG_OSX)
109+
dist: $(PKG_TAR)
110110

111111
distcheck: $(PKG_TAR)
112112
$(Q)rm -Rf dist

branches/snap-stage3/src/compiletest/compiletest.rs

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

1414
#[allow(non_camel_case_types)];
15+
#[allow(deprecated_owned_vector)]; // NOTE: remove after stage0
1516
#[deny(warnings)];
1617

1718
extern crate test;

branches/snap-stage3/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;
362+
let task_numbers = local_arc.get();
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;
414+
let task_numbers = local_arc.get();
415415
# }
416416
~~~
417417

branches/snap-stage3/src/driver/driver.rs

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

17+
#[cfg(not(stage0))]
1718
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/snap-stage3/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/mpsc_intrusive.rs", # BSD
44+
"libsync/sync/mpsc_intrusive.rs", # BSD
4545
]
4646

4747
def check_license(name, contents):

branches/snap-stage3/src/libgreen/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,16 @@ 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+
210220
/// Set up a default runtime configuration, given compiler-supplied arguments.
211221
///
212222
/// This function will block until the entire pool of M:N schedulers have

branches/snap-stage3/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 guard = (*me).lock.lock();
43+
let mut 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 guard = (*me).lock.lock();
63+
let mut guard = (*me).lock.lock();
6464
(*me).awoken = true;
6565
guard.signal();
6666
}

branches/snap-stage3/src/libnative/io/process.rs

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

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-
}
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);
499452

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

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);
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))
521469
}
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+
})
478+
}
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);
522517
}
518+
}
523519

524-
match config.gid {
525-
Some(u) => {
526-
if libc::setgid(u as libc::gid_t) != 0 {
527-
fail(&mut output);
528-
}
520+
match config.gid {
521+
Some(u) => {
522+
if libc::setgid(u as libc::gid_t) != 0 {
523+
fail(&mut output);
529524
}
530-
None => {}
531525
}
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);
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);
545541

546-
if libc::setuid(u as libc::uid_t) != 0 {
547-
fail(&mut output);
548-
}
542+
if libc::setuid(u as libc::uid_t) != 0 {
543+
fail(&mut output);
549544
}
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();
557545
}
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| {
558556
if !dirp.is_null() && chdir(dirp) == -1 {
559557
fail(&mut output);
560558
}
559+
});
560+
561+
with_envp(env, |envp| {
561562
if !envp.is_null() {
562563
set_environ(envp);
563564
}
564-
let _ = execvp(*argv, argv);
565-
fail(&mut output);
565+
with_argv(config.program, config.args, |argv| {
566+
let _ = execvp(*argv, argv);
567+
fail(&mut output);
568+
})
566569
})
567-
})
570+
}
568571
}
569572

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

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

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

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

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

branches/snap-stage3/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 guard = TIMER_HELPER_EXIT.lock();
78+
let mut guard = TIMER_HELPER_EXIT.lock();
7979
send(Shutdown);
8080
guard.wait();
8181
drop(guard);

branches/snap-stage3/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))]
72+
#[cfg(not(test), not(stage0))]
7373
pub fn lang_start(main: *u8, argc: int, argv: **u8) -> int {
7474
use std::cast;
7575
start(argc, argv, proc() {

branches/snap-stage3/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 guard = (*me).lock.lock();
193+
let mut 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 guard = (*me).lock.lock();
205+
let mut 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 guard = (*me).lock.lock();
235+
let mut guard = (*me).lock.lock();
236236
(*me).awoken = true;
237237
guard.signal();
238238
}

0 commit comments

Comments
 (0)