Skip to content

Commit 0f91b3c

Browse files
committed
---
yaml --- r: 139971 b: refs/heads/try2 c: 5c2e9b2 h: refs/heads/master i: 139969: e58c505 139967: ba8009b v: v3
1 parent f9ca548 commit 0f91b3c

Some content is hidden

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

118 files changed

+5774
-3763
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: 4ff701b7db609cabe59832d47779832a16627b5f
8+
refs/heads/try2: 5c2e9b29f10694ad76dcb6b88e95243a44813c05
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/doc/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1670,7 +1670,7 @@ do spawn {
16701670
~~~~
16711671

16721672
If you want to see the output of `debug!` statements, you will need to turn on `debug!` logging.
1673-
To enable `debug!` logging, set the RUST_LOG environment variable to the name of your crate, which, for a file named `foo.rs`, will be `foo` (e.g., with bash, `export RUST_LOG=foo`).
1673+
To enable `debug!` logging, set the RUST_LOG environment variable to `debug` (e.g., with bash, `export RUST_LOG=debug`)
16741674

16751675
## For loops
16761676

branches/try2/src/etc/unicode.py

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -112,49 +112,7 @@ def escape_char(c):
112112
return "'\\u%4.4x'" % c
113113
return "'\\U%8.8x'" % c
114114

115-
def ch_prefix(ix):
116-
if ix == 0:
117-
return " "
118-
if ix % 2 == 0:
119-
return ",\n "
120-
else:
121-
return ", "
122-
123-
def emit_bsearch_range_table(f):
124-
f.write("""
125-
pure fn bsearch_range_table(c: char, r: &[(char,char)]) -> bool {
126-
use cmp::{EQ, LT, GT};
127-
use vec::bsearch;
128-
use option::None;
129-
(do bsearch(r) |&(lo,hi)| {
130-
if lo <= c && c <= hi { EQ }
131-
else if hi < c { LT }
132-
else { GT }
133-
}) != None
134-
}\n\n
135-
""");
136-
137115
def emit_property_module(f, mod, tbl):
138-
f.write("pub mod %s {\n" % mod)
139-
keys = tbl.keys()
140-
keys.sort()
141-
emit_bsearch_range_table(f);
142-
for cat in keys:
143-
f.write(" const %s_table : &[(char,char)] = &[\n" % cat)
144-
ix = 0
145-
for pair in tbl[cat]:
146-
f.write(ch_prefix(ix))
147-
f.write("(%s, %s)" % (escape_char(pair[0]), escape_char(pair[1])))
148-
ix += 1
149-
f.write("\n ];\n\n")
150-
151-
f.write(" pub pure fn %s(c: char) -> bool {\n" % cat)
152-
f.write(" bsearch_range_table(c, %s_table)\n" % cat)
153-
f.write(" }\n\n")
154-
f.write("}\n")
155-
156-
157-
def emit_property_module_old(f, mod, tbl):
158116
f.write("mod %s {\n" % mod)
159117
keys = tbl.keys()
160118
keys.sort()
@@ -235,9 +193,8 @@ def emit_decomp_module(f, canon, compat):
235193
rf = open(r, "w")
236194

237195
(canon_decomp, compat_decomp, gencats) = load_unicode_data("UnicodeData.txt")
196+
emit_decomp_module(rf, canon_decomp, compat_decomp)
238197
emit_property_module(rf, "general_category", gencats)
239198

240-
#emit_decomp_module(rf, canon_decomp, compat_decomp)
241-
242199
derived = load_derived_core_properties("DerivedCoreProperties.txt")
243200
emit_property_module(rf, "derived_property", derived)

branches/try2/src/libcore/comm.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ pub mod streamp {
112112

113113
#[allow(non_camel_case_types)]
114114
pub mod server {
115+
priv use core::kinds::Owned;
116+
115117
#[allow(non_camel_case_types)]
116118
pub type Open<T> = ::core::pipes::RecvPacket<super::Open<T>>;
117119
}
@@ -386,6 +388,8 @@ pub mod oneshot {
386388
387389
#[allow(non_camel_case_types)]
388390
pub mod server {
391+
priv use core::kinds::Owned;
392+
389393
#[allow(non_camel_case_types)]
390394
pub type Oneshot<T> =
391395
::core::pipes::RecvPacketBuffered<super::Oneshot<T>,

branches/try2/src/libcore/rt/sched/local_sched.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,18 @@ pub fn borrow(f: &fn(&mut Scheduler)) {
6666
/// Because this leaves the Scheduler in thread-local storage it is possible
6767
/// For the Scheduler pointer to be aliased
6868
pub unsafe fn unsafe_borrow() -> &mut Scheduler {
69-
let key = tls_key();
70-
let mut void_sched: *mut c_void = tls::get(key);
71-
assert!(void_sched.is_not_null());
72-
{
73-
let void_sched_ptr = &mut void_sched;
74-
let sched: &mut ~Scheduler = {
75-
transmute::<&mut *mut c_void, &mut ~Scheduler>(void_sched_ptr)
76-
};
77-
let sched: &mut Scheduler = &mut **sched;
78-
return sched;
69+
unsafe {
70+
let key = tls_key();
71+
let mut void_sched: *mut c_void = tls::get(key);
72+
assert!(void_sched.is_not_null());
73+
{
74+
let void_sched_ptr = &mut void_sched;
75+
let sched: &mut ~Scheduler = {
76+
transmute::<&mut *mut c_void, &mut ~Scheduler>(void_sched_ptr)
77+
};
78+
let sched: &mut Scheduler = &mut **sched;
79+
return sched;
80+
}
7981
}
8082
}
8183

branches/try2/src/libcore/rt/uv/net.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ fn connect_read() {
388388
vec_to_uv_buf(vec::from_elem(size, 0))
389389
};
390390
do stream_watcher.read_start(alloc)
391-
|stream_watcher, _nread, buf, status| {
391+
|stream_watcher, nread, buf, status| {
392392
393393
let buf = vec_from_uv_buf(buf);
394394
rtdebug!("read cb!");

branches/try2/src/libcore/stackwalk.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ fn test_simple_deep() {
6464
if i == 0 { return }
6565

6666
for walk_stack |_frame| {
67-
breakpoint();
67+
unsafe {
68+
breakpoint();
69+
}
6870
}
6971
run(i - 1);
7072
}

branches/try2/src/libcore/str.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3346,15 +3346,15 @@ mod tests {
33463346
#[test]
33473347
fn test_shift_byte() {
33483348
let mut s = ~"ABC";
3349-
let b = raw::shift_byte(&mut s);
3349+
let b = unsafe { raw::shift_byte(&mut s) };
33503350
assert!((s == ~"BC"));
33513351
assert!((b == 65u8));
33523352
}
33533353
33543354
#[test]
33553355
fn test_pop_byte() {
33563356
let mut s = ~"ABC";
3357-
let b = raw::pop_byte(&mut s);
3357+
let b = unsafe { raw::pop_byte(&mut s) };
33583358
assert!((s == ~"AB"));
33593359
assert!((b == 67u8));
33603360
}

branches/try2/src/libcore/sys.rs

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,24 @@ pub fn get_type_desc<T>() -> *TypeDesc {
8383
unsafe { rusti::get_tydesc::<T>() as *TypeDesc }
8484
}
8585

86+
/// Returns a pointer to a type descriptor.
87+
#[inline(always)]
88+
pub fn get_type_desc_val<T>(_val: &T) -> *TypeDesc {
89+
get_type_desc::<T>()
90+
}
91+
8692
/// Returns the size of a type
8793
#[inline(always)]
8894
pub fn size_of<T>() -> uint {
8995
unsafe { rusti::size_of::<T>() }
9096
}
9197

98+
/// Returns the size of the type that `_val` points to
99+
#[inline(always)]
100+
pub fn size_of_val<T>(_val: &T) -> uint {
101+
size_of::<T>()
102+
}
103+
92104
/**
93105
* Returns the size of a type, or 1 if the actual size is zero.
94106
*
@@ -100,6 +112,13 @@ pub fn nonzero_size_of<T>() -> uint {
100112
if s == 0 { 1 } else { s }
101113
}
102114

115+
/// Returns the size of the type of the value that `_val` points to
116+
#[inline(always)]
117+
pub fn nonzero_size_of_val<T>(_val: &T) -> uint {
118+
nonzero_size_of::<T>()
119+
}
120+
121+
103122
/**
104123
* Returns the ABI-required minimum alignment of a type
105124
*
@@ -111,12 +130,26 @@ pub fn min_align_of<T>() -> uint {
111130
unsafe { rusti::min_align_of::<T>() }
112131
}
113132

133+
/// Returns the ABI-required minimum alignment of the type of the value that
134+
/// `_val` points to
135+
#[inline(always)]
136+
pub fn min_align_of_val<T>(_val: &T) -> uint {
137+
min_align_of::<T>()
138+
}
139+
114140
/// Returns the preferred alignment of a type
115141
#[inline(always)]
116142
pub fn pref_align_of<T>() -> uint {
117143
unsafe { rusti::pref_align_of::<T>() }
118144
}
119145

146+
/// Returns the preferred alignment of the type of the value that
147+
/// `_val` points to
148+
#[inline(always)]
149+
pub fn pref_align_of_val<T>(_val: &T) -> uint {
150+
pref_align_of::<T>()
151+
}
152+
120153
/// Returns the refcount of a shared box (as just before calling this)
121154
#[inline(always)]
122155
pub fn refcount<T>(t: @T) -> uint {
@@ -162,7 +195,7 @@ pub fn fail_assert(msg: &str, file: &str, line: uint) -> ! {
162195
#[cfg(test)]
163196
mod tests {
164197
use cast;
165-
use sys::{Closure, pref_align_of, size_of, nonzero_size_of};
198+
use sys::*;
166199
167200
#[test]
168201
fn size_of_basic() {
@@ -188,6 +221,14 @@ mod tests {
188221
assert!(size_of::<*uint>() == 8u);
189222
}
190223

224+
#[test]
225+
fn size_of_val_basic() {
226+
assert_eq!(size_of_val(&1u8), 1);
227+
assert_eq!(size_of_val(&1u16), 2);
228+
assert_eq!(size_of_val(&1u32), 4);
229+
assert_eq!(size_of_val(&1u64), 8);
230+
}
231+
191232
#[test]
192233
fn nonzero_size_of_basic() {
193234
type Z = [i8, ..0];
@@ -196,6 +237,14 @@ mod tests {
196237
assert!(nonzero_size_of::<uint>() == size_of::<uint>());
197238
}
198239

240+
#[test]
241+
fn nonzero_size_of_val_basic() {
242+
let z = [0u8, ..0];
243+
assert_eq!(size_of_val(&z), 0u);
244+
assert_eq!(nonzero_size_of_val(&z), 1u);
245+
assert_eq!(nonzero_size_of_val(&1u), size_of_val(&1u));
246+
}
247+
199248
#[test]
200249
fn align_of_basic() {
201250
assert!(pref_align_of::<u8>() == 1u);
@@ -219,6 +268,13 @@ mod tests {
219268
assert!(pref_align_of::<*uint>() == 8u);
220269
}
221270

271+
#[test]
272+
fn align_of_val_basic() {
273+
assert_eq!(pref_align_of_val(&1u8), 1u);
274+
assert_eq!(pref_align_of_val(&1u16), 2u);
275+
assert_eq!(pref_align_of_val(&1u32), 4u);
276+
}
277+
222278
#[test]
223279
fn synthesize_closure() {
224280
unsafe {

branches/try2/src/libcore/task/local_data.rs

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -150,28 +150,32 @@ fn test_tls_modify() {
150150
151151
#[test]
152152
fn test_tls_crust_automorestack_memorial_bug() {
153-
// This might result in a stack-canary clobber if the runtime fails to
154-
// set sp_limit to 0 when calling the cleanup extern - it might
155-
// automatically jump over to the rust stack, which causes next_c_sp
156-
// to get recorded as something within a rust stack segment. Then a
157-
// subsequent upcall (esp. for logging, think vsnprintf) would run on
158-
// a stack smaller than 1 MB.
159-
fn my_key(_x: @~str) { }
160-
do task::spawn {
161-
unsafe { local_data_set(my_key, @~"hax"); }
153+
unsafe {
154+
// This might result in a stack-canary clobber if the runtime fails to
155+
// set sp_limit to 0 when calling the cleanup extern - it might
156+
// automatically jump over to the rust stack, which causes next_c_sp
157+
// to get recorded as something within a rust stack segment. Then a
158+
// subsequent upcall (esp. for logging, think vsnprintf) would run on
159+
// a stack smaller than 1 MB.
160+
fn my_key(_x: @~str) { }
161+
do task::spawn {
162+
unsafe { local_data_set(my_key, @~"hax"); }
163+
}
162164
}
163165
}
164166
165167
#[test]
166168
fn test_tls_multiple_types() {
167-
fn str_key(_x: @~str) { }
168-
fn box_key(_x: @@()) { }
169-
fn int_key(_x: @int) { }
170-
do task::spawn {
171-
unsafe {
172-
local_data_set(str_key, @~"string data");
173-
local_data_set(box_key, @@());
174-
local_data_set(int_key, @42);
169+
unsafe {
170+
fn str_key(_x: @~str) { }
171+
fn box_key(_x: @@()) { }
172+
fn int_key(_x: @int) { }
173+
do task::spawn {
174+
unsafe {
175+
local_data_set(str_key, @~"string data");
176+
local_data_set(box_key, @@());
177+
local_data_set(int_key, @42);
178+
}
175179
}
176180
}
177181
}

0 commit comments

Comments
 (0)