Skip to content

Commit 425b743

Browse files
committed
---
yaml --- r: 61373 b: refs/heads/try c: 8a15333 h: refs/heads/master i: 61371: 59326f3 v: v3
1 parent e262c4e commit 425b743

Some content is hidden

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

59 files changed

+1300
-3027
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2d28d645422c1617be58c8ca7ad9a457264ca850
5-
refs/heads/try: 0d1331f4a0cade66349a4c22315899210ad9b6a7
5+
refs/heads/try: 8a15333c06b8ba491e1654c3fca3fa21d21def9b
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/etc/vim/after/syntax/rust.vim

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ syn match rustRightArrowHead contained ">" conceal cchar= 
1111
syn match rustRightArrowTail contained "-" conceal cchar=
1212
syn match rustNiceOperator "->" contains=rustRightArrowHead,rustRightArrowTail
1313

14-
syn match rustLeftRightArrowHead contained ">" conceal cchar= 
15-
syn match rustLeftRightArrowTail contained "<-" conceal cchar=
16-
syn match rustNiceOperator "<->" contains=rustLeftRightArrowHead,rustLeftRightArrowTail
17-
1814
syn match rustFatRightArrowHead contained ">" conceal cchar= 
1915
syn match rustFatRightArrowTail contained "=" conceal cchar=
2016
syn match rustNiceOperator "=>" contains=rustFatRightArrowHead,rustFatRightArrowTail

branches/try/src/etc/vim/syntax/rust.vim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ syn keyword rustOperator as
1515

1616
syn keyword rustKeyword break copy do drop extern
1717
syn keyword rustKeyword for if impl let log
18-
syn keyword rustKeyword copy do drop extern
18+
syn keyword rustKeyword copy do extern
1919
syn keyword rustKeyword for impl let log
2020
syn keyword rustKeyword loop mod once priv pub
2121
syn keyword rustKeyword return
@@ -28,8 +28,8 @@ syn keyword rustStorage const mut ref static
2828
syn match rustIdentifier contains=rustIdentifierPrime "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained
2929
syn match rustFuncName "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained
3030

31-
" Reserved words
32-
"syn keyword rustKeyword m32 m64 m128 f80 f16 f128 be " These are obsolete
31+
" reserved
32+
syn keyword rustKeyword be
3333

3434
syn keyword rustType int uint float char bool u8 u16 u32 u64 f32
3535
syn keyword rustType f64 i8 i16 i32 i64 str Self

branches/try/src/libcore/cell.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,17 @@ Similar to a mutable option type, but friendlier.
2121
*/
2222

2323
#[mutable]
24+
#[deriving(Clone)]
2425
pub struct Cell<T> {
2526
priv value: Option<T>
2627
}
2728

