Skip to content

Commit c39ae3a

Browse files
committed
---
yaml --- r: 95913 b: refs/heads/dist-snap c: f1cbb4d h: refs/heads/master i: 95911: 92c8211 v: v3
1 parent 15b80f0 commit c39ae3a

File tree

11 files changed

+196
-63
lines changed

11 files changed

+196
-63
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: a5f6f853f10ec88dc2608a8d2f969a4cf9e2e07d
9+
refs/heads/dist-snap: f1cbb4d566428c74f98acdc4805ffbda7c9994e0
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/libstd/any.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,28 @@ use util::Void;
2323
///////////////////////////////////////////////////////////////////////////////
2424

2525
/// `TypeId` represents a globally unique identifier for a type
26+
#[cfg(stage0)]
27+
pub struct TypeId {
28+
priv t: *intrinsics::TyDesc,
29+
}
30+
31+
/// `TypeId` represents a globally unique identifier for a type
32+
#[cfg(not(stage0))]
2633
pub struct TypeId {
2734
priv t: u64,
2835
}
2936

3037
impl TypeId {
3138
/// Returns the `TypeId` of the type this generic function has been instantiated with
3239
#[inline]
40+
#[cfg(stage0)]
41+
pub fn of<T: 'static>() -> TypeId {
42+
TypeId{ t: unsafe { intrinsics::get_tydesc::<T>() } }
43+
}
44+
45+
/// Returns the `TypeId` of the type this generic function has been instantiated with
46+
#[inline]
47+
#[cfg(not(stage0))]
3348
pub fn of<T: 'static>() -> TypeId {
3449
TypeId{ t: unsafe { intrinsics::type_id::<T>() } }
3550
}

