Skip to content

Commit 8496cea

Browse files
committed
---
yaml --- r: 88854 b: refs/heads/snap-stage3 c: 282f3d9 h: refs/heads/master v: v3
1 parent b02cbd8 commit 8496cea

File tree

19 files changed

+135
-108
lines changed

19 files changed

+135
-108
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: deeca5d586bfaa4aa60246f671a8d611d38f6248
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 39dbcd7b012da733f378b0fadf1e7d2519dc0d0c
4+
refs/heads/snap-stage3: 282f3d99a5ad85acbc58c03b5dfcdabf649c0c85
55
refs/heads/try: b160761e35efcd1207112b3b782c06633cf441a8
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/Makefile.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,15 @@ define CHECK_FOR_OLD_GLOB_MATCHES_EXCEPT
280280
endef
281281

282282
# Same interface as above, but deletes rather than just listing the files.
283+
ifdef VERBOSE
283284
define REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT
284285
$(Q)MATCHES="$(filter-out %$(3),$(wildcard $(1)/$(2)))"; if [ -n "$$MATCHES" ] ; then echo "warning: removing previous" \'$(2)\' "libraries:" $$MATCHES; rm $$MATCHES ; fi
285286
endef
287+
else
288+
define REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT
289+
$(Q)MATCHES="$(filter-out %$(3),$(wildcard $(1)/$(2)))"; if [ -n "$$MATCHES" ] ; then rm $$MATCHES ; fi
290+
endef
291+
endif
286292

287293
# We use a different strategy for LIST_ALL_OLD_GLOB_MATCHES_EXCEPT
288294
# than in the macros above because it needs the result of running the

branches/snap-stage3/mk/target.mk

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,16 +161,13 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(3)): \
161161
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTC_GLOB_$(2)),$$(notdir $$@))
162162
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTC_RGLOB_$(2)),$$(notdir $$@))
163163

164-
# NOTE: after the next snapshot remove these '-L' flags
165164
$$(TBIN$(1)_T_$(2)_H_$(3))/rustc$$(X_$(3)): \
166165
$$(DRIVER_CRATE) \
167-
$$(TSREQ$(1)_T_$(2)_H_$(3)) \
166+
$$(SREQ$(1)_T_$(2)_H_$(3)) \
168167
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(3)) \
169168
| $$(TBIN$(1)_T_$(2)_H_$(3))/
170169
@$$(call E, compile_and_link: $$@)
171-
$$(STAGE$(1)_T_$(2)_H_$(3)) --cfg rustc -o $$@ $$< \
172-
-L $$(UV_SUPPORT_DIR_$(2)) \
173-
-L $$(dir $$(LIBUV_LIB_$(2)))
170+
$$(STAGE$(1)_T_$(2)_H_$(3)) --cfg rustc -o $$@ $$<
174171
ifdef CFG_ENABLE_PAX_FLAGS
175172
@$$(call E, apply PaX flags: $$@)
176173
@"$(CFG_PAXCTL)" -cm "$$@"

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
extern mod extra;
1717

1818
use std::os;
19-
use std::rt;
19+
use std::io;
2020
use std::io::fs;
2121

2222
use extra::getopts;
@@ -234,7 +234,7 @@ pub fn run_tests(config: &config) {
234234
// sadly osx needs some file descriptor limits raised for running tests in
235235
// parallel (especially when we have lots and lots of child processes).
236236
// For context, see #8904
237-
rt::test::prepare_for_lots_of_tests();
237+
io::test::raise_fd_limit();
238238
let res = test::run_tests_console(&opts, tests);
239239
if !res { fail!("Some tests failed"); }
240240
}

