Skip to content

Commit 54ed520

Browse files
committed
---
yaml --- r: 79861 b: refs/heads/master c: 67ed30c h: refs/heads/master i: 79859: 32f1f51 v: v3
1 parent b4e6199 commit 54ed520

File tree

93 files changed

+1416
-462
lines changed

Some content is hidden

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

93 files changed

+1416
-462
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: 491ce71453499f61eeb24d891b28a07ea9ae532b
2+
refs/heads/master: 67ed30cd5eab9af1976a994c50d146a3dbeccad4
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 54ae2800ffb30513f89ce13d27ac3c8d095d98ac
55
refs/heads/try: 71bebebc37fbb229877da88dde13c2f35913bd77

trunk/src/libextra/rl.rs

Lines changed: 31 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// FIXME #3921. This is unsafe because linenoise uses global mutable
12+
// state without mutexes.
13+
1114
use std::c_str::ToCStr;
1215
use std::libc::{c_char, c_int};
13-
use std::{local_data, str, rt};
14-
use std::unstable::finally::Finally;
16+
use std::local_data;
17+
use std::str;
1518

1619
#[cfg(stage0)]
1720
pub mod rustrt {
@@ -25,9 +28,6 @@ pub mod rustrt {
2528
fn linenoiseHistoryLoad(file: *c_char) -> c_int;
2629
fn linenoiseSetCompletionCallback(callback: *u8);
2730
fn linenoiseAddCompletion(completions: *(), line: *c_char);
28-
29-
fn rust_take_linenoise_lock();
30-
fn rust_drop_linenoise_lock();
3131
}
3232
}
3333

@@ -42,107 +42,65 @@ pub mod rustrt {
4242
externfn!(fn linenoiseHistoryLoad(file: *c_char) -> c_int)
4343
externfn!(fn linenoiseSetCompletionCallback(callback: extern "C" fn(*i8, *())))
4444
externfn!(fn linenoiseAddCompletion(completions: *(), line: *c_char))
45-
46-
externfn!(fn rust_take_linenoise_lock())
47-
externfn!(fn rust_drop_linenoise_lock())
48-
}
49-
50-
macro_rules! locked {
51-
($expr:expr) => {
52-
unsafe {
53-
// FIXME #9105: can't use a static mutex in pure Rust yet.
54-
rustrt::rust_take_linenoise_lock();
55-
let x = $expr;
56-
rustrt::rust_drop_linenoise_lock();
57-
x
58-
}
59-
}
6045
}
6146