branches/dist-snap/src/libstd/ptr.rs

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,35 @@ pub fn is_not_null<T,P:RawPtr<T>>(ptr: P) -> bool { ptr.is_not_null() }
8787
* and destination may overlap.
8888
*/
8989
#[inline]
90+
#[cfg(target_word_size = "32", stage0)]
91+
pub unsafe fn copy_memory<T,P:RawPtr<T>>(dst: *mut T, src: P, count: uint) {
92+
intrinsics::memmove32(dst,
93+
cast::transmute_immut_unsafe(src),
94+
count as u32);
95+
}
96+
97+
/**
98+
* Copies data from one location to another.
99+
*
100+
* Copies `count` elements (not bytes) from `src` to `dst`. The source
101+
* and destination may overlap.
102+
*/
103+
#[inline]
104+
#[cfg(target_word_size = "64", stage0)]
105+
pub unsafe fn copy_memory<T,P:RawPtr<T>>(dst: *mut T, src: P, count: uint) {
106+
intrinsics::memmove64(dst,
107+
cast::transmute_immut_unsafe(src),
108+
count as u64);
109+
}
110+
111+
/**
112+
* Copies data from one location to another.
113+
*
114+
* Copies `count` elements (not bytes) from `src` to `dst`. The source
115+
* and destination may overlap.
116+
*/
117+
#[inline]
118+
#[cfg(not(stage0))]
90119
pub unsafe fn copy_memory<T,P:RawPtr<T>>(dst: *mut T, src: P, count: uint) {
91120
intrinsics::copy_memory(dst, cast::transmute_immut_unsafe(src), count)
92121
}
@@ -98,6 +127,39 @@ pub unsafe fn copy_memory<T,P:RawPtr<T>>(dst: *mut T, src: P, count: uint) {
98127
* and destination may *not* overlap.
99128
*/
100129
#[inline]
130+
#[cfg(target_word_size = "32", stage0)]
131+
pub unsafe fn copy_nonoverlapping_memory<T,P:RawPtr<T>>(dst: *mut T,
132+
src: P,
133+
count: uint) {
134+
intrinsics::memcpy32(dst,
135+
cast::transmute_immut_unsafe(src),
136+
count as u32);
137+
}
138+
139+
/**
140+
* Copies data from one location to another.
141+
*
142+
* Copies `count` elements (not bytes) from `src` to `dst`. The source
143+
* and destination may *not* overlap.
144+
*/
145+
#[inline]
146+
#[cfg(target_word_size = "64", stage0)]
147+
pub unsafe fn copy_nonoverlapping_memory<T,P:RawPtr<T>>(dst: *mut T,
148+
src: P,
149+
count: uint) {
150+
intrinsics::memcpy64(dst,
151+
cast::transmute_immut_unsafe(src),
152+
count as u64);
153+
}
154+
155+
/**
156+
* Copies data from one location to another.
157+
*
158+
* Copies `count` elements (not bytes) from `src` to `dst`. The source
159+
* and destination may *not* overlap.
160+
*/
161+
#[inline]
162+
#[cfg(not(stage0))]
101163
pub unsafe fn copy_nonoverlapping_memory<T,P:RawPtr<T>>(dst: *mut T,
102164
src: P,
103165
count: uint) {
@@ -109,6 +171,27 @@ pub unsafe fn copy_nonoverlapping_memory<T,P:RawPtr<T>>(dst: *mut T,
109171
* bytes of memory starting at `dst` to `c`.
110172
*/
111173
#[inline]
174+
#[cfg(target_word_size = "32", stage0)]
175+
pub unsafe fn set_memory<T>(dst: *mut T, c: u8, count: uint) {
176+
intrinsics::memset32(dst, c, count as u32);
177+
}
178+
179+
/**
180+
* Invokes memset on the specified pointer, setting `count * size_of::<T>()`
181+
* bytes of memory starting at `dst` to `c`.
182+
*/
183+
#[inline]
184+
#[cfg(target_word_size = "64", stage0)]
185+
pub unsafe fn set_memory<T>(dst: *mut T, c: u8, count: uint) {
186+
intrinsics::memset64(dst, c, count as u64);
187+
}
188+
189+
/**
190+
* Invokes memset on the specified pointer, setting `count * size_of::<T>()`
191+
* bytes of memory starting at `dst` to `c`.
192+
*/
193+
#[inline]
194+
#[cfg(not(stage0))]
112195
pub unsafe fn set_memory<T>(dst: *mut T, c: u8, count: uint) {
113196
intrinsics::set_memory(dst, c, count)
114197
}

branches/dist-snap/src/libstd/rc.rs

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,12 @@ impl<T: Freeze> Rc<T> {
4848
}
4949
}
5050

51-
impl<T: Send> Rc<T> {
52-
/// Construct a new reference-counted box from a `Send` value
53-
#[inline]
54-
pub fn from_send(value: T) -> Rc<T> {
55-
unsafe {
56-
Rc::new_unchecked(value)
57-
}
58-
}
59-
}
60-
6151
impl<T> Rc<T> {
6252
/// Unsafety construct a new reference-counted box from any value.
6353
///
64-
/// It is possible to create cycles, which will leak, and may interact
65-
/// poorly with managed pointers.
54+
/// If the type is not `Freeze`, the `Rc` box will incorrectly still be considered as a `Freeze`
55+
/// type. It is also possible to create cycles, which will leak, and may interact poorly with
56+
/// managed pointers.
6657
#[inline]
6758
pub unsafe fn new_unchecked(value: T) -> Rc<T> {
6859
Rc{ptr: transmute(~RcBox{value: value, count: 1})}
@@ -113,22 +104,26 @@ mod test_rc {
113104

114105
#[test]
115106
fn test_clone() {
116-
let x = Rc::from_send(Cell::new(5));
117-
let y = x.clone();
118-
do x.borrow().with_mut_ref |inner| {
119-
*inner = 20;
107+
unsafe {
108+
let x = Rc::new_unchecked(Cell::new(5));
109+
let y = x.clone();
110+
do x.borrow().with_mut_ref |inner| {
111+
*inner = 20;
112+
}
113+
assert_eq!(y.borrow().take(), 20);
120114
}
121-
assert_eq!(y.borrow().take(), 20);
122115
}
123116

124117
#[test]
125118
fn test_deep_clone() {
126-
let x = Rc::from_send(Cell::new(5));
127-
let y = x.deep_clone();
128-
do x.borrow().with_mut_ref |inner| {
129-
*inner = 20;
119+
unsafe {
120+
let x = Rc::new_unchecked(Cell::new(5));
121+
let y = x.deep_clone();
122+
do x.borrow().with_mut_ref |inner| {
123+
*inner = 20;
124+
}
125+
assert_eq!(y.borrow().take(), 5);
130126
}
131-
assert_eq!(y.borrow().take(), 5);
132127
}
133128

134129
#[test]
@@ -147,8 +142,10 @@ mod test_rc {
147142

148143
#[test]
149144
fn test_destructor() {
150-
let x = Rc::from_send(~5);
151-
assert_eq!(**x.borrow(), 5);
145+
unsafe {
146+
let x = Rc::new_unchecked(~5);
147+
assert_eq!(**x.borrow(), 5);
148+
}
152149
}
153150
}
154151

branches/dist-snap/src/libstd/reflect.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,13 @@ impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> {
382382
true
383383
}
384384

385+
#[cfg(stage0)]
386+
fn visit_fn_output(&mut self, retstyle: uint, inner: *TyDesc) -> bool {
387+
if ! self.inner.visit_fn_output(retstyle, inner) { return false; }
388+
true
389+
}
390+
391+
#[cfg(not(stage0))]
385392
fn visit_fn_output(&mut self, retstyle: uint, variadic: bool, inner: *TyDesc) -> bool {
386393
if ! self.inner.visit_fn_output(retstyle, variadic, inner) { return false; }
387394
true

branches/dist-snap/src/libstd/repr.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,18 @@ impl<'self> TyVisitor for ReprVisitor<'self> {
572572
true
573573
}
574574

575+
#[cfg(stage0)]
576+
fn visit_fn_output(&mut self, _retstyle: uint, inner: *TyDesc) -> bool {
577+
self.writer.write(")".as_bytes());
578+
let name = unsafe { (*inner).name };
579+
if name != "()" {
580+
self.writer.write(" -> ".as_bytes());
581+
self.writer.write(name.as_bytes());
582+
}
583+
true
584+
}
585+
586+
#[cfg(not(stage0))]
575587
fn visit_fn_output(&mut self, _retstyle: uint, variadic: bool, inner: *TyDesc) -> bool {
576588
if variadic {
577589
self.writer.write(", ...".as_bytes());

branches/dist-snap/src/libstd/unstable/intrinsics.rs

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ pub trait TyVisitor {
160160
fn visit_enter_fn(&mut self, purity: uint, proto: uint,
161161
n_inputs: uint, retstyle: uint) -> bool;
162162
fn visit_fn_input(&mut self, i: uint, mode: uint, inner: *TyDesc) -> bool;
163+
#[cfg(stage0)]
164+
fn visit_fn_output(&mut self, retstyle: uint, inner: *TyDesc) -> bool;
165+
#[cfg(not(stage0))]
163166
fn visit_fn_output(&mut self, retstyle: uint, variadic: bool, inner: *TyDesc) -> bool;
164167
fn visit_leave_fn(&mut self, purity: uint, proto: uint,
165168
n_inputs: uint, retstyle: uint) -> bool;
@@ -310,6 +313,7 @@ extern "rust-intrinsic" {
310313
/// Gets an identifier which is globally unique to the specified type. This
311314
/// function will return the same value for a type regardless of whichever
312315
/// crate it is invoked in.
316+
#[cfg(not(stage0))]
313317
pub fn type_id<T: 'static>() -> u64;
314318

315319
/// Create a value initialized to zero.
@@ -333,6 +337,11 @@ extern "rust-intrinsic" {
333337
pub fn needs_drop<T>() -> bool;
334338

335339
/// Returns `true` if a type is managed (will be allocated on the local heap)
340+
#[cfg(stage0)]
341+
pub fn contains_managed<T>() -> bool;
342+
343+
/// Returns `true` if a type is managed (will be allocated on the local heap)
344+
#[cfg(not(stage0))]
336345
pub fn owns_managed<T>() -> bool;
337346

338347
pub fn visit_tydesc(td: *TyDesc, tv: &mut TyVisitor);
@@ -348,19 +357,40 @@ extern "rust-intrinsic" {
348357
/// integer, since the conversion would throw away aliasing information.
349358
pub fn offset<T>(dst: *T, offset: int) -> *T;
350359

351-
/// Equivalent to the appropriate `llvm.memcpy.p0i8.0i8.*` intrinsic, with
352-
/// a size of `count` * `size_of::<T>()` and an alignment of
353-
/// `min_align_of::<T>()`
360+
/// Equivalent to the `llvm.memcpy.p0i8.0i8.i32` intrinsic, with a size of
361+
/// `count` * `size_of::<T>()` and an alignment of `min_align_of::<T>()`
362+
#[cfg(stage0)]
363+
pub fn memcpy32<T>(dst: *mut T, src: *T, count: u32);
364+
/// Equivalent to the `llvm.memcpy.p0i8.0i8.i64` intrinsic, with a size of
365+
/// `count` * `size_of::<T>()` and an alignment of `min_align_of::<T>()`
366+
#[cfg(stage0)]
367+
pub fn memcpy64<T>(dst: *mut T, src: *T, count: u64);
368+
369+
/// Equivalent to the `llvm.memmove.p0i8.0i8.i32` intrinsic, with a size of
370+
/// `count` * `size_of::<T>()` and an alignment of `min_align_of::<T>()`
371+
#[cfg(stage0)]
372+
pub fn memmove32<T>(dst: *mut T, src: *T, count: u32);
373+
/// Equivalent to the `llvm.memmove.p0i8.0i8.i64` intrinsic, with a size of
374+
/// `count` * `size_of::<T>()` and an alignment of `min_align_of::<T>()`
375+
#[cfg(stage0)]
376+
pub fn memmove64<T>(dst: *mut T, src: *T, count: u64);
377+
378+
/// Equivalent to the `llvm.memset.p0i8.i32` intrinsic, with a size of
379+
/// `count` * `size_of::<T>()` and an alignment of `min_align_of::<T>()`
380+
#[cfg(stage0)]
381+
pub fn memset32<T>(dst: *mut T, val: u8, count: u32);
382+
/// Equivalent to the `llvm.memset.p0i8.i64` intrinsic, with a size of
383+
/// `count` * `size_of::<T>()` and an alignment of `min_align_of::<T>()`
384+
#[cfg(stage0)]
385+
pub fn memset64<T>(dst: *mut T, val: u8, count: u64);
386+
387+
#[cfg(not(stage0))]
354388
pub fn copy_nonoverlapping_memory<T>(dst: *mut T, src: *T, count: uint);
355389

356-
/// Equivalent to the appropriate `llvm.memmove.p0i8.0i8.*` intrinsic, with
357-
/// a size of `count` * `size_of::<T>()` and an alignment of
358-
/// `min_align_of::<T>()`
390+
#[cfg(not(stage0))]
359391
pub fn copy_memory<T>(dst: *mut T, src: *T, count: uint);
360392

361-
/// Equivalent to the appropriate `llvm.memset.p0i8.*` intrinsic, with a
362-
/// size of `count` * `size_of::<T>()` and an alignment of
363-
/// `min_align_of::<T>()`
393+
#[cfg(not(stage0))]
364394
pub fn set_memory<T>(dst: *mut T, val: u8, count: uint);
365395

366396
pub fn sqrtf32(x: f32) -> f32;

branches/dist-snap/src/libstd/vec.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,19 @@ use mem::size_of;
121121
use uint;
122122
use unstable::finally::Finally;
123123
use unstable::intrinsics;
124-
use unstable::intrinsics::{get_tydesc, owns_managed};
124+
use unstable::intrinsics::{get_tydesc};
125125
use unstable::raw::{Box, Repr, Slice, Vec};
126126
use vec;
127127
use util;
128128

129+
#[cfg(not(stage0))]
130+
use unstable::intrinsics::owns_managed;
131+
132+
#[cfg(stage0)]
133+
unsafe fn owns_managed<T>() -> bool {
134+
intrinsics::contains_managed::<T>()
135+
}
136+
129137
/**
130138
* Creates and initializes an owned vector.
131139
*
@@ -2058,8 +2066,13 @@ pub mod raw {
20582066
use unstable::intrinsics;
20592067
use vec::{with_capacity, ImmutableVector, MutableVector};
20602068
use unstable::raw::{Box, Vec, Slice};
2069+
2070+
#[cfg(not(stage0))]
20612071
use unstable::intrinsics::owns_managed;
20622072

2073+
#[cfg(stage0)]
2074+
use vec::owns_managed;
2075+
20632076
/**
20642077
* Sets the length of a vector
20652078
*

branches/dist-snap/src/snapshots.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
S 2013-11-06 fdc830d
2-
freebsd-x86_64 ef38f3acf8d05eda3c9f21e75c2bbd2f90a614a3
3-
linux-i386 6ad20f6722c15a71fe7654d187dc431e26c1da6f
4-
linux-x86_64 699b4bef2eff078ae6cfaac093c580b322dc769c
5-
macos-i386 8c9d906116359bc665d8ad04ce117b9f5a8a9ae2
6-
macos-x86_64 1954f546017639f7ff4cc584120ba41c29c790d2
7-
winnt-i386 ce528f85f1470b3183c1e310452103c0c7f89751
8-
91
S 2013-11-01 8ea2123
102
freebsd-x86_64 bc7dea1ca297cfb4bd6d8a32185c6a4fddca3e6b
113
linux-i386 4b33599d160d757f6021ff05d0213fba3097dde2

branches/dist-snap/src/test/compile-fail/no_freeze-rc.rs

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

0 commit comments

Comments
 (0)