branches/snap-stage3/src/etc/licenseck.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@
7676
"rt/isaac/randport.cpp", # public domain
7777
"rt/isaac/rand.h", # public domain
7878
"rt/isaac/standard.h", # public domain
79-
"libstd/rt/mpsc_queue.rs", # BSD
80-
"libstd/rt/spsc_queue.rs", # BSD
81-
"libstd/rt/mpmc_bounded_queue.rs", # BSD
79+
"libstd/sync/mpsc_queue.rs", # BSD
80+
"libstd/sync/spsc_queue.rs", # BSD
81+
"libstd/sync/mpmc_bounded_queue.rs", # BSD
8282
]
8383

8484
def check_license(name, contents):

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

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
//! This can be optionally linked in to rust programs in order to provide M:N
1818
//! functionality inside of 1:1 programs.
1919
20+
#[pkgid = "green#0.9-pre"];
2021
#[link(name = "green",
2122
package_id = "green",
2223
vers = "0.9-pre",
@@ -30,17 +31,16 @@
3031
// NB this does *not* include globs, please keep it that way.
3132
#[feature(macro_rules)];
3233

33-
use std::cast;
3434
use std::os;
35-
use std::rt::thread::Thread;
36-
use std::rt;
3735
use std::rt::crate_map;
3836
use std::rt::rtio;
39-
use std::sync::deque;
37+
use std::rt::thread::Thread;
38+
use std::rt;
4039
use std::sync::atomics::{SeqCst, AtomicUint, INIT_ATOMIC_UINT};
40+
use std::sync::deque;
4141
use std::task::TaskOpts;
42-
use std::vec;
4342
use std::util;
43+
use std::vec;
4444
use stdtask = std::rt::task;
4545

4646
use sched::{Shutdown, Scheduler, SchedHandle, TaskFromFriend, NewNeighbor};
@@ -58,9 +58,9 @@ pub mod sleeper_list;
5858
pub mod stack;
5959
pub mod task;
6060

