Mass rename uint/int to usize/isize

Now that support has been removed, all lingering use cases are renamed.
This commit is contained in:
Alex Crichton 2015-03-25 17:06:52 -07:00
parent 54f16b818b
commit 43bfaa4a33
1391 changed files with 5180 additions and 5238 deletions

View file

@ -63,7 +63,7 @@ type StackWalk64Fn =
*mut libc::c_void, *mut libc::c_void,
*mut libc::c_void, *mut libc::c_void) -> libc::BOOL;
const MAX_SYM_NAME: uint = 2000;
const MAX_SYM_NAME: usize = 2000;
const IMAGE_FILE_MACHINE_I386: libc::DWORD = 0x014c;
const IMAGE_FILE_MACHINE_IA64: libc::DWORD = 0x0200;
const IMAGE_FILE_MACHINE_AMD64: libc::DWORD = 0x8664;
@ -138,7 +138,7 @@ struct KDHELP64 {
mod arch {
use libc;
const MAXIMUM_SUPPORTED_EXTENSION: uint = 512;
const MAXIMUM_SUPPORTED_EXTENSION: usize = 512;
#[repr(C)]
pub struct CONTEXT {

View file

@ -42,7 +42,7 @@ impl FileDesc {
FileDesc { fd: fd, close_on_drop: close_on_drop }
}
pub fn read(&self, buf: &mut [u8]) -> IoResult<uint> {
pub fn read(&self, buf: &mut [u8]) -> IoResult<usize> {
let mut read = 0;
let ret = unsafe {
libc::ReadFile(self.handle(), buf.as_ptr() as libc::LPVOID,
@ -50,7 +50,7 @@ impl FileDesc {
ptr::null_mut())
};
if ret != 0 {
Ok(read as uint)
Ok(read as usize)
} else {
Err(super::last_error())
}
@ -67,8 +67,8 @@ impl FileDesc {
ptr::null_mut())
};
if ret != 0 {
remaining -= amt as uint;
cur = unsafe { cur.offset(amt as int) };
remaining -= amt as usize;
cur = unsafe { cur.offset(amt as isize) };
} else {
return Err(super::last_error())
}
@ -234,7 +234,7 @@ pub fn open(path: &Path, fm: FileMode, fa: FileAccess) -> IoResult<FileDesc> {
}
}
pub fn mkdir(p: &Path, _mode: uint) -> IoResult<()> {
pub fn mkdir(p: &Path, _mode: usize) -> IoResult<()> {
let p = try!(to_utf16(p));
super::mkerr_winbool(unsafe {
// FIXME: turn mode into something useful? #2623
@ -308,11 +308,11 @@ pub fn unlink(p: &Path) -> IoResult<()> {
};
if stat.perm.intersects(old_io::USER_WRITE) { return Err(e) }
match chmod(p, (stat.perm | old_io::USER_WRITE).bits() as uint) {
match chmod(p, (stat.perm | old_io::USER_WRITE).bits() as usize) {
Ok(()) => do_unlink(&p_utf16),
Err(..) => {
// Try to put it back as we found it
let _ = chmod(p, stat.perm.bits() as uint);
let _ = chmod(p, stat.perm.bits() as usize);
Err(e)
}
}
@ -331,7 +331,7 @@ pub fn rename(old: &Path, new: &Path) -> IoResult<()> {
})
}
pub fn chmod(p: &Path, mode: uint) -> IoResult<()> {
pub fn chmod(p: &Path, mode: usize) -> IoResult<()> {
let p = try!(to_utf16(p));
mkerr_libc(unsafe {
libc::wchmod(p.as_ptr(), mode as libc::c_int)
@ -343,7 +343,7 @@ pub fn rmdir(p: &Path) -> IoResult<()> {
super::mkerr_winbool(unsafe { libc::RemoveDirectoryW(p.as_ptr()) })
}
pub fn chown(_p: &Path, _uid: int, _gid: int) -> IoResult<()> {
pub fn chown(_p: &Path, _uid: isize, _gid: isize) -> IoResult<()> {
// libuv has this as a no-op, so seems like this should as well?
Ok(())
}

View file

@ -115,7 +115,7 @@ impl Event {
initial_state as libc::BOOL,
ptr::null())
};
if event as uint == 0 {
if event as usize == 0 {
Err(super::last_error())
} else {
Ok(Event(event))
@ -181,7 +181,7 @@ unsafe fn pipe(name: *const u16, init: bool) -> libc::HANDLE {
}
pub fn await(handle: libc::HANDLE, deadline: u64,
events: &[libc::HANDLE]) -> IoResult<uint> {
events: &[libc::HANDLE]) -> IoResult<usize> {
use libc::consts::os::extra::{WAIT_FAILED, WAIT_TIMEOUT, WAIT_OBJECT_0};
// If we've got a timeout, use WaitForSingleObject in tandem with CancelIo
@ -204,7 +204,7 @@ pub fn await(handle: libc::HANDLE, deadline: u64,
let _ = c::CancelIo(handle);
Err(sys_common::timeout("operation timed out"))
},
n => Ok((n - WAIT_OBJECT_0) as uint)
n => Ok((n - WAIT_OBJECT_0) as usize)
}
}
@ -314,7 +314,7 @@ impl UnixStream {
// `WaitNamedPipe` function, and this is indicated with an error
// code of ERROR_PIPE_BUSY.
let code = unsafe { libc::GetLastError() };
if code as int != libc::ERROR_PIPE_BUSY as int {
if code as isize != libc::ERROR_PIPE_BUSY as isize {
return Err(super::last_error())
}
@ -362,7 +362,7 @@ impl UnixStream {
}
}
pub fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
pub fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> {
if self.read.is_none() {
self.read = Some(try!(Event::new(true, false)));
}
@ -390,7 +390,7 @@ impl UnixStream {
&mut bytes_read,
&mut overlapped)
};
if ret != 0 { return Ok(bytes_read as uint) }
if ret != 0 { return Ok(bytes_read as usize) }
// If our errno doesn't say that the I/O is pending, then we hit some
// legitimate error and return immediately.
@ -418,7 +418,7 @@ impl UnixStream {
};
// If we succeeded, or we failed for some reason other than
// CancelIoEx, return immediately
if ret != 0 { return Ok(bytes_read as uint) }
if ret != 0 { return Ok(bytes_read as usize) }
if os::errno() != libc::ERROR_OPERATION_ABORTED as i32 {
return Err(super::last_error())
}
@ -487,7 +487,7 @@ impl UnixStream {
return Err(super::last_error())
}
if !wait_succeeded.is_ok() {
let amt = offset + bytes_written as uint;
let amt = offset + bytes_written as usize;
return if amt > 0 {
Err(IoError {
kind: old_io::ShortWrite(amt),
@ -504,7 +504,7 @@ impl UnixStream {
continue // retry
}
}
offset += bytes_written as uint;
offset += bytes_written as usize;
}
Ok(())
}

View file

@ -63,11 +63,11 @@ impl Process {
self.pid
}
pub unsafe fn kill(&self, signal: int) -> IoResult<()> {
pub unsafe fn kill(&self, signal: isize) -> IoResult<()> {
Process::killpid(self.pid, signal)
}
pub unsafe fn killpid(pid: pid_t, signal: int) -> IoResult<()> {
pub unsafe fn killpid(pid: pid_t, signal: isize) -> IoResult<()> {
let handle = libc::OpenProcess(libc::PROCESS_TERMINATE |
libc::PROCESS_QUERY_INFORMATION,
libc::FALSE, pid as libc::DWORD);
@ -309,7 +309,7 @@ impl Process {
}
if status != STILL_ACTIVE {
assert!(CloseHandle(process) != 0);
return Ok(ExitStatus(status as int));
return Ok(ExitStatus(status as isize));
}
let interval = if deadline == 0 {
INFINITE
@ -394,7 +394,7 @@ fn make_command_line(prog: &CString, args: &[CString]) -> String {
}
}
fn append_char_at(cmd: &mut String, arg: &[char], i: uint) {
fn append_char_at(cmd: &mut String, arg: &[char], i: usize) {
match arg[i] {
'"' => {
// Escape quotes.
@ -415,7 +415,7 @@ fn make_command_line(prog: &CString, args: &[CString]) -> String {
}
}
fn backslash_run_ends_in_quote(s: &[char], mut i: uint) -> bool {
fn backslash_run_ends_in_quote(s: &[char], mut i: usize) -> bool {
while i < s.len() && s[i] == '\\' {
i += 1;
}

View file

@ -31,7 +31,7 @@ impl Drop for Handler {
}
// This is initialized in init() and only read from after
static mut PAGE_SIZE: uint = 0;
static mut PAGE_SIZE: usize = 0;
#[no_stack_check]
extern "system" fn vectored_handler(ExceptionInfo: *mut EXCEPTION_POINTERS) -> LONG {
@ -56,7 +56,7 @@ extern "system" fn vectored_handler(ExceptionInfo: *mut EXCEPTION_POINTERS) -> L
pub unsafe fn init() {
let mut info = mem::zeroed();
libc::GetSystemInfo(&mut info);
PAGE_SIZE = info.dwPageSize as uint;
PAGE_SIZE = info.dwPageSize as usize;
if AddVectoredExceptionHandler(0, vectored_handler) == ptr::null_mut() {
panic!("failed to install exception handler");
@ -96,7 +96,7 @@ pub type PVECTORED_EXCEPTION_HANDLER = extern "system"
pub type ULONG = libc::c_ulong;
const EXCEPTION_CONTINUE_SEARCH: LONG = 0;
const EXCEPTION_MAXIMUM_PARAMETERS: uint = 15;
const EXCEPTION_MAXIMUM_PARAMETERS: usize = 15;
const EXCEPTION_STACK_OVERFLOW: DWORD = 0xc00000fd;
extern "system" {

View file

@ -77,7 +77,7 @@ impl TcpListener {
pub fn socket(&self) -> sock_t { self.sock }
pub fn listen(self, backlog: int) -> IoResult<TcpAcceptor> {
pub fn listen(self, backlog: isize) -> IoResult<TcpAcceptor> {
match unsafe { libc::listen(self.socket(), backlog as libc::c_int) } {
-1 => Err(last_net_error()),

View file

@ -25,8 +25,8 @@ use time::Duration;
pub type rust_thread = HANDLE;
pub mod guard {
pub unsafe fn main() -> uint { 0 }
pub unsafe fn current() -> uint { 0 }
pub unsafe fn main() -> usize { 0 }
pub unsafe fn current() -> usize { 0 }
pub unsafe fn init() {}
}

View file

@ -139,7 +139,7 @@ unsafe fn init_dtors() {
let dtors = DTORS;
DTORS = 1 as *mut _;
Box::from_raw(dtors);
assert!(DTORS as uint == 1); // can't re-init after destructing
assert!(DTORS as usize == 1); // can't re-init after destructing
DTOR_LOCK.unlock();
});
if res.is_ok() {
@ -152,8 +152,8 @@ unsafe fn init_dtors() {
unsafe fn register_dtor(key: Key, dtor: Dtor) {
DTOR_LOCK.lock();
init_dtors();
assert!(DTORS as uint != 0);
assert!(DTORS as uint != 1,
assert!(DTORS as usize != 0);
assert!(DTORS as usize != 1,
"cannot create new TLS keys after the main thread has exited");
(*DTORS).push((key, dtor));
DTOR_LOCK.unlock();
@ -162,8 +162,8 @@ unsafe fn register_dtor(key: Key, dtor: Dtor) {
unsafe fn unregister_dtor(key: Key) -> bool {
DTOR_LOCK.lock();
init_dtors();
assert!(DTORS as uint != 0);
assert!(DTORS as uint != 1,
assert!(DTORS as usize != 0);
assert!(DTORS as usize != 1,
"cannot unregister destructors after the main thread has exited");
let ret = {
let dtors = &mut *DTORS;

View file

@ -91,13 +91,13 @@ fn helper(input: libc::HANDLE, messages: Receiver<Req>, _: ()) {
}
} else {
let remove = {
match &mut chans[idx as uint - 1] {
match &mut chans[idx as usize - 1] {
&mut (ref mut c, oneshot) => { c.call(); oneshot }
}
};
if remove {
drop(objs.remove(idx as uint));
drop(chans.remove(idx as uint - 1));
drop(objs.remove(idx as usize));
drop(chans.remove(idx as usize - 1));
}
}
}

View file

@ -92,7 +92,7 @@ impl TTY {
}
}
pub fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
pub fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> {
// Read more if the buffer is empty
if self.utf8.eof() {
let mut utf16: Vec<u16> = repeat(0u16).take(0x1000).collect();
@ -105,7 +105,7 @@ impl TTY {
0 => return Err(super::last_error()),
_ => (),
};
utf16.truncate(num as uint);
utf16.truncate(num as usize);
let utf8 = match String::from_utf16(&utf16) {
Ok(utf8) => utf8.into_bytes(),
Err(..) => return Err(invalid_encoding()),
@ -149,12 +149,12 @@ impl TTY {
}
}
pub fn get_winsize(&mut self) -> IoResult<(int, int)> {
pub fn get_winsize(&mut self) -> IoResult<(isize, isize)> {
let mut info: CONSOLE_SCREEN_BUFFER_INFO = unsafe { mem::zeroed() };
match unsafe { GetConsoleScreenBufferInfo(self.handle, &mut info as *mut _) } {
0 => Err(super::last_error()),
_ => Ok(((info.srWindow.Right + 1 - info.srWindow.Left) as int,
(info.srWindow.Bottom + 1 - info.srWindow.Top) as int)),
_ => Ok(((info.srWindow.Right + 1 - info.srWindow.Left) as isize,
(info.srWindow.Bottom + 1 - info.srWindow.Top) as isize)),
}
}
}