auto merge of #13532 : alexcrichton/rust/rollup, r=alexcrichton
This commit is contained in:
commit
349d66af94
45 changed files with 546 additions and 413 deletions
|
|
@ -88,7 +88,9 @@ pub trait Set<T>: Container {
|
|||
fn is_subset(&self, other: &Self) -> bool;
|
||||
|
||||
/// Return true if the set is a superset of another
|
||||
fn is_superset(&self, other: &Self) -> bool;
|
||||
fn is_superset(&self, other: &Self) -> bool {
|
||||
other.is_subset(self)
|
||||
}
|
||||
|
||||
// FIXME #8154: Add difference, sym. difference, intersection and union iterators
|
||||
}
|
||||
|
|
|
|||
|
|
@ -394,26 +394,50 @@ extern "rust-intrinsic" {
|
|||
|
||||
pub fn roundf32(x: f32) -> f32;
|
||||
pub fn roundf64(x: f64) -> f64;
|
||||
}
|
||||
#[cfg(not(stage0))]
|
||||
extern "rust-intrinsic" {
|
||||
pub fn ctpop8(x: u8) -> u8;
|
||||
pub fn ctpop16(x: u16) -> u16;
|
||||
pub fn ctpop32(x: u32) -> u32;
|
||||
pub fn ctpop64(x: u64) -> u64;
|
||||
|
||||
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: u8) -> u8;
|
||||
pub fn ctlz16(x: u16) -> u16;
|
||||
pub fn ctlz32(x: u32) -> u32;
|
||||
pub fn ctlz64(x: u64) -> u64;
|
||||
|
||||
pub fn ctlz8(x: i8) -> i8;
|
||||
pub fn ctlz16(x: i16) -> i16;
|
||||
pub fn ctlz32(x: i32) -> i32;
|
||||
pub fn ctlz64(x: i64) -> i64;
|
||||
pub fn cttz8(x: u8) -> u8;
|
||||
pub fn cttz16(x: u16) -> u16;
|
||||
pub fn cttz32(x: u32) -> u32;
|
||||
pub fn cttz64(x: u64) -> u64;
|
||||
|
||||
pub fn cttz8(x: i8) -> i8;
|
||||
pub fn cttz16(x: i16) -> i16;
|
||||
pub fn cttz32(x: i32) -> i32;
|
||||
pub fn cttz64(x: i64) -> i64;
|
||||
pub fn bswap16(x: u16) -> u16;
|
||||
pub fn bswap32(x: u32) -> u32;
|
||||
pub fn bswap64(x: u64) -> u64;
|
||||
}
|
||||
|
||||
pub fn bswap16(x: i16) -> i16;
|
||||
pub fn bswap32(x: i32) -> i32;
|
||||
pub fn bswap64(x: i64) -> i64;
|
||||
// NOTE: remove this after a snap, and merge the extern block above
|
||||
macro_rules! stage0_hack {
|
||||
($( $u_ty:ty, $i_ty:ty => $($name:ident),*);*) => {
|
||||
$(
|
||||
$(
|
||||
#[cfg(stage0)]
|
||||
pub unsafe fn $name(x: $u_ty) -> $u_ty {
|
||||
extern "rust-intrinsic" { fn $name(x: $i_ty) -> $i_ty; }
|
||||
$name(x as $i_ty) as $u_ty
|
||||
}
|
||||
)*)*
|
||||
}
|
||||
}
|
||||
stage0_hack! {
|
||||
u8, i8 => ctpop8, ctlz8, cttz8;
|
||||
u16, i16 => ctpop16, ctlz16, cttz16, bswap16;
|
||||
u32, i32 => ctpop32, ctlz32, cttz32, bswap32;
|
||||
u64, i64 => ctpop64, ctlz64, cttz64, bswap64
|
||||
}
|
||||
|
||||
extern "rust-intrinsic" {
|
||||
pub fn i8_add_with_overflow(x: i8, y: i8) -> (i8, bool);
|
||||
pub fn i16_add_with_overflow(x: i16, y: i16) -> (i16, bool);
|
||||
pub fn i32_add_with_overflow(x: i32, y: i32) -> (i32, bool);
|
||||
|
|
|
|||
|
|
@ -83,9 +83,9 @@ pub fn u64_to_le_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T {
|
|||
assert!(size <= 8u);
|
||||
match size {
|
||||
1u => f(&[n as u8]),
|
||||
2u => f(unsafe { transmute::<i16, [u8, ..2]>(to_le16(n as i16)) }),
|
||||
4u => f(unsafe { transmute::<i32, [u8, ..4]>(to_le32(n as i32)) }),
|
||||
8u => f(unsafe { transmute::<i64, [u8, ..8]>(to_le64(n as i64)) }),
|
||||
2u => f(unsafe { transmute::<_, [u8, ..2]>(to_le16(n as u16)) }),
|
||||
4u => f(unsafe { transmute::<_, [u8, ..4]>(to_le32(n as u32)) }),
|
||||
8u => f(unsafe { transmute::<_, [u8, ..8]>(to_le64(n)) }),
|
||||
_ => {
|
||||
|
||||
let mut bytes = vec!();
|
||||
|
|
@ -123,9 +123,9 @@ pub fn u64_to_be_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T {
|
|||
assert!(size <= 8u);
|
||||
match size {
|
||||
1u => f(&[n as u8]),
|
||||
2u => f(unsafe { transmute::<i16, [u8, ..2]>(to_be16(n as i16)) }),
|
||||
4u => f(unsafe { transmute::<i32, [u8, ..4]>(to_be32(n as i32)) }),
|
||||
8u => f(unsafe { transmute::<i64, [u8, ..8]>(to_be64(n as i64)) }),
|
||||
2u => f(unsafe { transmute::<_, [u8, ..2]>(to_be16(n as u16)) }),
|
||||
4u => f(unsafe { transmute::<_, [u8, ..4]>(to_be32(n as u32)) }),
|
||||
8u => f(unsafe { transmute::<_, [u8, ..8]>(to_be64(n)) }),
|
||||
_ => {
|
||||
let mut bytes = vec!();
|
||||
let mut i = size;
|
||||
|
|
@ -166,7 +166,7 @@ pub fn u64_from_be_bytes(data: &[u8], start: uint, size: uint) -> u64 {
|
|||
let ptr = data.as_ptr().offset(start as int);
|
||||
let out = buf.as_mut_ptr();
|
||||
copy_nonoverlapping_memory(out.offset((8 - size) as int), ptr, size);
|
||||
from_be64(*(out as *i64)) as u64
|
||||
from_be64(*(out as *u64))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ fn reset_helper(w: ~Writer:Send,
|
|||
{
|
||||
let mut t = Local::borrow(None::<Task>);
|
||||
// Be sure to flush any pending output from the writer
|
||||
match f(t.get(), w) {
|
||||
match f(&mut *t, w) {
|
||||
Some(mut w) => {
|
||||
drop(t);
|
||||
// FIXME: is failing right here?
|
||||
|
|
@ -230,9 +230,7 @@ fn with_task_stdout(f: |&mut Writer| -> IoResult<()> ) {
|
|||
// To protect against this, we do a little dance in which we
|
||||
// temporarily take the task, swap the handles, put the task in TLS,
|
||||
// and only then drop the previous handle.
|
||||
let mut t = Local::borrow(None::<Task>);
|
||||
let prev = replace(&mut t.get().stdout, my_stdout);
|
||||
drop(t);
|
||||
let prev = replace(&mut Local::borrow(None::<Task>).stdout, my_stdout);
|
||||
drop(prev);
|
||||
ret
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,128 +99,128 @@ pub unsafe fn move_val_init<T>(dst: &mut T, src: T) {
|
|||
intrinsics::move_val_init(dst, src)
|
||||
}
|
||||
|
||||
/// Convert an i16 to little endian from the target's endianness.
|
||||
/// Convert an u16 to little endian from the target's endianness.
|
||||
///
|
||||
/// On little endian, this is a no-op. On big endian, the bytes are swapped.
|
||||
#[cfg(target_endian = "little")] #[inline] pub fn to_le16(x: i16) -> i16 { x }
|
||||
#[cfg(target_endian = "little")] #[inline] pub fn to_le16(x: u16) -> u16 { x }
|
||||
|
||||
/// Convert an i16 to little endian from the target's endianness.
|
||||
/// Convert an u16 to little endian from the target's endianness.
|
||||
///
|
||||
/// On little endian, this is a no-op. On big endian, the bytes are swapped.
|
||||
#[cfg(target_endian = "big")] #[inline] pub fn to_le16(x: i16) -> i16 { unsafe { bswap16(x) } }
|
||||
#[cfg(target_endian = "big")] #[inline] pub fn to_le16(x: u16) -> u16 { unsafe { bswap16(x) } }
|
||||
|
||||
/// Convert an i32 to little endian from the target's endianness.
|
||||
/// Convert an u32 to little endian from the target's endianness.
|
||||
///
|
||||
/// On little endian, this is a no-op. On big endian, the bytes are swapped.
|
||||
#[cfg(target_endian = "little")] #[inline] pub fn to_le32(x: i32) -> i32 { x }
|
||||
#[cfg(target_endian = "little")] #[inline] pub fn to_le32(x: u32) -> u32 { x }
|
||||
|
||||
/// Convert an i32 to little endian from the target's endianness.
|
||||
/// Convert an u32 to little endian from the target's endianness.
|
||||
///
|
||||
/// On little endian, this is a no-op. On big endian, the bytes are swapped.
|
||||
#[cfg(target_endian = "big")] #[inline] pub fn to_le32(x: i32) -> i32 { unsafe { bswap32(x) } }
|
||||
#[cfg(target_endian = "big")] #[inline] pub fn to_le32(x: u32) -> u32 { unsafe { bswap32(x) } }
|
||||
|
||||
/// Convert an i64 to little endian from the target's endianness.
|
||||
/// Convert an u64 to little endian from the target's endianness.
|
||||
///
|
||||
/// On little endian, this is a no-op. On big endian, the bytes are swapped.
|
||||
#[cfg(target_endian = "little")] #[inline] pub fn to_le64(x: i64) -> i64 { x }
|
||||
#[cfg(target_endian = "little")] #[inline] pub fn to_le64(x: u64) -> u64 { x }
|
||||
|
||||
/// Convert an i64 to little endian from the target's endianness.
|
||||
/// Convert an u64 to little endian from the target's endianness.
|
||||
///
|
||||
/// On little endian, this is a no-op. On big endian, the bytes are swapped.
|
||||
#[cfg(target_endian = "big")] #[inline] pub fn to_le64(x: i64) -> i64 { unsafe { bswap64(x) } }
|
||||
#[cfg(target_endian = "big")] #[inline] pub fn to_le64(x: u64) -> u64 { unsafe { bswap64(x) } }
|
||||
|
||||
|
||||
/// Convert an i16 to big endian from the target's endianness.
|
||||
/// Convert an u16 to big endian from the target's endianness.
|
||||
///
|
||||
/// On big endian, this is a no-op. On little endian, the bytes are swapped.
|
||||
#[cfg(target_endian = "little")] #[inline] pub fn to_be16(x: i16) -> i16 { unsafe { bswap16(x) } }
|
||||
#[cfg(target_endian = "little")] #[inline] pub fn to_be16(x: u16) -> u16 { unsafe { bswap16(x) } }
|
||||
|
||||
/// Convert an i16 to big endian from the target's endianness.
|
||||
/// Convert an u16 to big endian from the target's endianness.
|
||||
///
|
||||
/// On big endian, this is a no-op. On little endian, the bytes are swapped.
|
||||
#[cfg(target_endian = "big")] #[inline] pub fn to_be16(x: i16) -> i16 { x }
|
||||
#[cfg(target_endian = "big")] #[inline] pub fn to_be16(x: u16) -> u16 { x }
|
||||
|
||||
/// Convert an i32 to big endian from the target's endianness.
|
||||
/// Convert an u32 to big endian from the target's endianness.
|
||||
///
|
||||
/// On big endian, this is a no-op. On little endian, the bytes are swapped.
|
||||
#[cfg(target_endian = "little")] #[inline] pub fn to_be32(x: i32) -> i32 { unsafe { bswap32(x) } }
|
||||
#[cfg(target_endian = "little")] #[inline] pub fn to_be32(x: u32) -> u32 { unsafe { bswap32(x) } }
|
||||
|
||||
/// Convert an i32 to big endian from the target's endianness.
|
||||
/// Convert an u32 to big endian from the target's endianness.
|
||||
///
|
||||
/// On big endian, this is a no-op. On little endian, the bytes are swapped.
|
||||
#[cfg(target_endian = "big")] #[inline] pub fn to_be32(x: i32) -> i32 { x }
|
||||
#[cfg(target_endian = "big")] #[inline] pub fn to_be32(x: u32) -> u32 { x }
|
||||
|
||||
/// Convert an i64 to big endian from the target's endianness.
|
||||
/// Convert an u64 to big endian from the target's endianness.
|
||||
///
|
||||
/// On big endian, this is a no-op. On little endian, the bytes are swapped.
|
||||
#[cfg(target_endian = "little")] #[inline] pub fn to_be64(x: i64) -> i64 { unsafe { bswap64(x) } }
|
||||
#[cfg(target_endian = "little")] #[inline] pub fn to_be64(x: u64) -> u64 { unsafe { bswap64(x) } }
|
||||
|
||||
/// Convert an i64 to big endian from the target's endianness.
|
||||
/// Convert an u64 to big endian from the target's endianness.
|
||||
///
|
||||
/// On big endian, this is a no-op. On little endian, the bytes are swapped.
|
||||
#[cfg(target_endian = "big")] #[inline] pub fn to_be64(x: i64) -> i64 { x }
|
||||
#[cfg(target_endian = "big")] #[inline] pub fn to_be64(x: u64) -> u64 { x }
|
||||
|
||||
|
||||
/// Convert an i16 from little endian to the target's endianness.
|
||||
/// Convert an u16 from little endian to the target's endianness.
|
||||
///
|
||||
/// On little endian, this is a no-op. On big endian, the bytes are swapped.
|
||||
#[cfg(target_endian = "little")] #[inline] pub fn from_le16(x: i16) -> i16 { x }
|
||||
#[cfg(target_endian = "little")] #[inline] pub fn from_le16(x: u16) -> u16 { x }
|
||||
|
||||
/// Convert an i16 from little endian to the target's endianness.
|
||||
/// Convert an u16 from little endian to the target's endianness.
|
||||
///
|
||||
/// On little endian, this is a no-op. On big endian, the bytes are swapped.
|
||||
#[cfg(target_endian = "big")] #[inline] pub fn from_le16(x: i16) -> i16 { unsafe { bswap16(x) } }
|
||||
#[cfg(target_endian = "big")] #[inline] pub fn from_le16(x: u16) -> u16 { unsafe { bswap16(x) } }
|
||||
|
||||
/// Convert an i32 from little endian to the target's endianness.
|
||||
/// Convert an u32 from little endian to the target's endianness.
|
||||
///
|
||||
/// On little endian, this is a no-op. On big endian, the bytes are swapped.
|
||||
#[cfg(target_endian = "little")] #[inline] pub fn from_le32(x: i32) -> i32 { x }
|
||||
#[cfg(target_endian = "little")] #[inline] pub fn from_le32(x: u32) -> u32 { x }
|
||||
|
||||
/// Convert an i32 from little endian to the target's endianness.
|
||||
/// Convert an u32 from little endian to the target's endianness.
|
||||
///
|
||||
/// On little endian, this is a no-op. On big endian, the bytes are swapped.
|
||||
#[cfg(target_endian = "big")] #[inline] pub fn from_le32(x: i32) -> i32 { unsafe { bswap32(x) } }
|
||||
#[cfg(target_endian = "big")] #[inline] pub fn from_le32(x: u32) -> u32 { unsafe { bswap32(x) } }
|
||||
|
||||
/// Convert an i64 from little endian to the target's endianness.
|
||||
/// Convert an u64 from little endian to the target's endianness.
|
||||
///
|
||||
/// On little endian, this is a no-op. On big endian, the bytes are swapped.
|
||||
#[cfg(target_endian = "little")] #[inline] pub fn from_le64(x: i64) -> i64 { x }
|
||||
#[cfg(target_endian = "little")] #[inline] pub fn from_le64(x: u64) -> u64 { x }
|
||||
|
||||
/// Convert an i64 from little endian to the target's endianness.
|
||||
/// Convert an u64 from little endian to the target's endianness.
|
||||
///
|
||||
/// On little endian, this is a no-op. On big endian, the bytes are swapped.
|
||||
#[cfg(target_endian = "big")] #[inline] pub fn from_le64(x: i64) -> i64 { unsafe { bswap64(x) } }
|
||||
#[cfg(target_endian = "big")] #[inline] pub fn from_le64(x: u64) -> u64 { unsafe { bswap64(x) } }
|
||||
|
||||
|
||||
/// Convert an i16 from big endian to the target's endianness.
|
||||
/// Convert an u16 from big endian to the target's endianness.
|
||||
///
|
||||
/// On big endian, this is a no-op. On little endian, the bytes are swapped.
|
||||
#[cfg(target_endian = "little")] #[inline] pub fn from_be16(x: i16) -> i16 { unsafe { bswap16(x) } }
|
||||
#[cfg(target_endian = "little")] #[inline] pub fn from_be16(x: u16) -> u16 { unsafe { bswap16(x) } }
|
||||
|
||||
/// Convert an i16 from big endian to the target's endianness.
|
||||
/// Convert an u16 from big endian to the target's endianness.
|
||||
///
|
||||
/// On big endian, this is a no-op. On little endian, the bytes are swapped.
|
||||
#[cfg(target_endian = "big")] #[inline] pub fn from_be16(x: i16) -> i16 { x }
|
||||
#[cfg(target_endian = "big")] #[inline] pub fn from_be16(x: u16) -> u16 { x }
|
||||
|
||||
/// Convert an i32 from big endian to the target's endianness.
|
||||
/// Convert an u32 from big endian to the target's endianness.
|
||||
///
|
||||
/// On big endian, this is a no-op. On little endian, the bytes are swapped.
|
||||
#[cfg(target_endian = "little")] #[inline] pub fn from_be32(x: i32) -> i32 { unsafe { bswap32(x) } }
|
||||
#[cfg(target_endian = "little")] #[inline] pub fn from_be32(x: u32) -> u32 { unsafe { bswap32(x) } }
|
||||
|
||||
/// Convert an i32 from big endian to the target's endianness.
|
||||
/// Convert an u32 from big endian to the target's endianness.
|
||||
///
|
||||
/// On big endian, this is a no-op. On little endian, the bytes are swapped.
|
||||
#[cfg(target_endian = "big")] #[inline] pub fn from_be32(x: i32) -> i32 { x }
|
||||
#[cfg(target_endian = "big")] #[inline] pub fn from_be32(x: u32) -> u32 { x }
|
||||
|
||||
/// Convert an i64 from big endian to the target's endianness.
|
||||
/// Convert an u64 from big endian to the target's endianness.
|
||||
///
|
||||
/// On big endian, this is a no-op. On little endian, the bytes are swapped.
|
||||
#[cfg(target_endian = "little")] #[inline] pub fn from_be64(x: i64) -> i64 { unsafe { bswap64(x) } }
|
||||
#[cfg(target_endian = "little")] #[inline] pub fn from_be64(x: u64) -> u64 { unsafe { bswap64(x) } }
|
||||
|
||||
/// Convert an i64 from big endian to the target's endianness.
|
||||
/// Convert an u64 from big endian to the target's endianness.
|
||||
///
|
||||
/// On big endian, this is a no-op. On little endian, the bytes are swapped.
|
||||
#[cfg(target_endian = "big")] #[inline] pub fn from_be64(x: i64) -> i64 { x }
|
||||
#[cfg(target_endian = "big")] #[inline] pub fn from_be64(x: u64) -> u64 { x }
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1037,7 +1037,7 @@ mod tests {
|
|||
assert_eq!(0f32.abs_sub(&INFINITY), 0f32);
|
||||
}
|
||||
|
||||
#[test] #[ignore(cfg(windows))] // FIXME #8663
|
||||
#[test]
|
||||
fn test_abs_sub_nowin() {
|
||||
assert!(NAN.abs_sub(&-1f32).is_nan());
|
||||
assert!(1f32.abs_sub(&NAN).is_nan());
|
||||
|
|
|
|||
|
|
@ -1041,7 +1041,7 @@ mod tests {
|
|||
assert_eq!(0f64.abs_sub(&INFINITY), 0f64);
|
||||
}
|
||||
|
||||
#[test] #[ignore(cfg(windows))] // FIXME #8663
|
||||
#[test]
|
||||
fn test_abs_sub_nowin() {
|
||||
assert!(NAN.abs_sub(&-1f64).is_nan());
|
||||
assert!(1f64.abs_sub(&NAN).is_nan());
|
||||
|
|
|
|||
|
|
@ -28,17 +28,17 @@ int_module!(i16, 16)
|
|||
impl Bitwise for i16 {
|
||||
/// Returns the number of ones in the binary representation of the number.
|
||||
#[inline]
|
||||
fn count_ones(&self) -> i16 { unsafe { intrinsics::ctpop16(*self) } }
|
||||
fn count_ones(&self) -> i16 { unsafe { intrinsics::ctpop16(*self as u16) as i16 } }
|
||||
|
||||
/// Returns the number of leading zeros in the in the binary representation
|
||||
/// of the number.
|
||||
#[inline]
|
||||
fn leading_zeros(&self) -> i16 { unsafe { intrinsics::ctlz16(*self) } }
|
||||
fn leading_zeros(&self) -> i16 { unsafe { intrinsics::ctlz16(*self as u16) as i16 } }
|
||||
|
||||
/// Returns the number of trailing zeros in the in the binary representation
|
||||
/// of the number.
|
||||
#[inline]
|
||||
fn trailing_zeros(&self) -> i16 { unsafe { intrinsics::cttz16(*self) } }
|
||||
fn trailing_zeros(&self) -> i16 { unsafe { intrinsics::cttz16(*self as u16) as i16 } }
|
||||
}
|
||||
|
||||
impl CheckedAdd for i16 {
|
||||
|
|
|
|||
|
|
@ -28,17 +28,17 @@ int_module!(i32, 32)
|
|||
impl Bitwise for i32 {
|
||||
/// Returns the number of ones in the binary representation of the number.
|
||||
#[inline]
|
||||
fn count_ones(&self) -> i32 { unsafe { intrinsics::ctpop32(*self) } }
|
||||
fn count_ones(&self) -> i32 { unsafe { intrinsics::ctpop32(*self as u32) as i32 } }
|
||||
|
||||
/// Returns the number of leading zeros in the in the binary representation
|
||||
/// of the number.
|
||||
#[inline]
|
||||
fn leading_zeros(&self) -> i32 { unsafe { intrinsics::ctlz32(*self) } }
|
||||
fn leading_zeros(&self) -> i32 { unsafe { intrinsics::ctlz32(*self as u32) as i32 } }
|
||||
|
||||
/// Returns the number of trailing zeros in the in the binary representation
|
||||
/// of the number.
|
||||
#[inline]
|
||||
fn trailing_zeros(&self) -> i32 { unsafe { intrinsics::cttz32(*self) } }
|
||||
fn trailing_zeros(&self) -> i32 { unsafe { intrinsics::cttz32(*self as u32) as i32 } }
|
||||
}
|
||||
|
||||
impl CheckedAdd for i32 {
|
||||
|
|
|
|||
|
|
@ -30,16 +30,16 @@ int_module!(i64, 64)
|
|||
impl Bitwise for i64 {
|
||||
/// Returns the number of ones in the binary representation of the number.
|
||||
#[inline]
|
||||
fn count_ones(&self) -> i64 { unsafe { intrinsics::ctpop64(*self) } }
|
||||
fn count_ones(&self) -> i64 { unsafe { intrinsics::ctpop64(*self as u64) as i64 } }
|
||||
|
||||
/// Returns the number of leading zeros in the in the binary representation
|
||||
/// of the number.
|
||||
#[inline]
|
||||
fn leading_zeros(&self) -> i64 { unsafe { intrinsics::ctlz64(*self) } }
|
||||
fn leading_zeros(&self) -> i64 { unsafe { intrinsics::ctlz64(*self as u64) as i64 } }
|
||||
|
||||
/// Counts the number of trailing zeros.
|
||||
#[inline]
|
||||
fn trailing_zeros(&self) -> i64 { unsafe { intrinsics::cttz64(*self) } }
|
||||
fn trailing_zeros(&self) -> i64 { unsafe { intrinsics::cttz64(*self as u64) as i64 } }
|
||||
}
|
||||
|
||||
impl CheckedAdd for i64 {
|
||||
|
|
|
|||
|
|
@ -28,17 +28,17 @@ int_module!(i8, 8)
|
|||
impl Bitwise for i8 {
|
||||
/// Returns the number of ones in the binary representation of the number.
|
||||
#[inline]
|
||||
fn count_ones(&self) -> i8 { unsafe { intrinsics::ctpop8(*self) } }
|
||||
fn count_ones(&self) -> i8 { unsafe { intrinsics::ctpop8(*self as u8) as i8 } }
|
||||
|
||||
/// Returns the number of leading zeros in the in the binary representation
|
||||
/// of the number.
|
||||
#[inline]
|
||||
fn leading_zeros(&self) -> i8 { unsafe { intrinsics::ctlz8(*self) } }
|
||||
fn leading_zeros(&self) -> i8 { unsafe { intrinsics::ctlz8(*self as u8) as i8 } }
|
||||
|
||||
/// Returns the number of trailing zeros in the in the binary representation
|
||||
/// of the number.
|
||||
#[inline]
|
||||
fn trailing_zeros(&self) -> i8 { unsafe { intrinsics::cttz8(*self) } }
|
||||
fn trailing_zeros(&self) -> i8 { unsafe { intrinsics::cttz8(*self as u8) as i8 } }
|
||||
}
|
||||
|
||||
impl CheckedAdd for i8 {
|
||||
|
|
|
|||
|
|
@ -1294,37 +1294,47 @@ impl Drop for MemoryMap {
|
|||
/// Various useful system-specific constants.
|
||||
pub mod consts {
|
||||
#[cfg(unix)]
|
||||
pub use os::consts::unix::*;
|
||||
pub use os::consts::unix::FAMILY;
|
||||
|
||||
#[cfg(windows)]
|
||||
pub use os::consts::windows::*;
|
||||
pub use os::consts::windows::FAMILY;
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
pub use os::consts::macos::*;
|
||||
pub use os::consts::macos::{SYSNAME, DLL_PREFIX, DLL_SUFFIX, DLL_EXTENSION};
|
||||
#[cfg(target_os = "macos")]
|
||||
pub use os::consts::macos::{EXE_SUFFIX, EXE_EXTENSION};
|
||||
|
||||
#[cfg(target_os = "freebsd")]
|
||||
pub use os::consts::freebsd::*;
|
||||
pub use os::consts::freebsd::{SYSNAME, DLL_PREFIX, DLL_SUFFIX, DLL_EXTENSION};
|
||||
#[cfg(target_os = "freebsd")]
|
||||
pub use os::consts::freebsd::{EXE_SUFFIX, EXE_EXTENSION};
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
pub use os::consts::linux::*;
|
||||
pub use os::consts::linux::{SYSNAME, DLL_PREFIX, DLL_SUFFIX, DLL_EXTENSION};
|
||||
#[cfg(target_os = "linux")]
|
||||
pub use os::consts::linux::{EXE_SUFFIX, EXE_EXTENSION};
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
pub use os::consts::android::*;
|
||||
pub use os::consts::android::{SYSNAME, DLL_PREFIX, DLL_SUFFIX, DLL_EXTENSION};
|
||||
#[cfg(target_os = "android")]
|
||||
pub use os::consts::android::{EXE_SUFFIX, EXE_EXTENSION};
|
||||
|
||||
#[cfg(target_os = "win32")]
|
||||
pub use os::consts::win32::*;
|
||||
pub use os::consts::win32::{SYSNAME, DLL_PREFIX, DLL_SUFFIX, DLL_EXTENSION};
|
||||
#[cfg(target_os = "win32")]
|
||||
pub use os::consts::win32::{EXE_SUFFIX, EXE_EXTENSION};
|
||||
|
||||
#[cfg(target_arch = "x86")]
|
||||
pub use os::consts::x86::*;
|
||||
pub use os::consts::x86::{ARCH};
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
pub use os::consts::x86_64::*;
|
||||
pub use os::consts::x86_64::{ARCH};
|
||||
|
||||
#[cfg(target_arch = "arm")]
|
||||
pub use os::consts::arm::*;
|
||||
pub use os::consts::arm::{ARCH};
|
||||
|
||||
#[cfg(target_arch = "mips")]
|
||||
pub use os::consts::mips::*;
|
||||
pub use os::consts::mips::{ARCH};
|
||||
|
||||
/// Constants for Unix systems.
|
||||
pub mod unix {
|
||||
|
|
|
|||
|
|
@ -319,8 +319,7 @@ pub unsafe fn local_free(ptr: *u8) {
|
|||
}
|
||||
|
||||
pub fn live_allocs() -> *mut Box {
|
||||
let mut task = Local::borrow(None::<Task>);
|
||||
task.get().heap.live_allocs
|
||||
Local::borrow(None::<Task>).heap.live_allocs
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
|||
|
|
@ -18,15 +18,17 @@
|
|||
#![allow(dead_code)]
|
||||
|
||||
use cast;
|
||||
use ops::Drop;
|
||||
use ops::{Drop, Deref, DerefMut};
|
||||
use ptr::RawPtr;
|
||||
|
||||
#[cfg(windows)] // mingw-w32 doesn't like thread_local things
|
||||
#[cfg(target_os = "android")] // see #10686
|
||||
pub use self::native::*;
|
||||
pub use self::native::{init, cleanup, put, take, try_take, unsafe_take, exists,
|
||||
unsafe_borrow, try_unsafe_borrow};
|
||||
|
||||
#[cfg(not(windows), not(target_os = "android"))]
|
||||
pub use self::compiled::*;
|
||||
pub use self::compiled::{init, cleanup, put, take, try_take, unsafe_take, exists,
|
||||
unsafe_borrow, try_unsafe_borrow};
|
||||
|
||||
/// Encapsulates a borrowed value. When this value goes out of scope, the
|
||||
/// pointer is returned.
|
||||
|
|
@ -48,13 +50,15 @@ impl<T> Drop for Borrowed<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> Borrowed<T> {
|
||||
pub fn get<'a>(&'a mut self) -> &'a mut T {
|
||||
unsafe {
|
||||
let val_ptr: &mut ~T = cast::transmute(&mut self.val);
|
||||
let val_ptr: &'a mut T = *val_ptr;
|
||||
val_ptr
|
||||
}
|
||||
impl<T> Deref<T> for Borrowed<T> {
|
||||
fn deref<'a>(&'a self) -> &'a T {
|
||||
unsafe { &*(self.val as *T) }
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> DerefMut<T> for Borrowed<T> {
|
||||
fn deref_mut<'a>(&'a mut self) -> &'a mut T {
|
||||
unsafe { &mut *(self.val as *mut T) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -127,8 +127,8 @@ impl Task {
|
|||
#[allow(unused_must_use)]
|
||||
fn close_outputs() {
|
||||
let mut task = Local::borrow(None::<Task>);
|
||||
let stderr = task.get().stderr.take();
|
||||
let stdout = task.get().stdout.take();
|
||||
let stderr = task.stderr.take();
|
||||
let stdout = task.stdout.take();
|
||||
drop(task);
|
||||
match stdout { Some(mut w) => { w.flush(); }, None => {} }
|
||||
match stderr { Some(mut w) => { w.flush(); }, None => {} }
|
||||
|
|
@ -159,8 +159,7 @@ impl Task {
|
|||
// be intertwined, and miraculously work for now...
|
||||
let mut task = Local::borrow(None::<Task>);
|
||||
let storage_map = {
|
||||
let task = task.get();
|
||||
let LocalStorage(ref mut optmap) = task.storage;
|
||||
let &LocalStorage(ref mut optmap) = &mut task.storage;
|
||||
optmap.take()
|
||||
};
|
||||
drop(task);
|
||||
|
|
@ -332,8 +331,7 @@ impl BlockedTask {
|
|||
}
|
||||
|
||||
/// Converts one blocked task handle to a list of many handles to the same.
|
||||
pub fn make_selectable(self, num_handles: uint) -> Take<BlockedTasks>
|
||||
{
|
||||
pub fn make_selectable(self, num_handles: uint) -> Take<BlockedTasks> {
|
||||
let arc = match self {
|
||||
Owned(task) => {
|
||||
let flag = unsafe { AtomicUint::new(cast::transmute(task)) };
|
||||
|
|
|
|||
|
|
@ -257,8 +257,8 @@ pub fn try<T:Send>(f: proc():Send -> T) -> Result<T, ~Any:Send> {
|
|||
pub fn with_task_name<U>(blk: |Option<&str>| -> U) -> U {
|
||||
use rt::task::Task;
|
||||
|
||||
let mut task = Local::borrow(None::<Task>);
|
||||
match task.get().name {
|
||||
let task = Local::borrow(None::<Task>);
|
||||
match task.name {
|
||||
Some(ref name) => blk(Some(name.as_slice())),
|
||||
None => blk(None)
|
||||
}
|
||||
|
|
@ -276,11 +276,8 @@ pub fn deschedule() {
|
|||
|
||||
pub fn failing() -> bool {
|
||||
//! True if the running task has failed
|
||||
|
||||
use rt::task::Task;
|
||||
|
||||
let mut local = Local::borrow(None::<Task>);
|
||||
local.get().unwinder.unwinding()
|
||||
Local::borrow(None::<Task>).unwinder.unwinding()
|
||||
}
|
||||
|
||||
// The following 8 tests test the following 2^3 combinations:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue