#![feature(lang_items)]
#![feature(no_std)]
#![feature(nonzero)]
+#![feature(num_bits_bytes)]
#![feature(optin_builtin_traits)]
#![feature(placement_in_syntax)]
#![feature(placement_new_protocol)]
use super::oom;
use super::boxed::Box;
use core::ops::Drop;
+use core;
/// A low-level utility for more ergonomically allocating, reallocating, and deallocating a
/// a buffer of memory on the heap without having to worry about all the corner cases
// user-space. e.g. PAE or x32
#[inline]
-#[cfg(target_pointer_width = "64")]
-fn alloc_guard(_alloc_size: usize) { }
-
-#[inline]
-#[cfg(target_pointer_width = "32")]
fn alloc_guard(alloc_size: usize) {
- assert!(alloc_size <= ::core::isize::MAX as usize, "capacity overflow");
+ if core::usize::BITS < 64 {
+ assert!(alloc_size <= ::core::isize::MAX as usize, "capacity overflow");
+ }
}
f.flags |= 1 << (FlagV1::SignAwareZeroPad as u32);
if let None = f.width {
- // The formats need two extra bytes, for the 0x
- if cfg!(target_pointer_width = "32") {
- f.width = Some(10);
- } else {
- f.width = Some(18);
- }
+ f.width = Some((::usize::BITS/4) + 2);
}
}
f.flags |= 1 << (FlagV1::Alternate as u32);
#[inline]
#[stable(feature = "hasher_write", since = "1.3.0")]
fn write_usize(&mut self, i: usize) {
- if cfg!(target_pointer_width = "32") {
- self.write_u32(i as u32)
- } else {
- self.write_u64(i as u64)
- }
+ let bytes = unsafe {
+ ::slice::from_raw_parts(&i as *const usize as *const u8,
+ mem::size_of::<usize>())
+ };
+ self.write(bytes);
}
/// Write a single `i8` into this hasher.
step_impl_unsigned!(u64);
#[cfg(target_pointer_width = "64")]
step_impl_signed!(i64);
-#[cfg(target_pointer_width = "32")]
+// If the target pointer width is not 64-bits, we
+// assume here that it is less than 64-bits.
+#[cfg(not(target_pointer_width = "64"))]
step_impl_no_between!(u64 i64);
/// An adapter for stepping range iterators by a custom amount.