6247
/// Add a line to history
63-
pub fn add_history(line: &str) -> bool {
48+
pub unsafe fn add_history(line: &str) -> bool {
6449
do line.with_c_str |buf| {
65-
(locked!(rustrt::linenoiseHistoryAdd(buf))) == 1 as c_int
50+
rustrt::linenoiseHistoryAdd(buf) == 1 as c_int
6651
}
6752
}
6853

6954
/// Set the maximum amount of lines stored
70-
pub fn set_history_max_len(len: int) -> bool {
71-
(locked!(rustrt::linenoiseHistorySetMaxLen(len as c_int))) == 1 as c_int
55+
pub unsafe fn set_history_max_len(len: int) -> bool {
56+
rustrt::linenoiseHistorySetMaxLen(len as c_int) == 1 as c_int
7257
}
7358

7459
/// Save line history to a file
75-
pub fn save_history(file: &str) -> bool {
60+
pub unsafe fn save_history(file: &str) -> bool {
7661
do file.with_c_str |buf| {
77-
// 0 on success, -1 on failure
78-
(locked!(rustrt::linenoiseHistorySave(buf))) == 0 as c_int
62+
rustrt::linenoiseHistorySave(buf) == 1 as c_int
7963
}
8064
}
8165

8266
/// Load line history from a file
83-
pub fn load_history(file: &str) -> bool {
67+
pub unsafe fn load_history(file: &str) -> bool {
8468
do file.with_c_str |buf| {
85-
// 0 on success, -1 on failure
86-
(locked!(rustrt::linenoiseHistoryLoad(buf))) == 0 as c_int
69+
rustrt::linenoiseHistoryLoad(buf) == 1 as c_int
8770
}
8871
}
8972

9073
/// Print out a prompt and then wait for input and return it
91-
pub fn read(prompt: &str) -> Option<~str> {
74+
pub unsafe fn read(prompt: &str) -> Option<~str> {
9275
do prompt.with_c_str |buf| {
93-
let line = locked!(rustrt::linenoise(buf));
76+
let line = rustrt::linenoise(buf);
9477

9578
if line.is_null() { None }
96-
else {
97-
unsafe {
98-
do (|| {
99-
Some(str::raw::from_c_str(line))
100-
}).finally {
101-
// linenoise's return value is from strdup, so we
102-
// better not leak it.
103-
rt::global_heap::exchange_free(line);
104-
}
105-
}
106-
}
79+
else { Some(str::raw::from_c_str(line)) }
10780
}
10881
}
10982

11083
pub type CompletionCb = @fn(~str, @fn(~str));
11184

112-
static complete_key: local_data::Key<CompletionCb> = &local_data::Key;
113-
114-
/// Bind to the main completion callback in the current task.
115-
///
116-
/// The completion callback should not call any `extra::rl` functions
117-
/// other than the closure that it receives as its second
118-
/// argument. Calling such a function will deadlock on the mutex used
119-
/// to ensure that the calls are thread-safe.
120-
pub fn complete(cb: CompletionCb) {
121-
local_data::set(complete_key, cb);
122-
123-
extern fn callback(c_line: *c_char, completions: *()) {
124-
do local_data::get(complete_key) |opt_cb| {
125-
// only fetch completions if a completion handler has been
126-
// registered in the current task.
127-
match opt_cb {
128-
None => {},
129-
Some(cb) => {
130-
let line = unsafe { str::raw::from_c_str(c_line) };
131-
do (*cb)(line) |suggestion| {
132-
do suggestion.with_c_str |buf| {
133-
// This isn't locked, because `callback` gets
134-
// called inside `rustrt::linenoise`, which
135-
// *is* already inside the mutex, so
136-
// re-locking would be a deadlock.
137-
unsafe {
138-
rustrt::linenoiseAddCompletion(completions, buf);
139-
}
140-
}
85+
static complete_key: local_data::Key<@CompletionCb> = &local_data::Key;
86+
87+
/// Bind to the main completion callback
88+
pub unsafe fn complete(cb: CompletionCb) {
89+
local_data::set(complete_key, @cb);
90+
91+
extern fn callback(line: *c_char, completions: *()) {
92+
do local_data::get(complete_key) |cb| {
93+
let cb = **cb.unwrap();
94+
95+
unsafe {
96+
do cb(str::raw::from_c_str(line)) |suggestion| {
97+
do suggestion.with_c_str |buf| {
98+
rustrt::linenoiseAddCompletion(completions, buf);
14199
}
142100
}
143101
}
144102
}
145103
}
146104

147-
locked!(rustrt::linenoiseSetCompletionCallback(callback));
105+
rustrt::linenoiseSetCompletionCallback(callback);
148106
}

trunk/src/librustc/lib/llvm.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2109,6 +2109,14 @@ pub mod llvm {
21092109
ArgNo: c_uint)
21102110
-> ValueRef;
21112111

2112+
#[fast_ffi]
2113+
pub fn LLVMDIBuilderCreateNameSpace(Builder: DIBuilderRef,
2114+
Scope: ValueRef,
2115+
Name: *c_char,
2116+
File: ValueRef,
2117+
LineNo: c_uint)
2118+
-> ValueRef;
2119+
21122120
#[fast_ffi]
21132121
pub fn LLVMIsAArgument(value_ref: ValueRef) -> ValueRef;
21142122

trunk/src/librustc/middle/trans/base.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3021,6 +3021,10 @@ pub fn trans_crate(sess: session::Session,
30213021
link_meta,
30223022
analysis.reachable);
30233023

3024+
if ccx.sess.opts.debuginfo {
3025+
debuginfo::initialize(ccx, crate);
3026+
}
3027+
30243028
{
30253029
let _icx = push_ctxt("text");
30263030
trans_mod(ccx, &crate.module);

0 commit comments

Comments
 (0)