Skip to content

Commit cae68cc

Browse files
committed
---
yaml --- r: 73292 b: refs/heads/dist-snap c: 54eafc0 h: refs/heads/master v: v3
1 parent 3349f71 commit cae68cc

File tree

8 files changed

+89
-30
lines changed

8 files changed

+89
-30
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
99
refs/heads/incoming: b50030718cf28f2a5a81857a26b57442734fe854
10-
refs/heads/dist-snap: 7bd421776681285bf4dfba09fe7a6dae4c8eecd5
10+
refs/heads/dist-snap: 54eafc009d1595a04862b242fb6825f9e7b51799
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/libcore/cast.rs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,26 @@
1212
1313
use sys;
1414
use unstable;
15-
use unstable::intrinsics;
15+
16+
pub mod rusti {
17+
#[abi = "rust-intrinsic"]
18+
#[link_name = "rusti"]
19+
pub extern "rust-intrinsic" {
20+
fn forget<T>(x: T);
21+
22+
fn transmute<T,U>(e: T) -> U;
23+
}
24+
}
1625

1726
/// Casts the value at `src` to U. The two types must have the same length.
1827
pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
19-
let mut dest: U = intrinsics::init();
28+
let mut dest: U = unstable::intrinsics::init();
2029
{
21-
let dest_ptr: *mut u8 = transmute(&mut dest);
22-
let src_ptr: *u8 = transmute(src);
23-
intrinsics::memmove64(dest_ptr,
24-
src_ptr,
25-
sys::size_of::<U>() as u64);
30+
let dest_ptr: *mut u8 = rusti::transmute(&mut dest);
31+
let src_ptr: *u8 = rusti::transmute(src);
32+
unstable::intrinsics::memmove64(dest_ptr,
33+
src_ptr,
34+
sys::size_of::<U>() as u64);
2635
}
2736
dest
2837
}
@@ -36,7 +45,7 @@ pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
3645
* reinterpret_cast on pointer types.
3746
*/
3847
#[inline(always)]
39-
pub unsafe fn forget<T>(thing: T) { intrinsics::forget(thing); }
48+
pub unsafe fn forget<T>(thing: T) { rusti::forget(thing); }
4049

4150
/**
4251
* Force-increment the reference count on a shared box. If used
@@ -56,7 +65,7 @@ pub unsafe fn bump_box_refcount<T>(t: @T) { forget(t); }
5665
*/
5766
#[inline(always)]
5867
pub unsafe fn transmute<L, G>(thing: L) -> G {
59-
intrinsics::transmute(thing)
68+
rusti::transmute(thing)
6069
}
6170

6271
/// Coerce an immutable reference to be mutable.

branches/dist-snap/src/libcore/stackwalk.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#[doc(hidden)]; // FIXME #3538
1212

1313
use cast::transmute;
14-
use unstable::intrinsics;
1514

1615
pub type Word = uint;
1716

