From 9776c387319f4078fb748c5f365b713d603bfc4f Mon Sep 17 00:00:00 2001 From: Matthijs 'Thiez' Hofstra Date: Wed, 20 Feb 2013 20:41:24 +0100 Subject: [PATCH] Changed a test to use intrinsics.rs and changed a few lines that were too long, had bad whitespace, etc. --- src/libcore/private.rs | 3 +- src/libcore/private/intrinsics.rs | 68 +++++++++++----------- src/libcore/vec.rs | 11 ++-- src/test/run-pass/type-use-i1-versus-i8.rs | 2 +- 4 files changed, 43 insertions(+), 41 deletions(-) diff --git a/src/libcore/private.rs b/src/libcore/private.rs index 935a04731d5..6d6fd07dc5a 100644 --- a/src/libcore/private.rs +++ b/src/libcore/private.rs @@ -127,7 +127,8 @@ struct ArcDestruct { } do task::unkillable { let data: ~ArcData = cast::reinterpret_cast(&self.data); - let new_count = intrinsics::atomic_xsub(&mut data.count, 1) - 1; + let new_count = + intrinsics::atomic_xsub(&mut data.count, 1) - 1; assert new_count >= 0; if new_count == 0 { // Were we really last, or should we hand off to an diff --git a/src/libcore/private/intrinsics.rs b/src/libcore/private/intrinsics.rs index 952ba742aa3..8f0067b7393 100644 --- a/src/libcore/private/intrinsics.rs +++ b/src/libcore/private/intrinsics.rs @@ -9,8 +9,8 @@ // except according to those terms. /*! -An attempt to move all intrinsic declarations to a single place, as mentioned in #3369 - +An attempt to move all intrinsic declarations to a single place, +as mentioned in #3369 The intrinsics are defined in librustc/middle/trans/foreign.rs. */ @@ -23,97 +23,97 @@ pub extern { pub fn atomic_xchg(dst: &mut int, src: int) -> int; pub fn atomic_xchg_acq(dst: &mut int, src: int) -> int; pub fn atomic_xchg_rel(dst: &mut int, src: int) -> int; - + pub fn atomic_xadd(dst: &mut int, src: int) -> int; pub fn atomic_xadd_acq(dst: &mut int, src: int) -> int; pub fn atomic_xadd_rel(dst: &mut int, src: int) -> int; - + pub fn atomic_xsub(dst: &mut int, src: int) -> int; pub fn atomic_xsub_acq(dst: &mut int, src: int) -> int; pub fn atomic_xsub_rel(dst: &mut int, src: int) -> int; - + pub fn size_of() -> uint; - + pub fn move_val(dst: &mut T, -src: T); pub fn move_val_init(dst: &mut T, -src: T); - + pub fn min_align_of() -> uint; pub fn pref_align_of() -> uint; - + pub fn get_tydesc() -> *(); - + pub fn init() -> T; - + pub fn forget(_: T) -> (); - // FIXME: intrinsic uses legacy modes + // XXX: intrinsic uses legacy modes fn reinterpret_cast(&&src: T) -> U; - // FIXME: intrinsic uses legacy modes + // XXX: intrinsic uses legacy modes fn addr_of(&&scr: T) -> *T; - + pub fn needs_drop() -> bool; - - // FIXME: intrinsic uses legacy modes and has reference to TyDesc + + // XXX: intrinsic uses legacy modes and has reference to TyDesc // and TyVisitor which are in librustc //fn visit_tydesc(++td: *TyDesc, &&tv: TyVisitor) -> (); - // FIXME: intrinsic uses legacy modes + // XXX: intrinsic uses legacy modes //fn frame_address(f: &once fn(*u8)); - + pub fn morestack_addr() -> *(); - + pub fn memmove32(dst: *mut u8, src: *u8, size: u32); pub fn memmove64(dst: *mut u8, src: *u8, size: u64); - + pub fn sqrtf32(x: f32) -> f32; pub fn sqrtf64(x: f64) -> f64; - + pub fn powif32(a: f32, x: i32) -> f32; pub fn powif64(a: f64, x: i32) -> f64; - + pub fn sinf32(x: f32) -> f32; pub fn sinf64(x: f64) -> f64; - + pub fn cosf32(x: f32) -> f32; pub fn cosf64(x: f64) -> f64; - + pub fn powf32(a: f32, x: f32) -> f32; pub fn powf64(a: f64, x: f64) -> f64; - + pub fn expf32(x: f32) -> f32; pub fn expf64(x: f64) -> f64; - + pub fn exp2f32(x: f32) -> f32; pub fn exp2f64(x: f64) -> f64; - + pub fn logf32(x: f32) -> f32; pub fn logf64(x: f64) -> f64; - + pub fn log10f32(x: f32) -> f32; pub fn log10f64(x: f64) -> f64; - + pub fn log2f32(x: f32) -> f32; pub fn log2f64(x: f64) -> f64; pub fn fmaf32(a: f32, b: f32, c: f32) -> f32; pub fn fmaf64(a: f64, b: f64, c: f64) -> f64; - + pub fn fabsf32(x: f32) -> f32; pub fn fabsf64(x: f64) -> f64; - + pub fn floorf32(x: f32) -> f32; pub fn floorf64(x: f64) -> f64; pub fn ceilf32(x: f32) -> f32; pub fn ceilf64(x: f64) -> f64; - + pub fn truncf32(x: f32) -> f32; pub fn truncf64(x: f64) -> f64; - + pub fn ctpop8(x: i8) -> i8; pub fn ctpop16(x: i16) -> i16; pub fn ctpop32(x: i32) -> i32; pub fn ctpop64(x: i64) -> i64; - + pub fn ctlz8(x: i8) -> i8; pub fn ctlz16(x: i16) -> i16; pub fn ctlz32(x: i32) -> i32; @@ -123,7 +123,7 @@ pub extern { pub fn cttz16(x: i16) -> i16; pub fn cttz32(x: i32) -> i32; pub fn cttz64(x: i64) -> i64; - + pub fn bswap16(x: i16) -> i16; pub fn bswap32(x: i32) -> i32; pub fn bswap64(x: i64) -> i64; diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index bbffd43d01e..6c374d6101a 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -114,7 +114,8 @@ pub pure fn from_fn(n_elts: uint, op: iter::InitOp) -> ~[T] { do as_mut_buf(v) |p, _len| { let mut i: uint = 0u; while i < n_elts { - intrinsics::move_val_init(&mut(*ptr::mut_offset(p, i)), op(i)); + intrinsics::move_val_init(&mut(*ptr::mut_offset(p, i)), + op(i)); i += 1u; } } @@ -551,7 +552,7 @@ pub fn pop(v: &mut ~[T]) -> T { } let valptr = ptr::to_mut_unsafe_ptr(&mut v[ln - 1u]); unsafe { - // FIXME #4204: Should be intrinsics::uninit() - we don't need this zeroed + // FIXME #4204: Should be uninit() - we don't need this zeroed let mut val = intrinsics::init(); val <-> *valptr; raw::set_len(v, ln - 1u); @@ -626,7 +627,7 @@ pub fn push_all_move(v: &mut ~[T], mut rhs: ~[T]) { unsafe { do as_mut_buf(rhs) |p, len| { for uint::range(0, len) |i| { - // FIXME #4204 Should be intrinsics::uninit() - don't need to zero + // FIXME #4204 Should be uninit() - don't need to zero let mut x = intrinsics::init(); x <-> *ptr::mut_offset(p, i); push(&mut *v, x); @@ -643,7 +644,7 @@ pub fn truncate(v: &mut ~[T], newlen: uint) { unsafe { // This loop is optimized out for non-drop types. for uint::range(newlen, oldlen) |i| { - // FIXME #4204 Should be intrinsics::uninit() - don't need to zero + // FIXME #4204 Should be uninit() - don't need to zero let mut dropped = intrinsics::init(); dropped <-> *ptr::mut_offset(p, i); } @@ -669,7 +670,7 @@ pub fn dedup(v: &mut ~[T]) { // last_written < next_to_read < ln if *ptr::mut_offset(p, next_to_read) == *ptr::mut_offset(p, last_written) { - // FIXME #4204 Should be intrinsics::uninit() - don't need to + // FIXME #4204 Should be uninit() - don't need to // zero let mut dropped = intrinsics::init(); dropped <-> *ptr::mut_offset(p, next_to_read); diff --git a/src/test/run-pass/type-use-i1-versus-i8.rs b/src/test/run-pass/type-use-i1-versus-i8.rs index 5f3c60c9ba5..d16b2e3e996 100644 --- a/src/test/run-pass/type-use-i1-versus-i8.rs +++ b/src/test/run-pass/type-use-i1-versus-i8.rs @@ -11,5 +11,5 @@ pub fn main() { let mut x: bool = false; // this line breaks it - vec::rusti::move_val_init(&mut x, false); + private::intrinsics::move_val_init(&mut x, false); }