Skip to content

Commit

Permalink
int/uint => isize/usize in liblibc/liballoc/libarena
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Feb 9, 2015
1 parent bfdcd34 commit 6a2bad3
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 103 deletions.
8 changes: 4 additions & 4 deletions src/liballoc/arc.rs
Expand Up @@ -206,12 +206,12 @@ impl<T> Arc<T> {
/// Get the number of weak references to this value.
#[inline]
#[unstable(feature = "alloc")]
pub fn weak_count<T>(this: &Arc<T>) -> uint { this.inner().weak.load(SeqCst) - 1 }
pub fn weak_count<T>(this: &Arc<T>) -> usize { this.inner().weak.load(SeqCst) - 1 }

/// Get the number of strong references to this value.
#[inline]
#[unstable(feature = "alloc")]
pub fn strong_count<T>(this: &Arc<T>) -> uint { this.inner().strong.load(SeqCst) }
pub fn strong_count<T>(this: &Arc<T>) -> usize { this.inner().strong.load(SeqCst) }

#[stable(feature = "rust1", since = "1.0.0")]
impl<T> Clone for Arc<T> {
Expand Down Expand Up @@ -649,7 +649,7 @@ mod tests {
let (tx, rx) = channel();

let _t = Thread::spawn(move || {
let arc_v: Arc<Vec<int>> = rx.recv().unwrap();
let arc_v: Arc<Vec<i32>> = rx.recv().unwrap();
assert_eq!((*arc_v)[3], 4);
});

Expand Down Expand Up @@ -818,5 +818,5 @@ mod tests {

// Make sure deriving works with Arc<T>
#[derive(Eq, Ord, PartialEq, PartialOrd, Clone, Debug, Default)]
struct Foo { inner: Arc<int> }
struct Foo { inner: Arc<i32> }
}
10 changes: 5 additions & 5 deletions src/liballoc/boxed_test.rs
Expand Up @@ -22,7 +22,7 @@ use std::boxed::BoxAny;
#[test]
fn test_owned_clone() {
let a = Box::new(5);
let b: Box<int> = a.clone();
let b: Box<i32> = a.clone();
assert!(a == b);
}

Expand All @@ -31,11 +31,11 @@ struct Test;

#[test]
fn any_move() {
let a = Box::new(8us) as Box<Any>;
let a = Box::new(8) as Box<Any>;
let b = Box::new(Test) as Box<Any>;

match a.downcast::<uint>() {
Ok(a) => { assert!(a == Box::new(8us)); }
match a.downcast::<i32>() {
Ok(a) => { assert!(a == Box::new(8)); }
Err(..) => panic!()
}
match b.downcast::<Test>() {
Expand All @@ -47,7 +47,7 @@ fn any_move() {
let b = Box::new(Test) as Box<Any>;

assert!(a.downcast::<Box<Test>>().is_err());
assert!(b.downcast::<Box<uint>>().is_err());
assert!(b.downcast::<Box<i32>>().is_err());
}

#[test]
Expand Down
87 changes: 44 additions & 43 deletions src/liballoc/heap.rs
Expand Up @@ -21,7 +21,7 @@ use core::ptr::PtrExt;
/// power of 2. The alignment must be no larger than the largest supported page
/// size on the platform.
#[inline]
pub unsafe fn allocate(size: uint, align: uint) -> *mut u8 {
pub unsafe fn allocate(size: usize, align: usize) -> *mut u8 {
imp::allocate(size, align)
}

Expand All @@ -37,7 +37,7 @@ pub unsafe fn allocate(size: uint, align: uint) -> *mut u8 {
/// create the allocation referenced by `ptr`. The `old_size` parameter may be
/// any value in range_inclusive(requested_size, usable_size).
#[inline]
pub unsafe fn reallocate(ptr: *mut u8, old_size: uint, size: uint, align: uint) -> *mut u8 {
pub unsafe fn reallocate(ptr: *mut u8, old_size: usize, size: usize, align: usize) -> *mut u8 {
imp::reallocate(ptr, old_size, size, align)
}

Expand All @@ -54,7 +54,8 @@ pub unsafe fn reallocate(ptr: *mut u8, old_size: uint, size: uint, align: uint)
/// create the allocation referenced by `ptr`. The `old_size` parameter may be
/// any value in range_inclusive(requested_size, usable_size).
#[inline]
pub unsafe fn reallocate_inplace(ptr: *mut u8, old_size: uint, size: uint, align: uint) -> uint {
pub unsafe fn reallocate_inplace(ptr: *mut u8, old_size: usize, size: usize,
align: usize) -> usize {
imp::reallocate_inplace(ptr, old_size, size, align)
}

Expand All @@ -66,14 +67,14 @@ pub unsafe fn reallocate_inplace(ptr: *mut u8, old_size: uint, size: uint, align
/// create the allocation referenced by `ptr`. The `old_size` parameter may be
/// any value in range_inclusive(requested_size, usable_size).
#[inline]
pub unsafe fn deallocate(ptr: *mut u8, old_size: uint, align: uint) {
pub unsafe fn deallocate(ptr: *mut u8, old_size: usize, align: usize) {
imp::deallocate(ptr, old_size, align)
}

/// Returns the usable size of an allocation created with the specified the
/// `size` and `align`.
#[inline]
pub fn usable_size(size: uint, align: uint) -> uint {
pub fn usable_size(size: usize, align: usize) -> usize {
imp::usable_size(size, align)
}

Expand All @@ -96,7 +97,7 @@ pub const EMPTY: *mut () = 0x1 as *mut ();
#[cfg(not(test))]
#[lang="exchange_malloc"]
#[inline]
unsafe fn exchange_malloc(size: uint, align: uint) -> *mut u8 {
unsafe fn exchange_malloc(size: usize, align: usize) -> *mut u8 {
if size == 0 {
EMPTY as *mut u8
} else {
Expand All @@ -109,7 +110,7 @@ unsafe fn exchange_malloc(size: uint, align: uint) -> *mut u8 {
#[cfg(not(test))]
#[lang="exchange_free"]
#[inline]
unsafe fn exchange_free(ptr: *mut u8, old_size: uint, align: uint) {
unsafe fn exchange_free(ptr: *mut u8, old_size: usize, align: usize) {
deallocate(ptr, old_size, align);
}

Expand All @@ -122,49 +123,49 @@ unsafe fn exchange_free(ptr: *mut u8, old_size: uint, align: uint) {
target_arch = "mips",
target_arch = "mipsel",
target_arch = "powerpc")))]
const MIN_ALIGN: uint = 8;
const MIN_ALIGN: usize = 8;
#[cfg(all(not(feature = "external_funcs"),
not(feature = "external_crate"),
any(target_arch = "x86",
target_arch = "x86_64",
target_arch = "aarch64")))]
const MIN_ALIGN: uint = 16;
const MIN_ALIGN: usize = 16;

#[cfg(feature = "external_funcs")]
mod imp {
extern {
fn rust_allocate(size: uint, align: uint) -> *mut u8;
fn rust_deallocate(ptr: *mut u8, old_size: uint, align: uint);
fn rust_reallocate(ptr: *mut u8, old_size: uint, size: uint, align: uint) -> *mut u8;
fn rust_reallocate_inplace(ptr: *mut u8, old_size: uint, size: uint,
align: uint) -> uint;
fn rust_usable_size(size: uint, align: uint) -> uint;
fn rust_allocate(size: usize, align: usize) -> *mut u8;
fn rust_deallocate(ptr: *mut u8, old_size: usize, align: usize);
fn rust_reallocate(ptr: *mut u8, old_size: usize, size: usize, align: usize) -> *mut u8;
fn rust_reallocate_inplace(ptr: *mut u8, old_size: usize, size: usize,
align: usize) -> usize;
fn rust_usable_size(size: usize, align: usize) -> usize;
fn rust_stats_print();
}

#[inline]
pub unsafe fn allocate(size: uint, align: uint) -> *mut u8 {
pub unsafe fn allocate(size: usize, align: usize) -> *mut u8 {
rust_allocate(size, align)
}

#[inline]
pub unsafe fn deallocate(ptr: *mut u8, old_size: uint, align: uint) {
pub unsafe fn deallocate(ptr: *mut u8, old_size: usize, align: usize) {
rust_deallocate(ptr, old_size, align)
}

#[inline]
pub unsafe fn reallocate(ptr: *mut u8, old_size: uint, size: uint, align: uint) -> *mut u8 {
pub unsafe fn reallocate(ptr: *mut u8, old_size: usize, size: usize, align: usize) -> *mut u8 {
rust_reallocate(ptr, old_size, size, align)
}

#[inline]
pub unsafe fn reallocate_inplace(ptr: *mut u8, old_size: uint, size: uint,
align: uint) -> uint {
pub unsafe fn reallocate_inplace(ptr: *mut u8, old_size: usize, size: usize,
align: usize) -> usize {
rust_reallocate_inplace(ptr, old_size, size, align)
}

#[inline]
pub fn usable_size(size: uint, align: uint) -> uint {
pub fn usable_size(size: usize, align: usize) -> usize {
unsafe { rust_usable_size(size, align) }
}

Expand Down Expand Up @@ -215,42 +216,42 @@ mod imp {

// MALLOCX_ALIGN(a) macro
#[inline(always)]
fn mallocx_align(a: uint) -> c_int { a.trailing_zeros() as c_int }
fn mallocx_align(a: usize) -> c_int { a.trailing_zeros() as c_int }

#[inline(always)]
fn align_to_flags(align: uint) -> c_int {
fn align_to_flags(align: usize) -> c_int {
if align <= MIN_ALIGN { 0 } else { mallocx_align(align) }
}

#[inline]
pub unsafe fn allocate(size: uint, align: uint) -> *mut u8 {
pub unsafe fn allocate(size: usize, align: usize) -> *mut u8 {
let flags = align_to_flags(align);
je_mallocx(size as size_t, flags) as *mut u8
}

#[inline]
pub unsafe fn reallocate(ptr: *mut u8, _old_size: uint, size: uint, align: uint) -> *mut u8 {
pub unsafe fn reallocate(ptr: *mut u8, _old_size: usize, size: usize, align: usize) -> *mut u8 {
let flags = align_to_flags(align);
je_rallocx(ptr as *mut c_void, size as size_t, flags) as *mut u8
}

#[inline]
pub unsafe fn reallocate_inplace(ptr: *mut u8, _old_size: uint, size: uint,
align: uint) -> uint {
pub unsafe fn reallocate_inplace(ptr: *mut u8, _old_size: usize, size: usize,
align: usize) -> usize {
let flags = align_to_flags(align);
je_xallocx(ptr as *mut c_void, size as size_t, 0, flags) as uint
je_xallocx(ptr as *mut c_void, size as size_t, 0, flags) as usize
}

#[inline]
pub unsafe fn deallocate(ptr: *mut u8, old_size: uint, align: uint) {
pub unsafe fn deallocate(ptr: *mut u8, old_size: usize, align: usize) {
let flags = align_to_flags(align);
je_sdallocx(ptr as *mut c_void, old_size as size_t, flags)
}

#[inline]
pub fn usable_size(size: uint, align: uint) -> uint {
pub fn usable_size(size: usize, align: usize) -> usize {
let flags = align_to_flags(align);
unsafe { je_nallocx(size as size_t, flags) as uint }
unsafe { je_nallocx(size as size_t, flags) as usize }
}

pub fn stats_print() {
Expand All @@ -277,7 +278,7 @@ mod imp {
}

#[inline]
pub unsafe fn allocate(size: uint, align: uint) -> *mut u8 {
pub unsafe fn allocate(size: usize, align: usize) -> *mut u8 {
if align <= MIN_ALIGN {
libc::malloc(size as libc::size_t) as *mut u8
} else {
Expand All @@ -294,7 +295,7 @@ mod imp {
}

#[inline]
pub unsafe fn reallocate(ptr: *mut u8, old_size: uint, size: uint, align: uint) -> *mut u8 {
pub unsafe fn reallocate(ptr: *mut u8, old_size: usize, size: usize, align: usize) -> *mut u8 {
if align <= MIN_ALIGN {
libc::realloc(ptr as *mut libc::c_void, size as libc::size_t) as *mut u8
} else {
Expand All @@ -306,18 +307,18 @@ mod imp {
}

#[inline]
pub unsafe fn reallocate_inplace(_ptr: *mut u8, old_size: uint, _size: uint,
_align: uint) -> uint {
pub unsafe fn reallocate_inplace(_ptr: *mut u8, old_size: usize, _size: usize,
_align: usize) -> usize {
old_size
}

#[inline]
pub unsafe fn deallocate(ptr: *mut u8, _old_size: uint, _align: uint) {
pub unsafe fn deallocate(ptr: *mut u8, _old_size: usize, _align: usize) {
libc::free(ptr as *mut libc::c_void)
}

#[inline]
pub fn usable_size(size: uint, _align: uint) -> uint {
pub fn usable_size(size: usize, _align: usize) -> usize {
size
}

Expand All @@ -341,7 +342,7 @@ mod imp {
}

#[inline]
pub unsafe fn allocate(size: uint, align: uint) -> *mut u8 {
pub unsafe fn allocate(size: usize, align: usize) -> *mut u8 {
if align <= MIN_ALIGN {
libc::malloc(size as size_t) as *mut u8
} else {
Expand All @@ -350,7 +351,7 @@ mod imp {
}

#[inline]
pub unsafe fn reallocate(ptr: *mut u8, _old_size: uint, size: uint, align: uint) -> *mut u8 {
pub unsafe fn reallocate(ptr: *mut u8, _old_size: usize, size: usize, align: usize) -> *mut u8 {
if align <= MIN_ALIGN {
libc::realloc(ptr as *mut c_void, size as size_t) as *mut u8
} else {
Expand All @@ -359,13 +360,13 @@ mod imp {
}

#[inline]
pub unsafe fn reallocate_inplace(_ptr: *mut u8, old_size: uint, _size: uint,
_align: uint) -> uint {
pub unsafe fn reallocate_inplace(_ptr: *mut u8, old_size: usize, _size: usize,
_align: usize) -> usize {
old_size
}

#[inline]
pub unsafe fn deallocate(ptr: *mut u8, _old_size: uint, align: uint) {
pub unsafe fn deallocate(ptr: *mut u8, _old_size: usize, align: usize) {
if align <= MIN_ALIGN {
libc::free(ptr as *mut libc::c_void)
} else {
Expand All @@ -374,7 +375,7 @@ mod imp {
}

#[inline]
pub fn usable_size(size: uint, _align: uint) -> uint {
pub fn usable_size(size: usize, _align: usize) -> usize {
size
}

Expand Down
1 change: 0 additions & 1 deletion src/liballoc/lib.rs
Expand Up @@ -70,7 +70,6 @@
#![feature(lang_items, unsafe_destructor)]
#![feature(box_syntax)]
#![feature(optin_builtin_traits)]
#![feature(int_uint)]
#![feature(unboxed_closures)]
#![feature(core)]
#![feature(hash)]
Expand Down

0 comments on commit 6a2bad3

Please sign in to comment.