Skip to content

Commit fc87167

Browse files
committed
---
yaml --- r: 46447 b: refs/heads/auto c: c0defda h: refs/heads/master i: 46445: fd7baa7 46443: 2d2886f 46439: 5e6ca8f 46431: 4211167 v: v3
1 parent 9ccf383 commit fc87167

File tree

28 files changed

+154
-252
lines changed

28 files changed

+154
-252
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: 3792eb2a3847f7891a7d3a1941aa7833626baa5c
17+
refs/heads/auto: c0defda4994b2cf292901c24bef88b37a088861e

branches/auto/doc/tutorial.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2072,12 +2072,12 @@ on values of type `T` inside the function. It will also cause a
20722072
compile-time error when anyone tries to call `print_all` on an array
20732073
whose element type does not have a `Printable` implementation.
20742074

2075-
Type parameters can have multiple bounds by separating them with spaces,
2075+
Type parameters can have multiple bounds by separating them with `+`,
20762076
as in this version of `print_all` that copies elements.
20772077

20782078
~~~
20792079
# trait Printable { fn print(&self); }
2080-
fn print_all<T: Printable Copy>(printable_things: ~[T]) {
2080+
fn print_all<T: Printable + Copy>(printable_things: ~[T]) {
20812081
let mut i = 0;
20822082
while i < printable_things.len() {
20832083
let copy_of_thing = printable_things[i];

branches/auto/src/libcore/at_vec.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ pub extern mod rustrt {
3030
++n: libc::size_t);
3131
}
3232

33+
#[abi = "rust-intrinsic"]
34+
pub extern mod rusti {
35+
pub fn move_val_init<T>(dst: &mut T, -src: T);
36+
}
37+
3338
/// Returns the number of elements the vector can hold without reallocating
3439
#[inline(always)]
3540
pub pure fn capacity<T>(v: @[const T]) -> uint {
@@ -180,10 +185,9 @@ pub mod traits {
180185
pub mod traits {}
181186

182187
pub mod raw {
183-
use at_vec::{capacity, rustrt};
188+
use at_vec::{capacity, rusti, rustrt};
184189
use cast::transmute;
185190
use libc;
186-
use private::intrinsics::{move_val_init};
187191
use ptr::addr_of;
188192
use ptr;
189193
use sys;
@@ -225,7 +229,7 @@ pub mod raw {
225229
(**repr).unboxed.fill += sys::size_of::<T>();
226230
let p = addr_of(&((**repr).unboxed.data));
227231
let p = ptr::offset(p, fill) as *mut T;
228-
move_val_init(&mut(*p), initval);
232+
rusti::move_val_init(&mut(*p), initval);
229233
}
230234

231235
pub unsafe fn push_slow<T>(v: &mut @[const T], initval: T) {

branches/auto/src/libcore/core.rc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,6 @@ pub const debug : u32 = 4_u32;
225225
// The runtime interface used by the compiler
226226
#[cfg(notest)] pub mod rt;
227227
// The runtime and compiler interface to fmt!
228-
#[cfg(stage0)]
229-
#[path = "private/extfmt.rs"]
230228
pub mod extfmt;
231229
// Private APIs
232230
pub mod private;

branches/auto/src/libcore/num/f32.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use num::strconv;
1818
use num;
1919
use ops;
2020
use option::Option;
21-
use private::intrinsics::floorf32;
2221
use from_str;
2322
use to_str;
2423

@@ -333,6 +332,11 @@ impl ops::Neg<f32> for f32 {
333332
pure fn neg(&self) -> f32 { -*self }
334333
}
335334

335+
#[abi="rust-intrinsic"]
336+
pub extern {
337+
fn floorf32(val: f32) -> f32;
338+
}
339+
336340
impl num::Round for f32 {
337341
#[inline(always)]
338342
pure fn round(&self, mode: num::RoundMode) -> f32 {

branches/auto/src/libcore/num/f64.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use num::strconv;
1919
use num;
2020
use ops;
2121
use option::Option;
22-
use private::intrinsics::floorf64;
2322
use to_str;
2423
use from_str;
2524

@@ -358,6 +357,11 @@ impl ops::Neg<f64> for f64 {
358357
pure fn neg(&self) -> f64 { -*self }
359358
}
360359

360+
#[abi="rust-intrinsic"]
361+
pub extern {
362+
fn floorf64(val: f64) -> f64;
363+
}
364+
361365
impl num::Round for f64 {
362366
#[inline(always)]
363367
pure fn round(&self, mode: num::RoundMode) -> f64 {

branches/auto/src/libcore/pipes.rs

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ use libc;
9292
use option;
9393
use option::{None, Option, Some, unwrap};
9494
use pipes;
95-
use private::intrinsics;
9695
use ptr;
9796
use private;
9897
use task;
@@ -257,26 +256,37 @@ pub fn entangle_buffer<T:Owned,Tstart:Owned>(
257256
(SendPacketBuffered(p), RecvPacketBuffered(p))
258257
}
259258

259+
#[abi = "rust-intrinsic"]
260+
#[doc(hidden)]
261+
extern mod rusti {
262+
fn atomic_xchg(dst: &mut int, src: int) -> int;
263+
fn atomic_xchg_acq(dst: &mut int, src: int) -> int;
264+
fn atomic_xchg_rel(dst: &mut int, src: int) -> int;
265+
266+
fn atomic_xadd_acq(dst: &mut int, src: int) -> int;
267+
fn atomic_xsub_rel(dst: &mut int, src: int) -> int;
268+
}
269+
260270
// If I call the rusti versions directly from a polymorphic function,
261271
// I get link errors. This is a bug that needs investigated more.
262272
#[doc(hidden)]
263273
pub fn atomic_xchng_rel(dst: &mut int, src: int) -> int {
264274
unsafe {
265-
intrinsics::atomic_xchg_rel(dst, src)
275+
rusti::atomic_xchg_rel(dst, src)
266276
}
267277
}
268278

269279
#[doc(hidden)]
270280
pub fn atomic_add_acq(dst: &mut int, src: int) -> int {
271281
unsafe {
272-
intrinsics::atomic_xadd_acq(dst, src)
282+
rusti::atomic_xadd_acq(dst, src)
273283
}
274284
}
275285

276286
#[doc(hidden)]
277287
pub fn atomic_sub_rel(dst: &mut int, src: int) -> int {
278288
unsafe {
279-
intrinsics::atomic_xsub_rel(dst, src)
289+
rusti::atomic_xsub_rel(dst, src)
280290
}
281291
}
282292

@@ -285,7 +295,7 @@ pub fn swap_task(dst: &mut *rust_task, src: *rust_task) -> *rust_task {
285295
// It might be worth making both acquire and release versions of
286296
// this.
287297
unsafe {
288-
transmute(intrinsics::atomic_xchg(transmute(dst), src as int))
298+
transmute(rusti::atomic_xchg(transmute(dst), src as int))
289299
}
290300
}
291301

@@ -325,14 +335,14 @@ fn wait_event(this: *rust_task) -> *libc::c_void {
325335
#[doc(hidden)]
326336
fn swap_state_acq(dst: &mut State, src: State) -> State {
327337
unsafe {
328-
transmute(intrinsics::atomic_xchg_acq(transmute(dst), src as int))
338+
transmute(rusti::atomic_xchg_acq(transmute(dst), src as int))
329339
}
330340
}
331341
332342
#[doc(hidden)]
333343
fn swap_state_rel(dst: &mut State, src: State) -> State {
334344
unsafe {
335-
transmute(intrinsics::atomic_xchg_rel(transmute(dst), src as int))
345+
transmute(rusti::atomic_xchg_rel(transmute(dst), src as int))
336346
}
337347
}
338348
@@ -1203,8 +1213,8 @@ pub trait Select2<T:Owned,U:Owned> {
12031213
12041214
impl<T: Owned,
12051215
U: Owned,
1206-
Left: Selectable GenericPort<T>,
1207-
Right: Selectable GenericPort<U>>
1216+
Left: Selectable + GenericPort<T>,
1217+
Right: Selectable + GenericPort<U>>
12081218
Select2<T,U> for (Left, Right) {
12091219
fn select() -> Either<T, U> {
12101220
match self {

branches/auto/src/libcore/prelude.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ pub use char;
5252
pub use cmp;
5353
pub use dvec;
5454
pub use either;
55+
pub use extfmt;
5556
pub use f32;
5657
pub use f64;
5758
pub use float;

branches/auto/src/libcore/private.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ pub mod finally;
3232
pub mod weak_task;
3333
#[path = "private/exchange_alloc.rs"]
3434
pub mod exchange_alloc;
35-
#[path = "private/intrinsics.rs"]
36-
pub mod intrinsics;
37-
#[path = "private/extfmt.rs"]
38-
pub mod extfmt;
3935

4036
extern mod rustrt {
4137
pub unsafe fn rust_create_little_lock() -> rust_little_lock;
@@ -47,6 +43,13 @@ extern mod rustrt {
4743
pub unsafe fn rust_raw_thread_join_delete(thread: *raw_thread);
4844
}
4945

46+
#[abi = "rust-intrinsic"]
47+
extern mod rusti {
48+
fn atomic_cxchg(dst: &mut int, old: int, src: int) -> int;
49+
fn atomic_xadd(dst: &mut int, src: int) -> int;
50+
fn atomic_xsub(dst: &mut int, src: int) -> int;
51+
}
52+
5053
#[allow(non_camel_case_types)] // runtime type
5154
type raw_thread = libc::c_void;
5255

@@ -98,7 +101,7 @@ fn test_run_in_bare_thread_exchange() {
98101

99102
fn compare_and_swap(address: &mut int, oldval: int, newval: int) -> bool {
100103
unsafe {
101-
let old = intrinsics::atomic_cxchg(address, oldval, newval);
104+
let old = rusti::atomic_cxchg(address, oldval, newval);
102105
old == oldval
103106
}
104107
}
@@ -129,8 +132,7 @@ struct ArcDestruct<T> {
129132
}
130133
do task::unkillable {
131134
let data: ~ArcData<T> = cast::reinterpret_cast(&self.data);
132-
let new_count =
133-
intrinsics::atomic_xsub(&mut data.count, 1) - 1;
135+
let new_count = rusti::atomic_xsub(&mut data.count, 1) - 1;
134136
assert new_count >= 0;
135137
if new_count == 0 {
136138
// Were we really last, or should we hand off to an
@@ -203,7 +205,7 @@ pub unsafe fn unwrap_shared_mutable_state<T:Owned>(rc: SharedMutableState<T>)
203205
// Got in. Step 0: Tell destructor not to run. We are now it.
204206
rc.data = ptr::null();
205207
// Step 1 - drop our own reference.
206-
let new_count = intrinsics::atomic_xsub(&mut ptr.count, 1) - 1;
208+
let new_count = rusti::atomic_xsub(&mut ptr.count, 1) - 1;
207209
//assert new_count >= 0;
208210
if new_count == 0 {
209211
// We were the last owner. Can unwrap immediately.
@@ -282,7 +284,7 @@ pub unsafe fn clone_shared_mutable_state<T:Owned>(rc: &SharedMutableState<T>)
282284
-> SharedMutableState<T> {
283285
unsafe {
284286
let ptr: ~ArcData<T> = cast::reinterpret_cast(&(*rc).data);
285-
let new_count = intrinsics::atomic_xadd(&mut ptr.count, 1) + 1;
287+
let new_count = rusti::atomic_xadd(&mut ptr.count, 1) + 1;
286288
assert new_count >= 2;
287289
cast::forget(ptr);
288290
}

branches/auto/src/libcore/private/at_exit.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ fn exit_runner(exit_fns: *ExitFunctions) {
7070
}
7171
}
7272

73+
#[abi = "rust-intrinsic"]
74+
pub extern mod rusti {
75+
fn move_val_init<T>(dst: &mut T, -src: T);
76+
fn init<T>() -> T;
77+
}
78+
7379
#[test]
7480
fn test_at_exit() {
7581
let i = 10;

branches/auto/src/libcore/private/exchange_alloc.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use c_malloc = libc::malloc;
1414
use c_free = libc::free;
1515
use managed::raw::{BoxHeaderRepr, BoxRepr};
1616
use cast::transmute;
17-
use private::intrinsics::{atomic_xadd,atomic_xsub};
1817
use ptr::null;
1918
use intrinsic::TyDesc;
2019

@@ -36,15 +35,15 @@ pub unsafe fn malloc(td: *TypeDesc, size: uint) -> *c_void {
3635
box.header.next = null();
3736

3837
let exchange_count = &mut *rust_get_exchange_count_ptr();
39-
atomic_xadd(exchange_count, 1);
38+
rusti::atomic_xadd(exchange_count, 1);
4039

4140
return transmute(box);
4241
}
4342
}
4443

4544
pub unsafe fn free(ptr: *c_void) {
4645
let exchange_count = &mut *rust_get_exchange_count_ptr();
47-
atomic_xsub(exchange_count, 1);
46+
rusti::atomic_xsub(exchange_count, 1);
4847

4948
assert ptr.is_not_null();
5049
c_free(ptr);
@@ -69,3 +68,8 @@ extern {
6968
fn rust_get_exchange_count_ptr() -> *mut int;
7069
}
7170

71+
#[abi = "rust-intrinsic"]
72+
extern mod rusti {
73+
fn atomic_xadd(dst: &mut int, src: int) -> int;
74+
fn atomic_xsub(dst: &mut int, src: int) -> int;
75+
}

branches/auto/src/libcore/private/global.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ use private::{Exclusive, exclusive};
3636
use private::{SharedMutableState, shared_mutable_state};
3737
use private::{get_shared_immutable_state};
3838
use private::at_exit::at_exit;
39-
use private::intrinsics::atomic_cxchg;
4039
use hashmap::linear::LinearMap;
4140
use sys::Closure;
4241
use task::spawn;
@@ -232,6 +231,11 @@ extern {
232231
fn rust_get_global_data_ptr() -> *mut int;
233232
}
234233

234+
#[abi = "rust-intrinsic"]
235+
extern {
236+
fn atomic_cxchg(dst: &mut int, old: int, src: int) -> int;
237+
}
238+
235239
#[test]
236240
fn test_clone_rc() {
237241
type MyType = SharedMutableState<int>;

0 commit comments

Comments
 (0)