29+
impl<T: DeepClone> DeepClone for Cell<T> {
30+
fn deep_clone(&self) -> Cell<T> {
31+
Cell{value: self.value.deep_clone()}
32+
}
33+
}
34+
2835
impl<T:cmp::Eq> cmp::Eq for Cell<T> {
2936
fn eq(&self, other: &Cell<T>) -> bool {
3037
(self.value) == (other.value)

branches/try/src/libcore/clone.rs

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,12 @@ by convention implementing the `Clone` trait and calling the
2323
*/
2424

2525
pub trait Clone {
26-
/// Return a deep copy of the owned object tree. Managed boxes are cloned with a shallow copy.
26+
/// Return a deep copy of the owned object tree. Types with shared ownership like managed boxes
27+
/// are cloned with a shallow copy.
2728
fn clone(&self) -> Self;
2829
}
2930

30-
impl Clone for () {
31-
/// Return a copy of the value.
32-
#[inline(always)]
33-
fn clone(&self) -> () { () }
34-
}
35-
36-
impl<T:Clone> Clone for ~T {
31+
impl<T: Clone> Clone for ~T {
3732
/// Return a deep copy of the owned box.
3833
#[inline(always)]
3934
fn clone(&self) -> ~T { ~(**self).clone() }
@@ -54,7 +49,7 @@ impl<T> Clone for @mut T {
5449
macro_rules! clone_impl(
5550
($t:ty) => {
5651
impl Clone for $t {
57-
/// Return a copy of the value.
52+
/// Return a deep copy of the value.
5853
#[inline(always)]
5954
fn clone(&self) -> $t { *self }
6055
}
@@ -77,9 +72,53 @@ clone_impl!(float)
7772
clone_impl!(f32)
7873
clone_impl!(f64)
7974

75+
clone_impl!(())
8076
clone_impl!(bool)
8177
clone_impl!(char)
8278

79+
pub trait DeepClone {
80+
/// Return a deep copy of the object tree. Types with shared ownership are also copied via a
81+
/// deep copy, unlike `Clone`. Note that this is currently unimplemented for managed boxes, as
82+
/// it would need to handle cycles.
83+
fn deep_clone(&self) -> Self;
84+
}
85+
86+
macro_rules! deep_clone_impl(
87+
($t:ty) => {
88+
impl DeepClone for $t {
89+
/// Return a deep copy of the value.
90+
#[inline(always)]
91+
fn deep_clone(&self) -> $t { *self }
92+
}
93+
}
94+
)
95+
96+
impl<T: DeepClone> DeepClone for ~T {
97+
/// Return a deep copy of the owned box.
98+
#[inline(always)]
99+
fn deep_clone(&self) -> ~T { ~(**self).deep_clone() }
100+
}
101+
102+
deep_clone_impl!(int)
103+
deep_clone_impl!(i8)
104+
deep_clone_impl!(i16)
105+
deep_clone_impl!(i32)
106+
deep_clone_impl!(i64)
107+
108+
deep_clone_impl!(uint)
109+
deep_clone_impl!(u8)
110+
deep_clone_impl!(u16)
111+
deep_clone_impl!(u32)
112+
deep_clone_impl!(u64)
113+
114+
deep_clone_impl!(float)
115+
deep_clone_impl!(f32)
116+
deep_clone_impl!(f64)
117+
118+
deep_clone_impl!(())
119+
deep_clone_impl!(bool)
120+
deep_clone_impl!(char)
121+
83122
#[test]
84123
fn test_owned_clone() {
85124
let a: ~int = ~5i;

branches/try/src/libcore/core.rc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,8 @@ mod unicode;
205205
#[path = "num/cmath.rs"]
206206
mod cmath;
207207
mod stackwalk;
208-
209-
// XXX: This shouldn't be pub, and it should be reexported under 'unstable'
210-
// but name resolution doesn't work without it being pub.
211208
#[path = "rt/mod.rs"]
212-
pub mod rt;
209+
mod rt;
213210

214211
// A curious inner-module that's not exported that contains the binding
215212
// 'core' so that macro-expanded references to core::error and such

branches/try/src/libcore/logging.rs

Lines changed: 13 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,17 @@
1010

1111
//! Logging
1212
13-
use option::*;
14-
use either::*;
15-
use rt;
16-
use rt::logging::{Logger, StdErrLogger};
17-
use io;
18-
use libc;
19-
use repr;
20-
use vec;
21-
use cast;
22-
use str;
13+
pub mod rustrt {
14+
use libc;
15+
16+
pub extern {
17+
unsafe fn rust_log_console_on();
18+
unsafe fn rust_log_console_off();
19+
unsafe fn rust_log_str(level: u32,
20+
string: *libc::c_char,
21+
size: libc::size_t);
22+
}
23+
}
2324

2425
/// Turns on logging to stdout globally
2526
pub fn console_on() {
@@ -54,46 +55,8 @@ pub fn log_type<T>(level: u32, object: &T) {
5455
let bytes = do io::with_bytes_writer |writer| {
5556
repr::write_repr(writer, object);
5657
};
57-
58-
match rt::context() {
59-
rt::OldTaskContext => {
60-
unsafe {
61-
let len = bytes.len() as libc::size_t;
62-
rustrt::rust_log_str(level, cast::transmute(vec::raw::to_ptr(bytes)), len);
63-
}
64-
}
65-
_ => {
66-
// XXX: Bad allocation
67-
let msg = str::from_bytes(bytes);
68-
newsched_log_str(msg);
69-
}
70-
}
71-
}
72-
73-
fn newsched_log_str(msg: ~str) {
7458
unsafe {
75-
match rt::local_services::unsafe_try_borrow_local_services() {
76-
Some(local) => {
77-
// Use the available logger
78-
(*local).logger.log(Left(msg));
79-
}
80-
None => {
81-
// There is no logger anywhere, just write to stderr
82-
let mut logger = StdErrLogger;
83-
logger.log(Left(msg));
84-
}
85-
}
86-
}
87-
}
88-
89-
pub mod rustrt {
90-
use libc;
91-
92-
pub extern {
93-
unsafe fn rust_log_console_on();
94-
unsafe fn rust_log_console_off();
95-
unsafe fn rust_log_str(level: u32,
96-
string: *libc::c_char,
97-
size: libc::size_t);
59+
let len = bytes.len() as libc::size_t;
60+
rustrt::rust_log_str(level, transmute(vec::raw::to_ptr(bytes)), len);
9861
}
9962
}

branches/try/src/libcore/macros.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,10 @@ macro_rules! rtdebug (
3030
($( $arg:expr),+) => ( $(let _ = $arg)*; )
3131
)
3232

33-
macro_rules! rtassert (
34-
( $arg:expr ) => ( {
35-
if !$arg {
36-
abort!("assertion failed: %s", stringify!($arg));
37-
}
38-
} )
39-
)
40-
4133
macro_rules! abort(
4234
($( $msg:expr),+) => ( {
4335
rtdebug!($($msg),+);
4436

45-
do_abort();
46-
47-
// NB: This is in a fn to avoid putting the `unsafe` block in a macro,
48-
// which causes spurious 'unnecessary unsafe block' warnings.
49-
fn do_abort() -> ! {
50-
unsafe { ::libc::abort(); }
51-
}
37+
unsafe { ::libc::abort(); }
5238
} )
5339
)

branches/try/src/libcore/option.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ use num::Zero;
4949
use old_iter::{BaseIter, MutableIter, ExtendedIter};
5050
use old_iter;
5151
use str::StrSlice;
52+
use clone::DeepClone;
5253

5354
#[cfg(test)] use str;
5455

@@ -59,6 +60,15 @@ pub enum Option<T> {
5960
Some(T),
6061
}
6162

63+
impl<T: DeepClone> DeepClone for Option<T> {
64+
fn deep_clone(&self) -> Option<T> {
65+
match *self {
66+
Some(ref x) => Some(x.deep_clone()),
67+
None => None
68+
}
69+
}
70+
}
71+
6272
impl<T:Ord> Ord for Option<T> {
6373
fn lt(&self, other: &Option<T>) -> bool {
6474
match (self, other) {

branches/try/src/libcore/os.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -147,25 +147,23 @@ pub mod win32 {
147147

148148
/*
149149
Accessing environment variables is not generally threadsafe.
150-
Serialize access through a global lock.
150+
This uses a per-runtime lock to serialize access.
151+
FIXME #4726: It would probably be appropriate to make this a real global
151152
*/
152153
fn with_env_lock<T>(f: &fn() -> T) -> T {
153-
use unstable::finally::Finally;
154+
use unstable::global::global_data_clone_create;
155+
use unstable::sync::{Exclusive, exclusive};
156+
157+
struct SharedValue(());
158+
type ValueMutex = Exclusive<SharedValue>;
159+
fn key(_: ValueMutex) { }
154160

155161
unsafe {
156-
return do (|| {
157-
rust_take_env_lock();
158-
f()
159-
}).finally {
160-
rust_drop_env_lock();
161-
};
162-
}
162+
let lock: ValueMutex = global_data_clone_create(key, || {
163+
~exclusive(SharedValue(()))
164+
});
163165

164-
extern {
165-
#[fast_ffi]
166-
fn rust_take_env_lock();
167-
#[fast_ffi]
168-
fn rust_drop_env_lock();
166+
lock.with_imm(|_| f() )
169167
}
170168
}
171169

@@ -724,7 +722,7 @@ pub fn list_dir(p: &Path) -> ~[~str] {
724722
use os::win32::{
725723
as_utf16_p
726724
};
727-
use rt::global_heap::{malloc_raw, free_raw};
725+
use unstable::exchange_alloc::{malloc_raw, free_raw};
728726
#[nolink]
729727
extern {
730728
unsafe fn rust_list_dir_wfd_size() -> libc::size_t;

branches/try/src/libcore/prelude.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub use io::{print, println};
2727

2828
/* Reexported types and traits */
2929

30-
pub use clone::Clone;
30+
pub use clone::{Clone, DeepClone};
3131
pub use cmp::{Eq, ApproxEq, Ord, TotalEq, TotalOrd, Ordering, Less, Equal, Greater, Equiv};
3232
pub use container::{Container, Mutable, Map, Set};
3333
pub use hash::Hash;

branches/try/src/libcore/rt/context.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ pub impl Context {
8484
}
8585

8686
extern {
87-
#[rust_stack]
8887
fn swap_registers(out_regs: *mut Registers, in_regs: *Registers);
8988
}
9089

@@ -112,9 +111,9 @@ fn initialize_call_frame(regs: &mut Registers, fptr: *c_void, arg: *c_void, sp:
112111
let sp = align_down(sp);
113112
let sp = mut_offset(sp, -4);
114113

115-
unsafe { *sp = arg as uint };
114+
unsafe { *sp = arg as uint; }
116115
let sp = mut_offset(sp, -1);
117-
unsafe { *sp = 0 }; // The final return address
116+
unsafe { *sp = 0; } // The final return address
118117

119118
regs.esp = sp as u32;
120119
regs.eip = fptr as u32;
@@ -196,7 +195,7 @@ fn initialize_call_frame(regs: &mut Registers, fptr: *c_void, arg: *c_void, sp:
196195

197196
fn align_down(sp: *mut uint) -> *mut uint {
198197
unsafe {
199-
let sp: uint = transmute(sp);
198+
let sp = transmute::<*mut uint, uint>(sp);
200199
let sp = sp & !(16 - 1);
201200
transmute::<uint, *mut uint>(sp)
202201
}

0 commit comments

Comments
 (0)