Skip to content

Commit d3d2c2d

Browse files
committed
---
yaml --- r: 102393 b: refs/heads/master c: 0a7b06e h: refs/heads/master i: 102391: d71ff35 v: v3
1 parent bb229f0 commit d3d2c2d

34 files changed

+457
-159
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 37b3a60b78be10f01aa57d2096d96f5ab9f07656
2+
refs/heads/master: 0a7b06e955cd3f1c520ec3c2a34a2464f08a46f6
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 6e7f170fedd3c526a643c0b2d13863acd982be02
55
refs/heads/try: a97642026c18a624ff6ea01075dd9550f8ed07ff

trunk/src/libgetopts/lib.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,25 @@ pub fn optmulti(short_name: &str, long_name: &str, desc: &str, hint: &str) -> Op
455455
}
456456
}
457457

458+
/// Create a generic option group, stating all parameters explicitly
459+
pub fn opt(short_name: &str,
460+
long_name: &str,
461+
desc: &str,
462+
hint: &str,
463+
hasarg: HasArg,
464+
occur: Occur) -> OptGroup {
465+
let len = short_name.len();
466+
assert!(len == 1 || len == 0);
467+
OptGroup {
468+
short_name: short_name.to_owned(),
469+
long_name: long_name.to_owned(),
470+
hint: hint.to_owned(),
471+
desc: desc.to_owned(),
472+
hasarg: hasarg,
473+
occur: occur
474+
}
475+
}
476+
458477
impl Fail_ {
459478
/// Convert a `Fail_` enum into an error string.
460479
pub fn to_err_msg(self) -> ~str {

trunk/src/libnative/io/file_unix.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use std::libc;
1919
use std::mem;
2020
use std::rt::rtio;
2121
use std::vec;
22+
use std::vec_ng::Vec;
2223

2324
use io::{IoResult, retry, keep_going};
2425

@@ -341,7 +342,7 @@ pub fn mkdir(p: &CString, mode: io::FilePermission) -> IoResult<()> {
341342

342343
pub fn readdir(p: &CString) -> IoResult<~[Path]> {
343344
use std::libc::{dirent_t};
344-
use std::libc::{opendir, readdir, closedir};
345+
use std::libc::{opendir, readdir_r, closedir};
345346

346347
fn prune(root: &CString, dirs: ~[Path]) -> ~[Path] {
347348
let root = unsafe { CString::new(root.with_ref(|p| p), false) };
@@ -353,23 +354,28 @@ pub fn readdir(p: &CString) -> IoResult<~[Path]> {
353354
}
354355

355356
extern {
356-
fn rust_list_dir_val(ptr: *dirent_t) -> *libc::c_char;
357+
fn rust_dirent_t_size() -> libc::c_int;
358+
fn rust_list_dir_val(ptr: *mut dirent_t) -> *libc::c_char;
357359
}
358360

361+
let size = unsafe { rust_dirent_t_size() };
362+
let mut buf = Vec::<u8>::with_capacity(size as uint);
363+
let ptr = buf.as_mut_slice().as_mut_ptr() as *mut dirent_t;
364+
359365
debug!("os::list_dir -- BEFORE OPENDIR");
360366

361367
let dir_ptr = p.with_ref(|buf| unsafe { opendir(buf) });
362368

363369
if dir_ptr as uint != 0 {
364370
let mut paths = ~[];
365371
debug!("os::list_dir -- opendir() SUCCESS");
366-
let mut entry_ptr = unsafe { readdir(dir_ptr) };
367-
while entry_ptr as uint != 0 {
372+
let mut entry_ptr = 0 as *mut dirent_t;
373+
while unsafe { readdir_r(dir_ptr, ptr, &mut entry_ptr) == 0 } {
374+
if entry_ptr.is_null() { break }
368375
let cstr = unsafe {
369376
CString::new(rust_list_dir_val(entry_ptr), false)
370377
};
371378
paths.push(Path::new(cstr));
372-
entry_ptr = unsafe { readdir(dir_ptr) };
373379
}
374380
assert_eq!(unsafe { closedir(dir_ptr) }, 0);
375381
Ok(prune(p, paths))

trunk/src/libnative/io/timer_helper.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
//! time.
2222
2323
use std::cast;
24+
use std::rt::bookkeeping;
2425
use std::rt;
2526
use std::unstable::mutex::{StaticNativeMutex, NATIVE_MUTEX_INIT};
2627

27-
use bookkeeping;
2828
use io::timer::{Req, Shutdown};
2929
use task;
3030

@@ -36,6 +36,8 @@ use task;
3636
static mut HELPER_CHAN: *mut Chan<Req> = 0 as *mut Chan<Req>;
3737
static mut HELPER_SIGNAL: imp::signal = 0 as imp::signal;
3838

39+
static mut TIMER_HELPER_EXIT: StaticNativeMutex = NATIVE_MUTEX_INIT;
40+
3941
pub fn boot(helper: fn(imp::signal, Port<Req>)) {
4042
static mut LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
4143
static mut INITIALIZED: bool = false;
@@ -53,6 +55,7 @@ pub fn boot(helper: fn(imp::signal, Port<Req>)) {
5355
task::spawn(proc() {
5456
bookkeeping::decrement();
5557
helper(receive, msgp);
58+
TIMER_HELPER_EXIT.lock().signal()
5659
});
5760

5861
rt::at_exit(proc() { shutdown() });
@@ -70,17 +73,15 @@ pub fn send(req: Req) {
7073
}
7174

7275
fn shutdown() {
73-
// We want to wait for the entire helper task to exit, and in doing so it
74-
// will attempt to decrement the global task count. When the helper was
75-
// created, it decremented the count so it wouldn't count towards preventing
76-
// the program to exit, so here we pair that manual decrement with a manual
77-
// increment. We will then wait for the helper thread to exit by calling
78-
// wait_for_other_tasks.
79-
bookkeeping::increment();
80-
8176
// Request a shutdown, and then wait for the task to exit
82-
send(Shutdown);
83-
bookkeeping::wait_for_other_tasks();
77+
unsafe {
78+
let mut guard = TIMER_HELPER_EXIT.lock();
79+
send(Shutdown);
80+
guard.wait();
81+
drop(guard);
82+
TIMER_HELPER_EXIT.destroy();
83+
}
84+
8485

8586
// Clean up after ther helper thread
8687
unsafe {

trunk/src/libnative/io/timer_other.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,15 @@ impl Timer {
218218
}
219219

220220
pub fn sleep(ms: u64) {
221-
// FIXME: this can fail because of EINTR, what do do?
222-
let _ = unsafe { libc::usleep((ms * 1000) as libc::c_uint) };
221+
let mut to_sleep = libc::timespec {
222+
tv_sec: (ms / 1000) as libc::time_t,
223+
tv_nsec: ((ms % 1000) * 1000000) as libc::c_long,
224+
};
225+
while unsafe { libc::nanosleep(&to_sleep, &mut to_sleep) } != 0 {
226+
if os::errno() as int != libc::EINTR as int {
227+
fail!("failed to sleep, but not because of EINTR?");
228+
}
229+
}
223230
}
224231

225232
fn inner(&mut self) -> ~Inner {

trunk/src/libnative/io/timer_timerfd.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
//! why).
2424
//!
2525
//! As with timer_other, timers just using sleep() do not use the timerfd at
26-
//! all. They remove the timerfd from the worker thread and then invoke usleep()
27-
//! to block the calling thread.
26+
//! all. They remove the timerfd from the worker thread and then invoke
27+
//! nanosleep() to block the calling thread.
2828
//!
2929
//! As with timer_other, all units in this file are in units of millseconds.
3030
@@ -183,8 +183,15 @@ impl Timer {
183183
}
184184

185185
pub fn sleep(ms: u64) {
186-
// FIXME: this can fail because of EINTR, what do do?
187-
let _ = unsafe { libc::usleep((ms * 1000) as libc::c_uint) };
186+
let mut to_sleep = libc::timespec {
187+
tv_sec: (ms / 1000) as libc::time_t,
188+
tv_nsec: ((ms % 1000) * 1000000) as libc::c_long,
189+
};
190+
while unsafe { libc::nanosleep(&to_sleep, &mut to_sleep) } != 0 {
191+
if os::errno() as int != libc::EINTR as int {
192+
fail!("failed to sleep, but not because of EINTR?");
193+
}
194+
}
188195
}
189196

190197
fn remove(&mut self) {

trunk/src/libnative/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
use std::os;
5959
use std::rt;
6060

61-
mod bookkeeping;
6261
pub mod io;
6362
pub mod task;
6463

@@ -105,6 +104,5 @@ pub fn start(argc: int, argv: **u8, main: proc()) -> int {
105104
/// number of arguments.
106105
pub fn run(main: proc()) -> int {
107106
main();
108-
bookkeeping::wait_for_other_tasks();
109107
os::get_exit_status()
110108
}

trunk/src/libnative/task.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@
1616
1717
use std::any::Any;
1818
use std::cast;
19+
use std::rt::bookkeeping;
1920
use std::rt::env;
2021
use std::rt::local::Local;
2122
use std::rt::rtio;
23+
use std::rt::stack;
2224
use std::rt::task::{Task, BlockedTask, SendMessage};
2325
use std::rt::thread::Thread;
2426
use std::rt;
2527
use std::task::TaskOpts;
2628
use std::unstable::mutex::NativeMutex;
27-
use std::rt::stack;
2829

2930
use io;
3031
use task;
31-
use bookkeeping;
3232

3333
/// Creates a new Task which is ready to execute as a 1:1 task.
3434
pub fn new(stack_bounds: (uint, uint)) -> ~Task {

trunk/src/librustc/back/link.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use back::archive::{Archive, METADATA_FILENAME};
1212
use back::rpath;
1313
use back::svh::Svh;
1414
use driver::driver::{CrateTranslation, OutputFilenames};
15-
use driver::session::Session;
15+
use driver::session::{NoDebugInfo, Session};
1616
use driver::session;
1717
use lib::llvm::llvm;
1818
use lib::llvm::ModuleRef;
@@ -92,7 +92,7 @@ pub mod write {
9292
use back::link::{OutputTypeExe, OutputTypeLlvmAssembly};
9393
use back::link::{OutputTypeObject};
9494
use driver::driver::{CrateTranslation, OutputFilenames};
95-
use driver::session::Session;
95+
use driver::session::{NoDebugInfo, Session};
9696
use driver::session;
9797
use lib::llvm::llvm;
9898
use lib::llvm::{ModuleRef, TargetMachineRef, PassManagerRef};
@@ -148,7 +148,7 @@ pub mod write {
148148

149149
// FIXME: #11906: Omitting frame pointers breaks retrieving the value of a parameter.
150150
// FIXME: #11954: mac64 unwinding may not work with fp elim
151-
let no_fp_elim = sess.opts.debuginfo ||
151+
let no_fp_elim = (sess.opts.debuginfo != NoDebugInfo) ||
152152
(sess.targ_cfg.os == abi::OsMacos &&
153153
sess.targ_cfg.arch == abi::X86_64);
154154

@@ -1052,7 +1052,7 @@ fn link_natively(sess: Session, dylib: bool, obj_filename: &Path,
10521052

10531053
// On OSX, debuggers need this utility to get run to do some munging of
10541054
// the symbols
1055-
if sess.targ_cfg.os == abi::OsMacos && sess.opts.debuginfo {
1055+
if sess.targ_cfg.os == abi::OsMacos && (sess.opts.debuginfo != NoDebugInfo) {
10561056
// FIXME (#9639): This needs to handle non-utf8 paths
10571057
match Process::status("dsymutil",
10581058
[out_filename.as_str().unwrap().to_owned()]) {

trunk/src/librustc/driver/driver.rs

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111

1212
use back::link;
1313
use back::{arm, x86, x86_64, mips};
14-
use driver::session::{Aggressive, CrateTypeExecutable};
14+
use driver::session::{Aggressive, CrateTypeExecutable, FullDebugInfo, LimitedDebugInfo,
15+
NoDebugInfo};
1516
use driver::session::{Session, Session_, No, Less, Default};
1617
use driver::session;
1718
use front;
@@ -38,7 +39,9 @@ use std::vec;
3839
use std::vec_ng::Vec;
3940
use std::vec_ng;
4041
use collections::{HashMap, HashSet};
41-
use getopts::{optopt, optmulti, optflag, optflagopt};
42+
use getopts::{optopt, optmulti, optflag, optflagopt, opt};
43+
use MaybeHasArg = getopts::Maybe;
44+
use OccurOptional = getopts::Optional;
4245
use getopts;
4346
use syntax::ast;
4447
use syntax::abi;
@@ -865,7 +868,18 @@ pub fn build_session_options(matches: &getopts::Matches)
865868
} else { No }
866869
};
867870
let gc = debugging_opts & session::GC != 0;
868-
let debuginfo = matches.opt_present("g") || matches.opt_present("debuginfo");
871+
872+
let debuginfo = match matches.opt_default("debuginfo", "2") {
873+
Some(level) => {
874+
match level {
875+
~"0" => NoDebugInfo,
876+
~"1" => LimitedDebugInfo,
877+
~"2" => FullDebugInfo,
878+
_ => early_error("debug info level needs to be between 0-2")
879+
}
880+
}
881+
None => NoDebugInfo
882+
};
869883

870884
let addl_lib_search_paths = matches.opt_strs("L").map(|s| {
871885
Path::new(s.as_slice())
@@ -1012,61 +1026,47 @@ pub fn optgroups() -> ~[getopts::OptGroup] {
10121026
optflag("h", "help", "Display this message"),
10131027
optmulti("", "cfg", "Configure the compilation environment", "SPEC"),
10141028
optmulti("L", "", "Add a directory to the library search path", "PATH"),
1015-
optmulti("", "crate-type", "Comma separated list of types of crates for the \
1016-
compiler to emit",
1029+
optmulti("", "crate-type", "Comma separated list of types of crates for the compiler to emit",
10171030
"[bin|lib|rlib|dylib|staticlib]"),
1018-
optmulti("", "emit", "Comma separated list of types of output for the compiler
1019-
to emit",
1031+
optmulti("", "emit", "Comma separated list of types of output for the compiler to emit",
10201032
"[asm|bc|ir|obj|link]"),
10211033
optflag("", "crate-id", "Output the crate id and exit"),
10221034
optflag("", "crate-name", "Output the crate name and exit"),
10231035
optflag("", "crate-file-name", "Output the file(s) that would be written if compilation \
10241036
continued and exit"),
10251037
optflag("", "ls", "List the symbols defined by a library crate"),
1026-
optflag("g", "debuginfo", "Emit DWARF debug info to the objects created"),
1027-
optflag("", "no-trans",
1028-
"Run all passes except translation; no output"),
1029-
optflag("", "no-analysis",
1030-
"Parse and expand the output, but run no analysis or produce \
1031-
output"),
1032-
optflag("O", "", "Equivalent to --opt-level=2"),
1033-
optopt("o", "", "Write output to <filename>", "FILENAME"),
1034-
optopt("", "opt-level",
1035-
"Optimize with possible levels 0-3", "LEVEL"),
1036-
optopt( "", "out-dir",
1037-
"Write output to compiler-chosen filename
1038-
in <dir>", "DIR"),
1039-
optflag("", "parse-only",
1040-
"Parse only; do not compile, assemble, or link"),
1038+
opt("g", "debuginfo", "Emit DWARF debug info to the objects created:
1039+
0 = no debug info,
1040+
1 = line-tables only (for stacktraces),
1041+
2 = full debug info with variable, argument and type information",
1042+
"LEVEL", MaybeHasArg, OccurOptional),
1043+
optflag("", "no-trans", "Run all passes except translation; no output"),
1044+
optflag("", "no-analysis", "Parse and expand the output, but run no analysis or produce output"),
1045+
optflag("O", "", "Equivalent to --opt-level=2"),
1046+
optopt("o", "", "Write output to <filename>", "FILENAME"),
1047+
optopt("", "opt-level", "Optimize with possible levels 0-3", "LEVEL"),
1048+
optopt( "", "out-dir", "Write output to compiler-chosen filename in <dir>", "DIR"),
1049+
optflag("", "parse-only", "Parse only; do not compile, assemble, or link"),
10411050
optflagopt("", "pretty",
1042-
"Pretty-print the input instead of compiling;
1043-
valid types are: normal (un-annotated source),
1044-
expanded (crates expanded),
1045-
typed (crates expanded, with type annotations),
1046-
or identified (fully parenthesized,
1047-
AST nodes and blocks with IDs)", "TYPE"),
1048-
optflagopt("", "dep-info",
1049-
"Output dependency info to <filename> after compiling", "FILENAME"),
1050-
optopt("", "sysroot",
1051-
"Override the system root", "PATH"),
1051+
"Pretty-print the input instead of compiling;
1052+
valid types are: normal (un-annotated source),
1053+
expanded (crates expanded),
1054+
typed (crates expanded, with type annotations),
1055+
or identified (fully parenthesized,
1056+
AST nodes and blocks with IDs)", "TYPE"),
1057+
optflagopt("", "dep-info", "Output dependency info to <filename> after compiling", "FILENAME"),
1058+
optopt("", "sysroot", "Override the system root", "PATH"),
10521059
optflag("", "test", "Build a test harness"),
1053-
optopt("", "target",
1054-
"Target triple cpu-manufacturer-kernel[-os]
1055-
to compile for (see chapter 3.4 of http://www.sourceware.org/autobook/
1056-
for details)", "TRIPLE"),
1057-
optmulti("W", "warn",
1058-
"Set lint warnings", "OPT"),
1059-
optmulti("A", "allow",
1060-
"Set lint allowed", "OPT"),
1061-
optmulti("D", "deny",
1062-
"Set lint denied", "OPT"),
1063-
optmulti("F", "forbid",
1064-
"Set lint forbidden", "OPT"),
1065-
optmulti("C", "codegen",
1066-
"Set a codegen option", "OPT[=VALUE]"),
1067-
optmulti("Z", "", "Set internal debugging options", "FLAG"),
1068-
optflag( "v", "version",
1069-
"Print version info and exit"),
1060+
optopt("", "target", "Target triple cpu-manufacturer-kernel[-os]
1061+
to compile for (see chapter 3.4 of http://www.sourceware.org/autobook/
1062+
for details)", "TRIPLE"),
1063+
optmulti("W", "warn", "Set lint warnings", "OPT"),
1064+
optmulti("A", "allow", "Set lint allowed", "OPT"),
1065+
optmulti("D", "deny", "Set lint denied", "OPT"),
1066+
optmulti("F", "forbid", "Set lint forbidden", "OPT"),
1067+
optmulti("C", "codegen", "Set a codegen option", "OPT[=VALUE]"),
1068+
optmulti("Z", "", "Set internal debugging options", "FLAG"),
1069+
optflag( "v", "version", "Print version info and exit"),
10701070
]
10711071
}
10721072

0 commit comments

Comments
 (0)