61-
#[cfg(stage0)]
6261
#[lang = "start"]
6362
pub fn lang_start(main: *u8, argc: int, argv: **u8) -> int {
63+
use std::cast;
6464
do start(argc, argv) {
6565
let main: extern "Rust" fn() = unsafe { cast::transmute(main) };
6666
main();
@@ -103,7 +103,15 @@ pub fn start(argc: int, argv: **u8, main: proc()) -> int {
103103
/// have returned.
104104
pub fn run(main: proc()) -> int {
105105
let mut pool = SchedPool::new(PoolConfig::new());
106-
pool.spawn(TaskOpts::new(), main);
106+
let (port, chan) = Chan::new();
107+
let mut opts = TaskOpts::new();
108+
opts.notify_chan = Some(chan);
109+
pool.spawn(opts, main);
110+
do pool.spawn(TaskOpts::new()) {
111+
if port.recv().is_err() {
112+
os::set_exit_status(rt::DEFAULT_ERROR_CODE);
113+
}
114+
}
107115
unsafe { stdtask::wait_for_completion(); }
108116
pool.shutdown();
109117
os::get_exit_status()

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
//! runtime. In addition, all I/O provided by this crate is the thread blocking
1515
//! version of I/O.
1616
17+
#[pkgid = "native#0.9-pre"];
1718
#[link(name = "native",
1819
package_id = "native",
1920
vers = "0.9-pre",
@@ -24,6 +25,7 @@
2425
#[crate_type = "rlib"];
2526
#[crate_type = "dylib"];
2627

28+
// Allow check-stage0-native for now
2729
#[cfg(stage0, test)] extern mod green;
2830

2931
// NB this crate explicitly does *not* allow glob imports, please seriously

branches/snap-stage3/src/librustuv/homing.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
//! This enqueueing is done with a concurrent queue from libstd, and the
3232
//! signalling is achieved with an async handle.
3333
34+
#[allow(dead_code)];
35+
3436
use std::rt::local::Local;
3537
use std::rt::rtio::LocalIo;
3638
use std::rt::task::{Task, BlockedTask};

branches/snap-stage3/src/librustuv/queue.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
//! event loop alive we use uv_ref and uv_unref in order to control when the
1919
//! async handle is active or not.
2020
21+
#[allow(dead_code)];
22+
2123
use std::cast;
2224
use std::libc::{c_void, c_int};
2325
use std::rt::task::BlockedTask;

branches/snap-stage3/src/libstd/io/test.rs

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,82 @@ fn base_port() -> u16 {
113113

114114
return final_base;
115115
}
116+
117+
pub fn raise_fd_limit() {
118+
unsafe { darwin_fd_limit::raise_fd_limit() }
119+
}
120+
121+
#[cfg(target_os="macos")]
122+
#[allow(non_camel_case_types)]
123+
mod darwin_fd_limit {
124+
/*!
125+
* darwin_fd_limit exists to work around an issue where launchctl on Mac OS X defaults the
126+
* rlimit maxfiles to 256/unlimited. The default soft limit of 256 ends up being far too low
127+
* for our multithreaded scheduler testing, depending on the number of cores available.
128+
*
129+
* This fixes issue #7772.
130+
*/
131+
132+
use libc;
133+
type rlim_t = libc::uint64_t;
134+
struct rlimit {
135+
rlim_cur: rlim_t,
136+
rlim_max: rlim_t
137+
}
138+
#[nolink]
139+
extern {
140+
// name probably doesn't need to be mut, but the C function doesn't specify const
141+
fn sysctl(name: *mut libc::c_int, namelen: libc::c_uint,
142+
oldp: *mut libc::c_void, oldlenp: *mut libc::size_t,
143+
newp: *mut libc::c_void, newlen: libc::size_t) -> libc::c_int;
144+
fn getrlimit(resource: libc::c_int, rlp: *mut rlimit) -> libc::c_int;
145+
fn setrlimit(resource: libc::c_int, rlp: *rlimit) -> libc::c_int;
146+
}
147+
static CTL_KERN: libc::c_int = 1;
148+
static KERN_MAXFILESPERPROC: libc::c_int = 29;
149+
static RLIMIT_NOFILE: libc::c_int = 8;
150+
151+
pub unsafe fn raise_fd_limit() {
152+
// The strategy here is to fetch the current resource limits, read the kern.maxfilesperproc
153+
// sysctl value, and bump the soft resource limit for maxfiles up to the sysctl value.
154+
use ptr::{to_unsafe_ptr, to_mut_unsafe_ptr, mut_null};
155+
use mem::size_of_val;
156+
use os::last_os_error;
157+
158+
// Fetch the kern.maxfilesperproc value
159+
let mut mib: [libc::c_int, ..2] = [CTL_KERN, KERN_MAXFILESPERPROC];
160+
let mut maxfiles: libc::c_int = 0;
161+
let mut size: libc::size_t = size_of_val(&maxfiles) as libc::size_t;
162+
if sysctl(to_mut_unsafe_ptr(&mut mib[0]), 2,
163+
to_mut_unsafe_ptr(&mut maxfiles) as *mut libc::c_void,
164+
to_mut_unsafe_ptr(&mut size),
165+
mut_null(), 0) != 0 {
166+
let err = last_os_error();
167+
error!("raise_fd_limit: error calling sysctl: {}", err);
168+
return;
169+
}
170+
171+
// Fetch the current resource limits
172+
let mut rlim = rlimit{rlim_cur: 0, rlim_max: 0};
173+
if getrlimit(RLIMIT_NOFILE, to_mut_unsafe_ptr(&mut rlim)) != 0 {
174+
let err = last_os_error();
175+
error!("raise_fd_limit: error calling getrlimit: {}", err);
176+
return;
177+
}
178+
179+
// Bump the soft limit to the smaller of kern.maxfilesperproc and the hard limit
180+
rlim.rlim_cur = ::cmp::min(maxfiles as rlim_t, rlim.rlim_max);
181+
182+
// Set our newly-increased resource limit
183+
if setrlimit(RLIMIT_NOFILE, to_unsafe_ptr(&rlim)) != 0 {
184+
let err = last_os_error();
185+
error!("raise_fd_limit: error calling setrlimit: {}", err);
186+
return;
187+
}
188+
}
189+
}
190+
191+
#[cfg(not(target_os="macos"))]
192+
mod darwin_fd_limit {
193+
pub unsafe fn raise_fd_limit() {}
194+
}

branches/snap-stage3/src/libstd/rt/task.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,13 @@ use task::{TaskResult, TaskOpts};
3838
use unstable::finally::Finally;
3939
use unstable::mutex::{Mutex, MUTEX_INIT};
4040

41-
#[cfg(stage0)] pub use rt::unwind::begin_unwind;
41+
#[cfg(stage0)]
42+
pub use rt::unwind::begin_unwind;
4243

44+
// These two statics are used as bookeeping to keep track of the rust runtime's
45+
// count of threads. In 1:1 contexts, this is used to know when to return from
46+
// the main function, and in M:N contexts this is used to know when to shut down
47+
// the pool of schedulers.
4348
static mut TASK_COUNT: AtomicUint = INIT_ATOMIC_UINT;
4449
static mut TASK_LOCK: Mutex = MUTEX_INIT;
4550

@@ -181,10 +186,15 @@ impl Task {
181186
// Cleanup the dynamic borrowck debugging info
182187
borrowck::clear_task_borrow_list();
183188

184-
// TODO: dox
189+
// Here we must unsafely borrow the task in order to not remove it from
190+
// TLS. When collecting failure, we may attempt to send on a channel (or
191+
// just run aribitrary code), so we must be sure to still have a local
192+
// task in TLS.
185193
unsafe {
186194
let me: *mut Task = Local::unsafe_borrow();
187195
(*me).death.collect_failure((*me).unwinder.result());
196+
197+
// see comments on these statics for why they're used
188198
if TASK_COUNT.fetch_sub(1, SeqCst) == 1 {
189199
TASK_LOCK.lock();
190200
TASK_LOCK.signal();
@@ -386,6 +396,10 @@ impl Drop for Death {
386396
}
387397
}
388398

399+
/// The main function of all rust executables will by default use this function.
400+
/// This function will *block* the OS thread (hence the `unsafe`) waiting for
401+
/// all known tasks to complete. Once this function has returned, it is
402+
/// guaranteed that no more user-defined code is still running.
389403
pub unsafe fn wait_for_completion() {
390404
TASK_LOCK.lock();
391405
while TASK_COUNT.load(SeqCst) > 0 {

branches/snap-stage3/src/libstd/sync/arc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use vec;
3232
/// An atomically reference counted pointer.
3333
///
3434
/// Enforces no shared-memory safety.
35-
#[unsafe_no_drop_flag]
35+
//#[unsafe_no_drop_flag] FIXME: #9758
3636
pub struct UnsafeArc<T> {
3737
priv data: *mut ArcData<T>,
3838
}

branches/snap-stage3/src/libsyntax/ext/build.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,6 @@ impl AstBuilder for @ExtCtxt {
606606
~[
607607
self.ident_of("std"),
608608
self.ident_of("rt"),
609-
self.ident_of("task"),
610609
self.ident_of("begin_unwind"),
611610
],
612611
~[

branches/snap-stage3/src/test/run-pass/core-rt-smoke.rs

Lines changed: 0 additions & 20 deletions
This file was deleted.

branches/snap-stage3/src/test/run-pass/native-print-no-uv.rs

Lines changed: 0 additions & 17 deletions
This file was deleted.

branches/snap-stage3/src/test/run-pass/rt-run-twice.rs

Lines changed: 0 additions & 26 deletions
This file was deleted.

branches/snap-stage3/src/test/run-pass/rt-start-main-thread.rs

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)