about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-08-15 19:10:40 +0000
committerbors <bors@rust-lang.org>2015-08-15 19:10:40 +0000
commitf05b22efb5e739b92b47527d29c5fa903f7e64b6 (patch)
tree8195c04753eb184726a2733d8a32d4cb84f5e71b /src/liballoc
parent753a6a9e29d4c8b4ee92345051fef61908c276b6 (diff)
parentea7768c2dd8089cc3c3dc1e27158cf1bed277308 (diff)
downloadrust-f05b22efb5e739b92b47527d29c5fa903f7e64b6.tar.gz
rust-f05b22efb5e739b92b47527d29c5fa903f7e64b6.zip
Auto merge of #27845 - dylanmckay:abstract-pointer-size-away, r=alexcrichton
This patch rewrites code in several places which assume that the current target has either 32-bit or 64-bit pointers so that it can support arbitrary-width pointers.

It does not completely remove all assumptions of pointer width, but it does reduce them significantly. There is a discussion [here](https://internals.rust-lang.org/t/adding-16-bit-pointer-support/2484/10) about the change.
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/lib.rs1
-rw-r--r--src/liballoc/raw_vec.rs10
2 files changed, 5 insertions, 6 deletions
diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs
index ca86850f5df..2db9cc7c4d8 100644
--- a/src/liballoc/lib.rs
+++ b/src/liballoc/lib.rs
@@ -83,6 +83,7 @@
 #![feature(lang_items)]
 #![feature(no_std)]
 #![feature(nonzero)]
+#![feature(num_bits_bytes)]
 #![feature(optin_builtin_traits)]
 #![feature(placement_in_syntax)]
 #![feature(placement_new_protocol)]
diff --git a/src/liballoc/raw_vec.rs b/src/liballoc/raw_vec.rs
index 9311f44d9df..97acd0db524 100644
--- a/src/liballoc/raw_vec.rs
+++ b/src/liballoc/raw_vec.rs
@@ -15,6 +15,7 @@ use heap;
 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
@@ -443,11 +444,8 @@ impl<T> Drop for RawVec<T> {
 // 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");
+    }
 }