@@ -76,6 +75,13 @@ fn test_simple_deep() {
7675

7776
fn frame_address(f: &fn(x: *u8)) {
7877
unsafe {
79-
intrinsics::frame_address(f)
78+
rusti::frame_address(f)
79+
}
80+
}
81+
82+
pub mod rusti {
83+
#[abi = "rust-intrinsic"]
84+
pub extern "rust-intrinsic" {
85+
pub fn frame_address(f: &once fn(x: *u8));
8086
}
8187
}

branches/dist-snap/src/libcore/sys.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use libc;
1919
use libc::{c_void, c_char, size_t};
2020
use repr;
2121
use str;
22-
use unstable::intrinsics;
2322

2423
pub type FreeGlue<'self> = &'self fn(*TypeDesc, *c_void);
2524

@@ -39,6 +38,16 @@ pub struct Closure {
3938
env: *(),
4039
}
4140

41+
pub mod rusti {
42+
#[abi = "rust-intrinsic"]
43+
pub extern "rust-intrinsic" {
44+
fn get_tydesc<T>() -> *();
45+
fn size_of<T>() -> uint;
46+
fn pref_align_of<T>() -> uint;
47+
fn min_align_of<T>() -> uint;
48+
}
49+
}
50+
4251
pub mod rustrt {
4352
use libc::{c_char, size_t};
4453

@@ -72,7 +81,7 @@ pub fn shape_le<T:Ord>(x1: &T, x2: &T) -> bool {
7281
*/
7382
#[inline(always)]
7483
pub fn get_type_desc<T>() -> *TypeDesc {
75-
unsafe { intrinsics::get_tydesc::<T>() as *TypeDesc }
84+
unsafe { rusti::get_tydesc::<T>() as *TypeDesc }
7685
}
7786

7887
/// Returns a pointer to a type descriptor.
@@ -84,7 +93,7 @@ pub fn get_type_desc_val<T>(_val: &T) -> *TypeDesc {
8493
/// Returns the size of a type
8594
#[inline(always)]
8695
pub fn size_of<T>() -> uint {
87-
unsafe { intrinsics::size_of::<T>() }
96+
unsafe { rusti::size_of::<T>() }
8897
}
8998

9099
/// Returns the size of the type that `_val` points to
@@ -119,7 +128,7 @@ pub fn nonzero_size_of_val<T>(_val: &T) -> uint {
119128
*/
120129
#[inline(always)]
121130
pub fn min_align_of<T>() -> uint {
122-
unsafe { intrinsics::min_align_of::<T>() }
131+
unsafe { rusti::min_align_of::<T>() }
123132
}
124133

125134
/// Returns the ABI-required minimum alignment of the type of the value that
@@ -132,7 +141,7 @@ pub fn min_align_of_val<T>(_val: &T) -> uint {
132141
/// Returns the preferred alignment of a type
133142
#[inline(always)]
134143
pub fn pref_align_of<T>() -> uint {
135-
unsafe { intrinsics::pref_align_of::<T>() }
144+
unsafe { rusti::pref_align_of::<T>() }
136145
}
137146

138147
/// Returns the preferred alignment of the type of the value that

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,15 @@ pub extern "rust-intrinsic" {
114114
/// `forget` is unsafe because the caller is responsible for
115115
/// ensuring the argument is deallocated already.
116116
pub unsafe fn forget<T>(_: T) -> ();
117-
pub fn transmute<T,U>(e: T) -> U;
118117

119118
/// Returns `true` if a type requires drop glue.
120119
pub fn needs_drop<T>() -> bool;
121120

122121
// XXX: intrinsic uses legacy modes and has reference to TyDesc
123122
// and TyVisitor which are in librustc
124123
//fn visit_tydesc(++td: *TyDesc, &&tv: TyVisitor) -> ();
125-
126-
pub fn frame_address(f: &once fn(*u8));
124+
// XXX: intrinsic uses legacy modes
125+
//fn frame_address(f: &once fn(*u8));
127126

128127
/// Get the address of the `__morestack` stack growth function.
129128
pub fn morestack_addr() -> *();

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

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -8,9 +8,33 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
/**
11+
/*!
1212
* Concurrency-enabled mechanisms for sharing mutable and/or immutable state
1313
* between tasks.
14+
*
15+
* # Example
16+
*
17+
* In this example, a large vector of floats is shared between several tasks.
18+
* With simple pipes, without ARC, a copy would have to be made for each task.
19+
*
20+
* ~~~
21+
* extern mod std;
22+
* use std::arc;
23+
* let numbers=vec::from_fn(100, |ind| (ind as float)*rand::random());
24+
* let shared_numbers=arc::ARC(numbers);
25+
*
26+
* for 10.times {
27+
* let (port, chan) = stream();
28+
* chan.send(shared_numbers.clone());
29+
*
30+
* do spawn {
31+
* let shared_numbers=port.recv();
32+
* let local_numbers=shared_numbers.get();
33+
*
34+
* // Work with the local numbers
35+
* }
36+
* }
37+
* ~~~
1438
*/
1539

1640
use sync;
@@ -21,7 +45,7 @@ use core::unstable::sync::UnsafeAtomicRcBox;
2145
use core::ptr;
2246
use core::task;
2347

24-
/// As sync::condvar, a mechanism for unlock-and-descheduling and signalling.
48+
/// As sync::condvar, a mechanism for unlock-and-descheduling and signaling.
2549
pub struct Condvar<'self> {
2650
is_mutex: bool,
2751
failed: &'self mut bool,
@@ -93,9 +117,14 @@ pub fn ARC<T:Const + Owned>(data: T) -> ARC<T> {
93117
* wrapper.
94118
*/
95119
pub fn get<'a, T:Const + Owned>(rc: &'a ARC<T>) -> &'a T {
96-
unsafe { &*rc.x.get_immut() }
120+
rc.get()
97121
}
98122

123+
impl<T:Const+Owned> ARC<T> {
124+
pub fn get<'a>(&'a self) -> &'a T {
125+
unsafe { &*self.x.get_immut() }
126+
}
127+
}
99128
/**
100129
* Duplicate an atomically reference counted wrapper.
101130
*
@@ -508,6 +537,7 @@ mod tests {
508537
c.send(arc::clone(&arc_v));
509538

510539
assert_eq!((*arc::get(&arc_v))[2], 3);
540+
assert_eq!(arc_v.get()[4], 5);
511541

512542
info!(arc_v);
513543
}

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,14 @@ use core::sys::TypeDesc;
4343
use core::sys;
4444
use core::uint;
4545
use core::vec;
46-
use core::unstable::intrinsics;
46+
47+
pub mod rusti {
48+
#[abi = "rust-intrinsic"]
49+
pub extern "rust-intrinsic" {
50+
fn move_val_init<T>(dst: &mut T, src: T);
51+
fn needs_drop<T>() -> bool;
52+
}
53+
}
4754

4855
pub mod rustrt {
4956
use core::libc::size_t;
@@ -201,7 +208,7 @@ pub impl Arena {
201208
let tydesc = sys::get_type_desc::<T>();
202209
let ptr = self.alloc_pod_inner((*tydesc).size, (*tydesc).align);
203210
let ptr: *mut T = transmute(ptr);
204-
intrinsics::move_val_init(&mut (*ptr), op());
211+
rusti::move_val_init(&mut (*ptr), op());
205212
return transmute(ptr);
206213
}
207214
}
@@ -254,7 +261,7 @@ pub impl Arena {
254261
// has *not* been initialized yet.
255262
*ty_ptr = transmute(tydesc);
256263
// Actually initialize it
257-
intrinsics::move_val_init(&mut(*ptr), op());
264+
rusti::move_val_init(&mut(*ptr), op());
258265
// Now that we are done, update the tydesc to indicate that
259266
// the object is there.
260267
*ty_ptr = bitpack_tydesc_ptr(tydesc, true);
@@ -269,7 +276,7 @@ pub impl Arena {
269276
unsafe {
270277
// XXX: Borrow check
271278
let this = transmute_mut_region(self);
272-
if !intrinsics::needs_drop::<T>() {
279+
if !rusti::needs_drop::<T>() {
273280
return this.alloc_pod(op);
274281
}
275282
// XXX: Borrow check

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111
//! A priority queue implemented with a binary heap
1212
1313
use core::old_iter::BaseIter;
14-
use core::unstable::intrinsics::{move_val_init, init};
15-
use core::unstable::intrinsics::uninit;
1614
use core::util::{replace, swap};
15+
use core::unstable::intrinsics::{init, move_val_init};
1716

1817
pub struct PriorityQueue<T> {
1918
priv data: ~[T],

0 commit comments

Comments
 (0)