diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-03-25 17:06:52 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-03-26 12:10:22 -0700 |
| commit | 43bfaa4a336095eb5697fb2df50909fd3c72ed14 (patch) | |
| tree | e10610e1ce9811c89e1291b786d7a49b63ee02d9 /src/libstd/sys | |
| parent | 54f16b818b58f6d6e81891b041fc751986e75155 (diff) | |
| download | rust-43bfaa4a336095eb5697fb2df50909fd3c72ed14.tar.gz rust-43bfaa4a336095eb5697fb2df50909fd3c72ed14.zip | |
Mass rename uint/int to usize/isize
Now that support has been removed, all lingering use cases are renamed.
Diffstat (limited to 'src/libstd/sys')
29 files changed, 195 insertions, 195 deletions
diff --git a/src/libstd/sys/common/backtrace.rs b/src/libstd/sys/common/backtrace.rs index c42a755b444..cd118b3c9ee 100644 --- a/src/libstd/sys/common/backtrace.rs +++ b/src/libstd/sys/common/backtrace.rs @@ -14,10 +14,10 @@ use io::prelude::*; use io; #[cfg(target_pointer_width = "64")] -pub const HEX_WIDTH: uint = 18; +pub const HEX_WIDTH: usize = 18; #[cfg(target_pointer_width = "32")] -pub const HEX_WIDTH: uint = 10; +pub const HEX_WIDTH: usize = 10; // All rust symbols are in theory lists of "::"-separated identifiers. Some // assemblers, however, can't handle these characters in symbol names. To get @@ -57,7 +57,7 @@ pub fn demangle(writer: &mut Write, s: &str) -> io::Result<()> { let mut i = 0; for c in chars.by_ref() { if c.is_numeric() { - i = i * 10 + c as uint - '0' as uint; + i = i * 10 + c as usize - '0' as usize; } else { break } @@ -86,7 +86,7 @@ pub fn demangle(writer: &mut Write, s: &str) -> io::Result<()> { while rest.char_at(0).is_numeric() { rest = &rest[1..]; } - let i: uint = inner[.. (inner.len() - rest.len())].parse().unwrap(); + let i: usize = inner[.. (inner.len() - rest.len())].parse().unwrap(); inner = &rest[i..]; rest = &rest[..i]; while rest.len() > 0 { diff --git a/src/libstd/sys/common/helper_thread.rs b/src/libstd/sys/common/helper_thread.rs index 10077dfd1b8..34a58f6c83a 100644 --- a/src/libstd/sys/common/helper_thread.rs +++ b/src/libstd/sys/common/helper_thread.rs @@ -51,7 +51,7 @@ pub struct Helper<M:Send> { pub chan: UnsafeCell<*mut Sender<M>>, /// OS handle used to wake up a blocked helper thread - pub signal: UnsafeCell<uint>, + pub signal: UnsafeCell<usize>, /// Flag if this helper thread has booted and been initialized yet. pub initialized: UnsafeCell<bool>, @@ -96,11 +96,11 @@ impl<M: Send> Helper<M> { { unsafe { let _guard = self.lock.lock().unwrap(); - if *self.chan.get() as uint == 0 { + if *self.chan.get() as usize == 0 { let (tx, rx) = channel(); *self.chan.get() = boxed::into_raw(box tx); let (receive, send) = helper_signal::new(); - *self.signal.get() = send as uint; + *self.signal.get() = send as usize; let receive = RaceBox(receive); @@ -114,7 +114,7 @@ impl<M: Send> Helper<M> { let _ = rt::at_exit(move || { self.shutdown() }); *self.initialized.get() = true; - } else if *self.chan.get() as uint == 1 { + } else if *self.chan.get() as usize == 1 { panic!("cannot continue usage after shutdown"); } } @@ -130,8 +130,8 @@ impl<M: Send> Helper<M> { // Must send and *then* signal to ensure that the child receives the // message. Otherwise it could wake up and go to sleep before we // send the message. - assert!(*self.chan.get() as uint != 0); - assert!(*self.chan.get() as uint != 1, + assert!(*self.chan.get() as usize != 0); + assert!(*self.chan.get() as usize != 1, "cannot continue usage after shutdown"); (**self.chan.get()).send(msg).unwrap(); helper_signal::signal(*self.signal.get() as helper_signal::signal); @@ -146,7 +146,7 @@ impl<M: Send> Helper<M> { let mut guard = self.lock.lock().unwrap(); let ptr = *self.chan.get(); - if ptr as uint == 1 { + if ptr as usize == 1 { panic!("cannot continue usage after shutdown"); } // Close the channel by destroying it diff --git a/src/libstd/sys/common/mod.rs b/src/libstd/sys/common/mod.rs index 29c05b1e0d8..a8769ba99e8 100644 --- a/src/libstd/sys/common/mod.rs +++ b/src/libstd/sys/common/mod.rs @@ -56,7 +56,7 @@ pub fn timeout(desc: &'static str) -> IoError { } #[allow(deprecated)] -pub fn short_write(n: uint, desc: &'static str) -> IoError { +pub fn short_write(n: usize, desc: &'static str) -> IoError { IoError { kind: if n == 0 { old_io::TimedOut } else { old_io::ShortWrite(n) }, desc: desc, @@ -84,7 +84,7 @@ pub fn mkerr_libc<T: Int>(ret: T) -> IoResult<()> { } pub fn keep_going<F>(data: &[u8], mut f: F) -> i64 where - F: FnMut(*const u8, uint) -> i64, + F: FnMut(*const u8, usize) -> i64, { let origamt = data.len(); let mut data = data.as_ptr(); @@ -94,8 +94,8 @@ pub fn keep_going<F>(data: &[u8], mut f: F) -> i64 where if ret == 0 { break } else if ret != -1 { - amt -= ret as uint; - data = unsafe { data.offset(ret as int) }; + amt -= ret as usize; + data = unsafe { data.offset(ret as isize) }; } else { return ret; } @@ -134,7 +134,7 @@ pub trait ProcessConfig<K: BytesContainer, V: BytesContainer> { fn args(&self) -> &[CString]; fn env(&self) -> Option<&collections::HashMap<K, V>>; fn cwd(&self) -> Option<&CString>; - fn uid(&self) -> Option<uint>; - fn gid(&self) -> Option<uint>; + fn uid(&self) -> Option<usize>; + fn gid(&self) -> Option<usize>; fn detach(&self) -> bool; } diff --git a/src/libstd/sys/common/net.rs b/src/libstd/sys/common/net.rs index 96b72b42e54..1a0ee17904a 100644 --- a/src/libstd/sys/common/net.rs +++ b/src/libstd/sys/common/net.rs @@ -148,7 +148,7 @@ pub fn getsockopt<T: Copy>(fd: sock_t, opt: libc::c_int, if ret != 0 { Err(last_net_error()) } else { - assert!(len as uint == mem::size_of::<T>()); + assert!(len as usize == mem::size_of::<T>()); Ok(slot) } } @@ -170,14 +170,14 @@ pub fn sockname(fd: sock_t, return Err(last_net_error()) } } - return sockaddr_to_addr(&storage, len as uint); + return sockaddr_to_addr(&storage, len as usize); } pub fn sockaddr_to_addr(storage: &libc::sockaddr_storage, - len: uint) -> IoResult<SocketAddr> { + len: usize) -> IoResult<SocketAddr> { match storage.ss_family as libc::c_int { libc::AF_INET => { - assert!(len as uint >= mem::size_of::<libc::sockaddr_in>()); + assert!(len as usize >= mem::size_of::<libc::sockaddr_in>()); let storage: &libc::sockaddr_in = unsafe { mem::transmute(storage) }; @@ -192,7 +192,7 @@ pub fn sockaddr_to_addr(storage: &libc::sockaddr_storage, }) } libc::AF_INET6 => { - assert!(len as uint >= mem::size_of::<libc::sockaddr_in6>()); + assert!(len as usize >= mem::size_of::<libc::sockaddr_in6>()); let storage: &libc::sockaddr_in6 = unsafe { mem::transmute(storage) }; @@ -283,13 +283,13 @@ pub fn get_host_addresses(host: Option<&str>, servname: Option<&str>, while !rp.is_null() { unsafe { let addr = try!(sockaddr_to_addr(mem::transmute((*rp).ai_addr), - (*rp).ai_addrlen as uint)); + (*rp).ai_addrlen as usize)); addrs.push(addrinfo::Info { address: addr, - family: (*rp).ai_family as uint, + family: (*rp).ai_family as usize, socktype: None, protocol: None, - flags: (*rp).ai_flags as uint + flags: (*rp).ai_flags as usize }); rp = (*rp).ai_next as *mut libc::addrinfo; @@ -312,7 +312,7 @@ extern "system" { flags: c_int) -> c_int; } -const NI_MAXHOST: uint = 1025; +const NI_MAXHOST: usize = 1025; pub fn get_address_name(addr: IpAddr) -> Result<String, IoError> { let addr = SocketAddr{ip: addr, port: 0}; @@ -393,7 +393,7 @@ pub fn get_address_name(addr: IpAddr) -> Result<String, IoError> { // [1] http://twistedmatrix.com/pipermail/twisted-commits/2012-April/034692.html // [2] http://stackoverflow.com/questions/19819198/does-send-msg-dontwait -pub fn read<T, L, R>(fd: sock_t, deadline: u64, mut lock: L, mut read: R) -> IoResult<uint> where +pub fn read<T, L, R>(fd: sock_t, deadline: u64, mut lock: L, mut read: R) -> IoResult<usize> where L: FnMut() -> T, R: FnMut(bool) -> libc::c_int, { @@ -431,7 +431,7 @@ pub fn read<T, L, R>(fd: sock_t, deadline: u64, mut lock: L, mut read: R) -> IoR match ret { 0 => Err(sys_common::eof()), n if n < 0 => Err(last_net_error()), - n => Ok(n as uint) + n => Ok(n as usize) } } @@ -440,9 +440,9 @@ pub fn write<T, L, W>(fd: sock_t, buf: &[u8], write_everything: bool, mut lock: L, - mut write: W) -> IoResult<uint> where + mut write: W) -> IoResult<usize> where L: FnMut() -> T, - W: FnMut(bool, *const u8, uint) -> i64, + W: FnMut(bool, *const u8, usize) -> i64, { let mut ret = -1; let mut written = 0; @@ -454,7 +454,7 @@ pub fn write<T, L, W>(fd: sock_t, }); } else { ret = retry(|| { write(false, buf.as_ptr(), buf.len()) }); - if ret > 0 { written = ret as uint; } + if ret > 0 { written = ret as usize; } } } @@ -483,7 +483,7 @@ pub fn write<T, L, W>(fd: sock_t, match retry(|| write(deadline.is_some(), ptr, len)) { -1 if wouldblock() => {} -1 => return Err(last_net_error()), - n => { written += n as uint; } + n => { written += n as usize; } } } ret = 0; @@ -513,8 +513,8 @@ pub fn connect_timeout(fd: sock_t, // If the connection is in progress, then we need to wait for it to // finish (with a timeout). The current strategy for doing this is // to use select() with a timeout. - -1 if os::errno() as int == INPROGRESS as int || - os::errno() as int == WOULDBLOCK as int => { + -1 if os::errno() as isize == INPROGRESS as isize || + os::errno() as isize == WOULDBLOCK as isize => { let mut set: c::fd_set = unsafe { mem::zeroed() }; c::fd_set(&mut set, fd); match await(fd, &mut set, timeout_ms) { @@ -686,7 +686,7 @@ impl TcpStream { nodelay as libc::c_int) } - pub fn set_keepalive(&mut self, seconds: Option<uint>) -> IoResult<()> { + pub fn set_keepalive(&mut self, seconds: Option<usize>) -> IoResult<()> { let ret = setsockopt(self.fd(), libc::SOL_SOCKET, libc::SO_KEEPALIVE, seconds.is_some() as libc::c_int); match seconds { @@ -696,18 +696,18 @@ impl TcpStream { } #[cfg(any(target_os = "macos", target_os = "ios"))] - fn set_tcp_keepalive(&mut self, seconds: uint) -> IoResult<()> { + fn set_tcp_keepalive(&mut self, seconds: usize) -> IoResult<()> { setsockopt(self.fd(), libc::IPPROTO_TCP, libc::TCP_KEEPALIVE, seconds as libc::c_int) } #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] - fn set_tcp_keepalive(&mut self, seconds: uint) -> IoResult<()> { + fn set_tcp_keepalive(&mut self, seconds: usize) -> IoResult<()> { setsockopt(self.fd(), libc::IPPROTO_TCP, libc::TCP_KEEPIDLE, seconds as libc::c_int) } #[cfg(target_os = "openbsd")] - fn set_tcp_keepalive(&mut self, seconds: uint) -> IoResult<()> { + fn set_tcp_keepalive(&mut self, seconds: usize) -> IoResult<()> { setsockopt(self.fd(), libc::IPPROTO_TCP, libc::SO_KEEPALIVE, seconds as libc::c_int) } @@ -716,7 +716,7 @@ impl TcpStream { target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd")))] - fn set_tcp_keepalive(&mut self, _seconds: uint) -> IoResult<()> { + fn set_tcp_keepalive(&mut self, _seconds: usize) -> IoResult<()> { Ok(()) } @@ -733,7 +733,7 @@ impl TcpStream { ret } - pub fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { + pub fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> { let fd = self.fd(); let dolock = || self.lock_nonblocking(); let doread = |nb| unsafe { @@ -749,7 +749,7 @@ impl TcpStream { pub fn write(&mut self, buf: &[u8]) -> IoResult<()> { let fd = self.fd(); let dolock = || self.lock_nonblocking(); - let dowrite = |nb: bool, buf: *const u8, len: uint| unsafe { + let dowrite = |nb: bool, buf: *const u8, len: usize| unsafe { let flags = if nb {c::MSG_DONTWAIT} else {0}; libc::send(fd, buf as *const _, @@ -876,7 +876,7 @@ impl UdpSocket { sockname(self.fd(), libc::getsockname) } - pub fn recv_from(&mut self, buf: &mut [u8]) -> IoResult<(uint, SocketAddr)> { + pub fn recv_from(&mut self, buf: &mut [u8]) -> IoResult<(usize, SocketAddr)> { let fd = self.fd(); let mut storage: libc::sockaddr_storage = unsafe { mem::zeroed() }; let storagep = &mut storage as *mut _ as *mut libc::sockaddr; @@ -893,7 +893,7 @@ impl UdpSocket { storagep, &mut addrlen) as libc::c_int })); - Ok((n as uint, sockaddr_to_addr(&storage, addrlen as uint).unwrap())) + Ok((n as usize, sockaddr_to_addr(&storage, addrlen as usize).unwrap())) } pub fn send_to(&mut self, buf: &[u8], dst: SocketAddr) -> IoResult<()> { @@ -903,7 +903,7 @@ impl UdpSocket { let fd = self.fd(); let dolock = || self.lock_nonblocking(); - let dowrite = |nb, buf: *const u8, len: uint| unsafe { + let dowrite = |nb, buf: *const u8, len: usize| unsafe { let flags = if nb {c::MSG_DONTWAIT} else {0}; libc::sendto(fd, buf as *const libc::c_void, @@ -939,11 +939,11 @@ impl UdpSocket { } } - pub fn multicast_time_to_live(&mut self, ttl: int) -> IoResult<()> { + pub fn multicast_time_to_live(&mut self, ttl: isize) -> IoResult<()> { setsockopt(self.fd(), libc::IPPROTO_IP, libc::IP_MULTICAST_TTL, ttl as libc::c_int) } - pub fn time_to_live(&mut self, ttl: int) -> IoResult<()> { + pub fn time_to_live(&mut self, ttl: isize) -> IoResult<()> { setsockopt(self.fd(), libc::IPPROTO_IP, libc::IP_TTL, ttl as libc::c_int) } diff --git a/src/libstd/sys/common/stack.rs b/src/libstd/sys/common/stack.rs index 8c428275ccf..8dc3407db77 100644 --- a/src/libstd/sys/common/stack.rs +++ b/src/libstd/sys/common/stack.rs @@ -46,7 +46,7 @@ // corresponding prolog, decision was taken to disable segmented // stack support on iOS. -pub const RED_ZONE: uint = 20 * 1024; +pub const RED_ZONE: usize = 20 * 1024; /// This function is invoked from rust's current __morestack function. Segmented /// stacks are currently not enabled as segmented stacks, but rather one giant @@ -117,7 +117,7 @@ extern fn stack_exhausted() { // On all other platforms both variants behave identically. #[inline(always)] -pub unsafe fn record_os_managed_stack_bounds(stack_lo: uint, _stack_hi: uint) { +pub unsafe fn record_os_managed_stack_bounds(stack_lo: usize, _stack_hi: usize) { record_sp_limit(stack_lo + RED_ZONE); } @@ -136,31 +136,31 @@ pub unsafe fn record_os_managed_stack_bounds(stack_lo: uint, _stack_hi: uint) { /// would be unfortunate for the functions themselves to trigger a morestack /// invocation (if they were an actual function call). #[inline(always)] -pub unsafe fn record_sp_limit(limit: uint) { +pub unsafe fn record_sp_limit(limit: usize) { return target_record_sp_limit(limit); // x86-64 #[cfg(all(target_arch = "x86_64", any(target_os = "macos", target_os = "ios")))] #[inline(always)] - unsafe fn target_record_sp_limit(limit: uint) { + unsafe fn target_record_sp_limit(limit: usize) { asm!("movq $$0x60+90*8, %rsi movq $0, %gs:(%rsi)" :: "r"(limit) : "rsi" : "volatile") } #[cfg(all(target_arch = "x86_64", target_os = "linux"))] #[inline(always)] - unsafe fn target_record_sp_limit(limit: uint) { + unsafe fn target_record_sp_limit(limit: usize) { asm!("movq $0, %fs:112" :: "r"(limit) :: "volatile") } #[cfg(all(target_arch = "x86_64", target_os = "windows"))] #[inline(always)] - unsafe fn target_record_sp_limit(_: uint) { + unsafe fn target_record_sp_limit(_: usize) { } #[cfg(all(target_arch = "x86_64", target_os = "freebsd"))] #[inline(always)] - unsafe fn target_record_sp_limit(limit: uint) { + unsafe fn target_record_sp_limit(limit: usize) { asm!("movq $0, %fs:24" :: "r"(limit) :: "volatile") } #[cfg(all(target_arch = "x86_64", target_os = "dragonfly"))] #[inline(always)] - unsafe fn target_record_sp_limit(limit: uint) { + unsafe fn target_record_sp_limit(limit: usize) { asm!("movq $0, %fs:32" :: "r"(limit) :: "volatile") } @@ -168,18 +168,18 @@ pub unsafe fn record_sp_limit(limit: uint) { #[cfg(all(target_arch = "x86", any(target_os = "macos", target_os = "ios")))] #[inline(always)] - unsafe fn target_record_sp_limit(limit: uint) { + unsafe fn target_record_sp_limit(limit: usize) { asm!("movl $$0x48+90*4, %eax movl $0, %gs:(%eax)" :: "r"(limit) : "eax" : "volatile") } #[cfg(all(target_arch = "x86", any(target_os = "linux", target_os = "freebsd")))] #[inline(always)] - unsafe fn target_record_sp_limit(limit: uint) { + unsafe fn target_record_sp_limit(limit: usize) { asm!("movl $0, %gs:48" :: "r"(limit) :: "volatile") } #[cfg(all(target_arch = "x86", target_os = "windows"))] #[inline(always)] - unsafe fn target_record_sp_limit(_: uint) { + unsafe fn target_record_sp_limit(_: usize) { } // mips, arm - Some brave soul can port these to inline asm, but it's over @@ -188,7 +188,7 @@ pub unsafe fn record_sp_limit(limit: uint) { target_arch = "mipsel", all(target_arch = "arm", not(target_os = "ios"))))] #[inline(always)] - unsafe fn target_record_sp_limit(limit: uint) { + unsafe fn target_record_sp_limit(limit: usize) { use libc::c_void; return record_sp_limit(limit as *const c_void); extern { @@ -205,7 +205,7 @@ pub unsafe fn record_sp_limit(limit: uint) { all(target_arch = "arm", target_os = "ios"), target_os = "bitrig", target_os = "openbsd"))] - unsafe fn target_record_sp_limit(_: uint) { + unsafe fn target_record_sp_limit(_: usize) { } } @@ -218,38 +218,38 @@ pub unsafe fn record_sp_limit(limit: uint) { /// As with the setter, this function does not have a __morestack header and can /// therefore be called in a "we're out of stack" situation. #[inline(always)] -pub unsafe fn get_sp_limit() -> uint { +pub unsafe fn get_sp_limit() -> usize { return target_get_sp_limit(); // x86-64 #[cfg(all(target_arch = "x86_64", any(target_os = "macos", target_os = "ios")))] #[inline(always)] - unsafe fn target_get_sp_limit() -> uint { + unsafe fn target_get_sp_limit() -> usize { let limit; asm!("movq $$0x60+90*8, %rsi movq %gs:(%rsi), $0" : "=r"(limit) :: "rsi" : "volatile"); return limit; } #[cfg(all(target_arch = "x86_64", target_os = "linux"))] #[inline(always)] - unsafe fn target_get_sp_limit() -> uint { + unsafe fn target_get_sp_limit() -> usize { let limit; asm!("movq %fs:112, $0" : "=r"(limit) ::: "volatile"); return limit; } #[cfg(all(target_arch = "x86_64", target_os = "windows"))] #[inline(always)] - unsafe fn target_get_sp_limit() -> uint { + unsafe fn target_get_sp_limit() -> usize { return 1024; } #[cfg(all(target_arch = "x86_64", target_os = "freebsd"))] #[inline(always)] - unsafe fn target_get_sp_limit() -> uint { + unsafe fn target_get_sp_limit() -> usize { let limit; asm!("movq %fs:24, $0" : "=r"(limit) ::: "volatile"); return limit; } #[cfg(all(target_arch = "x86_64", target_os = "dragonfly"))] #[inline(always)] - unsafe fn target_get_sp_limit() -> uint { + unsafe fn target_get_sp_limit() -> usize { let limit; asm!("movq %fs:32, $0" : "=r"(limit) ::: "volatile"); return limit; @@ -259,7 +259,7 @@ pub unsafe fn get_sp_limit() -> uint { #[cfg(all(target_arch = "x86", any(target_os = "macos", target_os = "ios")))] #[inline(always)] - unsafe fn target_get_sp_limit() -> uint { + unsafe fn target_get_sp_limit() -> usize { let limit; asm!("movl $$0x48+90*4, %eax movl %gs:(%eax), $0" : "=r"(limit) :: "eax" : "volatile"); @@ -268,13 +268,13 @@ pub unsafe fn get_sp_limit() -> uint { #[cfg(all(target_arch = "x86", any(target_os = "linux", target_os = "freebsd")))] #[inline(always)] - unsafe fn target_get_sp_limit() -> uint { + unsafe fn target_get_sp_limit() -> usize { let limit; asm!("movl %gs:48, $0" : "=r"(limit) ::: "volatile"); return limit; } #[cfg(all(target_arch = "x86", target_os = "windows"))] #[inline(always)] - unsafe fn target_get_sp_limit() -> uint { + unsafe fn target_get_sp_limit() -> usize { return 1024; } @@ -284,9 +284,9 @@ pub unsafe fn get_sp_limit() -> uint { target_arch = "mipsel", all(target_arch = "arm", not(target_os = "ios"))))] #[inline(always)] - unsafe fn target_get_sp_limit() -> uint { + unsafe fn target_get_sp_limit() -> usize { use libc::c_void; - return get_sp_limit() as uint; + return get_sp_limit() as usize; extern { fn get_sp_limit() -> *const c_void; } @@ -305,7 +305,7 @@ pub unsafe fn get_sp_limit() -> uint { target_os = "bitrig", target_os = "openbsd"))] #[inline(always)] - unsafe fn target_get_sp_limit() -> uint { + unsafe fn target_get_sp_limit() -> usize { 1024 } } diff --git a/src/libstd/sys/common/thread_info.rs b/src/libstd/sys/common/thread_info.rs index 90526b8f4f3..22cb5943371 100644 --- a/src/libstd/sys/common/thread_info.rs +++ b/src/libstd/sys/common/thread_info.rs @@ -18,7 +18,7 @@ use thread::Thread; use thread::LocalKeyState; struct ThreadInfo { - stack_guard: uint, + stack_guard: usize, thread: Thread, } @@ -47,11 +47,11 @@ pub fn current_thread() -> Thread { ThreadInfo::with(|info| info.thread.clone()) } -pub fn stack_guard() -> uint { +pub fn stack_guard() -> usize { ThreadInfo::with(|info| info.stack_guard) } -pub fn set(stack_guard: uint, thread: Thread) { +pub fn set(stack_guard: usize, thread: Thread) { THREAD_INFO.with(|c| assert!(c.borrow().is_none())); THREAD_INFO.with(move |c| *c.borrow_mut() = Some(ThreadInfo{ stack_guard: stack_guard, diff --git a/src/libstd/sys/common/thread_local.rs b/src/libstd/sys/common/thread_local.rs index 5e2a138fa63..5995d7ac10f 100644 --- a/src/libstd/sys/common/thread_local.rs +++ b/src/libstd/sys/common/thread_local.rs @@ -178,7 +178,7 @@ impl StaticKey { } } - unsafe fn lazy_init(&self) -> uint { + unsafe fn lazy_init(&self) -> usize { // POSIX allows the key created here to be 0, but the compare_and_swap // below relies on using 0 as a sentinel value to check who won the // race to set the shared TLS key. As far as I know, there is no @@ -197,9 +197,9 @@ impl StaticKey { key2 }; assert!(key != 0); - match self.inner.key.compare_and_swap(0, key as uint, Ordering::SeqCst) { + match self.inner.key.compare_and_swap(0, key as usize, Ordering::SeqCst) { // The CAS succeeded, so we've created the actual key - 0 => key as uint, + 0 => key as usize, // If someone beat us to the punch, use their key instead n => { imp::destroy(key); n } } @@ -261,8 +261,8 @@ mod tests { assert!(k2.get().is_null()); k1.set(1 as *mut _); k2.set(2 as *mut _); - assert_eq!(k1.get() as uint, 1); - assert_eq!(k2.get() as uint, 2); + assert_eq!(k1.get() as usize, 1); + assert_eq!(k2.get() as usize, 2); } #[test] @@ -275,8 +275,8 @@ mod tests { assert!(K2.get().is_null()); K1.set(1 as *mut _); K2.set(2 as *mut _); - assert_eq!(K1.get() as uint, 1); - assert_eq!(K2.get() as uint, 2); + assert_eq!(K1.get() as usize, 1); + assert_eq!(K2.get() as usize, 2); } } } diff --git a/src/libstd/sys/common/wtf8.rs b/src/libstd/sys/common/wtf8.rs index 9f3dae34c7a..7efe7d96b71 100644 --- a/src/libstd/sys/common/wtf8.rs +++ b/src/libstd/sys/common/wtf8.rs @@ -158,7 +158,7 @@ impl Wtf8Buf { /// Create an new, empty WTF-8 string with pre-allocated capacity for `n` bytes. #[inline] - pub fn with_capacity(n: uint) -> Wtf8Buf { + pub fn with_capacity(n: usize) -> Wtf8Buf { Wtf8Buf { bytes: Vec::with_capacity(n) } } @@ -214,7 +214,7 @@ impl Wtf8Buf { // Attempt to not use an intermediate buffer by just pushing bytes // directly onto this string. let slice = slice::from_raw_parts_mut( - self.bytes.as_mut_ptr().offset(cur_len as int), + self.bytes.as_mut_ptr().offset(cur_len as isize), 4 ); let used = encode_utf8_raw(code_point.value, mem::transmute(slice)) @@ -234,15 +234,15 @@ impl Wtf8Buf { /// /// # Panics /// - /// Panics if the new capacity overflows `uint`. + /// Panics if the new capacity overflows `usize`. #[inline] - pub fn reserve(&mut self, additional: uint) { + pub fn reserve(&mut self, additional: usize) { self.bytes.reserve(additional) } /// Returns the number of bytes that this string buffer can hold without reallocating. #[inline] - pub fn capacity(&self) -> uint { + pub fn capacity(&self) -> usize { self.bytes.capacity() } @@ -313,7 +313,7 @@ impl Wtf8Buf { /// Panics if `new_len` > current length, /// or if `new_len` is not a code point boundary. #[inline] - pub fn truncate(&mut self, new_len: uint) { + pub fn truncate(&mut self, new_len: usize) { assert!(is_code_point_boundary(self, new_len)); self.bytes.truncate(new_len) } @@ -463,7 +463,7 @@ impl Wtf8 { /// Return the length, in WTF-8 bytes. #[inline] - pub fn len(&self) -> uint { + pub fn len(&self) -> usize { self.bytes.len() } @@ -474,7 +474,7 @@ impl Wtf8 { /// /// Panics if `position` is beyond the end of the string. #[inline] - pub fn ascii_byte_at(&self, position: uint) -> u8 { + pub fn ascii_byte_at(&self, position: usize) -> u8 { match self.bytes[position] { ascii_byte @ 0x00 ... 0x7F => ascii_byte, _ => 0xFF @@ -488,7 +488,7 @@ impl Wtf8 { /// Panics if `position` is not at a code point boundary, /// or is beyond the end of the string. #[inline] - pub fn code_point_at(&self, position: uint) -> CodePoint { + pub fn code_point_at(&self, position: usize) -> CodePoint { let (code_point, _) = self.code_point_range_at(position); code_point } @@ -501,7 +501,7 @@ impl Wtf8 { /// Panics if `position` is not at a code point boundary, /// or is beyond the end of the string. #[inline] - pub fn code_point_range_at(&self, position: uint) -> (CodePoint, uint) { + pub fn code_point_range_at(&self, position: usize) -> (CodePoint, usize) { let (c, n) = char_range_at_raw(&self.bytes, position); (CodePoint { value: c }, n) } @@ -570,7 +570,7 @@ impl Wtf8 { } #[inline] - fn next_surrogate(&self, mut pos: uint) -> Option<(uint, u16)> { + fn next_surrogate(&self, mut pos: usize) -> Option<(usize, u16)> { let mut iter = self.bytes[pos..].iter(); loop { let b = match iter.next() { @@ -792,7 +792,7 @@ fn decode_surrogate_pair(lead: u16, trail: u16) -> char { /// Copied from core::str::StrPrelude::is_char_boundary #[inline] -pub fn is_code_point_boundary(slice: &Wtf8, index: uint) -> bool { +pub fn is_code_point_boundary(slice: &Wtf8, index: usize) -> bool { if index == slice.len() { return true; } match slice.bytes.get(index) { None => false, @@ -802,17 +802,17 @@ pub fn is_code_point_boundary(slice: &Wtf8, index: uint) -> bool { /// Copied from core::str::raw::slice_unchecked #[inline] -pub unsafe fn slice_unchecked(s: &Wtf8, begin: uint, end: uint) -> &Wtf8 { +pub unsafe fn slice_unchecked(s: &Wtf8, begin: usize, end: usize) -> &Wtf8 { // memory layout of an &[u8] and &Wtf8 are the same mem::transmute(slice::from_raw_parts( - s.bytes.as_ptr().offset(begin as int), + s.bytes.as_ptr().offset(begin as isize), end - begin )) } /// Copied from core::str::raw::slice_error_fail #[inline(never)] -pub fn slice_error_fail(s: &Wtf8, begin: uint, end: uint) -> ! { +pub fn slice_error_fail(s: &Wtf8, begin: usize, end: usize) -> ! { assert!(begin <= end); panic!("index {} and/or {} in `{:?}` do not lie on character boundary", begin, end, s); @@ -835,7 +835,7 @@ impl<'a> Iterator for Wtf8CodePoints<'a> { } #[inline] - fn size_hint(&self) -> (uint, Option<uint>) { + fn size_hint(&self) -> (usize, Option<usize>) { let (len, _) = self.bytes.size_hint(); (len.saturating_add(3) / 4, Some(len)) } @@ -869,7 +869,7 @@ impl<'a> Iterator for EncodeWide<'a> { } #[inline] - fn size_hint(&self) -> (uint, Option<uint>) { + fn size_hint(&self) -> (usize, Option<usize>) { let (low, high) = self.code_points.size_hint(); // every code point gets either one u16 or two u16, // so this iterator is between 1 or 2 times as diff --git a/src/libstd/sys/unix/backtrace.rs b/src/libstd/sys/unix/backtrace.rs index 7db64cfb936..b46d390826c 100644 --- a/src/libstd/sys/unix/backtrace.rs +++ b/src/libstd/sys/unix/backtrace.rs @@ -128,7 +128,7 @@ pub fn write(w: &mut Write) -> io::Result<()> { // skipping the first one as it is write itself let iter = (1..cnt).map(|i| { - print(w, i as int, buf[i], buf[i]) + print(w, i as isize, buf[i], buf[i]) }); result::fold(iter, (), |_, _| ()) } @@ -138,7 +138,7 @@ pub fn write(w: &mut Write) -> io::Result<()> { // tracing pub fn write(w: &mut Write) -> io::Result<()> { struct Context<'a> { - idx: int, + idx: isize, writer: &'a mut (Write+'a), last_error: Option<io::Error>, } @@ -222,7 +222,7 @@ pub fn write(w: &mut Write) -> io::Result<()> { } #[cfg(any(target_os = "macos", target_os = "ios"))] -fn print(w: &mut Write, idx: int, addr: *mut libc::c_void, +fn print(w: &mut Write, idx: isize, addr: *mut libc::c_void, _symaddr: *mut libc::c_void) -> io::Result<()> { use intrinsics; #[repr(C)] @@ -248,7 +248,7 @@ fn print(w: &mut Write, idx: int, addr: *mut libc::c_void, } #[cfg(not(any(target_os = "macos", target_os = "ios")))] -fn print(w: &mut Write, idx: int, addr: *mut libc::c_void, +fn print(w: &mut Write, idx: isize, addr: *mut libc::c_void, symaddr: *mut libc::c_void) -> io::Result<()> { use env; use ffi::AsOsStr; @@ -441,7 +441,7 @@ fn print(w: &mut Write, idx: int, addr: *mut libc::c_void, } // Finally, after all that work above, we can emit a symbol. -fn output(w: &mut Write, idx: int, addr: *mut libc::c_void, +fn output(w: &mut Write, idx: isize, addr: *mut libc::c_void, s: Option<&[u8]>) -> io::Result<()> { try!(write!(w, " {:2}: {:2$?} - ", idx, addr, HEX_WIDTH)); match s.and_then(|s| str::from_utf8(s).ok()) { diff --git a/src/libstd/sys/unix/c.rs b/src/libstd/sys/unix/c.rs index 4e9f9c80a18..2514d4bf4a3 100644 --- a/src/libstd/sys/unix/c.rs +++ b/src/libstd/sys/unix/c.rs @@ -167,7 +167,7 @@ extern { #[cfg(any(target_os = "macos", target_os = "ios"))] mod select { - pub const FD_SETSIZE: uint = 1024; + pub const FD_SETSIZE: usize = 1024; #[repr(C)] pub struct fd_set { @@ -175,7 +175,7 @@ mod select { } pub fn fd_set(set: &mut fd_set, fd: i32) { - set.fds_bits[(fd / 32) as uint] |= 1 << ((fd % 32) as uint); + set.fds_bits[(fd / 32) as usize] |= 1 << ((fd % 32) as usize); } } @@ -198,7 +198,7 @@ mod select { } pub fn fd_set(set: &mut fd_set, fd: i32) { - let fd = fd as uint; + let fd = fd as usize; set.fds_bits[fd / usize::BITS as usize] |= 1 << (fd % usize::BITS as usize); } } diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs index 327ff3953aa..2569653811f 100644 --- a/src/libstd/sys/unix/fs.rs +++ b/src/libstd/sys/unix/fs.rs @@ -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 ret = retry(|| unsafe { libc::read(self.fd(), buf.as_mut_ptr() as *mut libc::c_void, @@ -53,7 +53,7 @@ impl FileDesc { } else if ret < 0 { Err(super::last_error()) } else { - Ok(ret as uint) + Ok(ret as usize) } } pub fn write(&self, buf: &[u8]) -> IoResult<()> { @@ -181,7 +181,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!(cstr(p)); mkerr_libc(unsafe { libc::mkdir(p.as_ptr(), mode as libc::mode_t) }) } @@ -204,13 +204,13 @@ pub fn readdir(p: &Path) -> IoResult<Vec<Path>> { } let size = unsafe { rust_dirent_t_size() }; - let mut buf = Vec::<u8>::with_capacity(size as uint); + let mut buf = Vec::<u8>::with_capacity(size as usize); let ptr = buf.as_mut_ptr() as *mut dirent_t; let p = try!(CString::new(p.as_vec())); let dir_ptr = unsafe {opendir(p.as_ptr())}; - if dir_ptr as uint != 0 { + if dir_ptr as usize != 0 { let mut paths = vec!(); let mut entry_ptr = ptr::null_mut(); while unsafe { readdir_r(dir_ptr, ptr, &mut entry_ptr) == 0 } { @@ -239,7 +239,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!(cstr(p)); mkerr_libc(retry(|| unsafe { libc::chmod(p.as_ptr(), mode as libc::mode_t) @@ -251,7 +251,7 @@ pub fn rmdir(p: &Path) -> IoResult<()> { mkerr_libc(unsafe { libc::rmdir(p.as_ptr()) }) } -pub fn chown(p: &Path, uid: int, gid: int) -> IoResult<()> { +pub fn chown(p: &Path, uid: isize, gid: isize) -> IoResult<()> { let p = try!(cstr(p)); mkerr_libc(retry(|| unsafe { libc::chown(p.as_ptr(), uid as libc::uid_t, gid as libc::gid_t) @@ -265,7 +265,7 @@ pub fn readlink(p: &Path) -> IoResult<Path> { if len == -1 { len = 1024; // FIXME: read PATH_MAX from C ffi? } - let mut buf: Vec<u8> = Vec::with_capacity(len as uint); + let mut buf: Vec<u8> = Vec::with_capacity(len as usize); match unsafe { libc::readlink(p, buf.as_ptr() as *mut libc::c_char, len as libc::size_t) as libc::c_int @@ -273,7 +273,7 @@ pub fn readlink(p: &Path) -> IoResult<Path> { -1 => Err(super::last_error()), n => { assert!(n > 0); - unsafe { buf.set_len(n as uint); } + unsafe { buf.set_len(n as usize); } Ok(Path::new(buf)) } } diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index c73d30d543a..724156d81d8 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -199,13 +199,13 @@ pub fn current_exe() -> io::Result<PathBuf> { 0 as libc::size_t); if err != 0 { return Err(io::Error::last_os_error()); } if sz == 0 { return Err(io::Error::last_os_error()); } - let mut v: Vec<u8> = Vec::with_capacity(sz as uint); + let mut v: Vec<u8> = Vec::with_capacity(sz as usize); let err = sysctl(mib.as_mut_ptr(), mib.len() as ::libc::c_uint, v.as_mut_ptr() as *mut libc::c_void, &mut sz, ptr::null_mut(), 0 as libc::size_t); if err != 0 { return Err(io::Error::last_os_error()); } if sz == 0 { return Err(io::Error::last_os_error()); } - v.set_len(sz as uint - 1); // chop off trailing NUL + v.set_len(sz as usize - 1); // chop off trailing NUL Ok(PathBuf::from(OsString::from_vec(v))) } } @@ -249,10 +249,10 @@ pub fn current_exe() -> io::Result<PathBuf> { let mut sz: u32 = 0; _NSGetExecutablePath(ptr::null_mut(), &mut sz); if sz == 0 { return Err(io::Error::last_os_error()); } - let mut v: Vec<u8> = Vec::with_capacity(sz as uint); + let mut v: Vec<u8> = Vec::with_capacity(sz as usize); let err = _NSGetExecutablePath(v.as_mut_ptr() as *mut i8, &mut sz); if err != 0 { return Err(io::Error::last_os_error()); } - v.set_len(sz as uint - 1); // chop off trailing NUL + v.set_len(sz as usize - 1); // chop off trailing NUL Ok(PathBuf::from(OsString::from_vec(v))) } } diff --git a/src/libstd/sys/unix/pipe.rs b/src/libstd/sys/unix/pipe.rs index daa981720f6..f0071295bf2 100644 --- a/src/libstd/sys/unix/pipe.rs +++ b/src/libstd/sys/unix/pipe.rs @@ -151,7 +151,7 @@ impl UnixStream { ret } - pub fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { + pub fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> { let fd = self.fd(); let dolock = || self.lock_nonblocking(); let doread = |nb| unsafe { @@ -167,7 +167,7 @@ impl UnixStream { pub fn write(&mut self, buf: &[u8]) -> IoResult<()> { let fd = self.fd(); let dolock = || self.lock_nonblocking(); - let dowrite = |nb: bool, buf: *const u8, len: uint| unsafe { + let dowrite = |nb: bool, buf: *const u8, len: usize| unsafe { let flags = if nb {c::MSG_DONTWAIT} else {0}; libc::send(fd, buf as *const _, diff --git a/src/libstd/sys/unix/process.rs b/src/libstd/sys/unix/process.rs index df0e8de3ff1..0d35ace185d 100644 --- a/src/libstd/sys/unix/process.rs +++ b/src/libstd/sys/unix/process.rs @@ -49,11 +49,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 r = libc::funcs::posix88::signal::kill(pid, signal as c_int); mkerr_libc(r) } @@ -454,7 +454,7 @@ impl Process { // with process timeouts, but libgreen should get there first // (currently libuv doesn't handle old signal handlers). if drain(read_fd) { - let i: uint = unsafe { mem::transmute(old.sa_handler) }; + let i: usize = unsafe { mem::transmute(old.sa_handler) }; if i != 0 { assert!(old.sa_flags & c::SA_SIGINFO == 0); (old.sa_handler)(c::SIGCHLD); @@ -618,8 +618,8 @@ fn translate_status(status: c_int) -> ProcessExit { } if imp::WIFEXITED(status) { - ExitStatus(imp::WEXITSTATUS(status) as int) + ExitStatus(imp::WEXITSTATUS(status) as isize) } else { - ExitSignal(imp::WTERMSIG(status) as int) + ExitSignal(imp::WTERMSIG(status) as isize) } } diff --git a/src/libstd/sys/unix/stack_overflow.rs b/src/libstd/sys/unix/stack_overflow.rs index 35706682047..6887095c53a 100644 --- a/src/libstd/sys/unix/stack_overflow.rs +++ b/src/libstd/sys/unix/stack_overflow.rs @@ -60,7 +60,7 @@ mod imp { // 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] unsafe extern fn signal_handler(signum: libc::c_int, @@ -82,7 +82,7 @@ mod imp { stack::record_sp_limit(0); let guard = thread_info::stack_guard(); - let addr = (*info).si_addr as uint; + let addr = (*info).si_addr as usize; if guard == 0 || addr < guard - PAGE_SIZE || addr >= guard { term(signum); @@ -101,7 +101,7 @@ mod imp { panic!("failed to get page size"); } - PAGE_SIZE = psize as uint; + PAGE_SIZE = psize as usize; let mut action: sigaction = mem::zeroed(); action.sa_flags = SA_SIGINFO | SA_ONSTACK; diff --git a/src/libstd/sys/unix/sync.rs b/src/libstd/sys/unix/sync.rs index c7d704922cb..3c05fd602be 100644 --- a/src/libstd/sys/unix/sync.rs +++ b/src/libstd/sys/unix/sync.rs @@ -66,24 +66,24 @@ mod os { #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] - const __PTHREAD_MUTEX_SIZE__: uint = 56; + const __PTHREAD_MUTEX_SIZE__: usize = 56; #[cfg(any(target_arch = "x86", target_arch = "arm"))] - const __PTHREAD_MUTEX_SIZE__: uint = 40; + const __PTHREAD_MUTEX_SIZE__: usize = 40; #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] - const __PTHREAD_COND_SIZE__: uint = 40; + const __PTHREAD_COND_SIZE__: usize = 40; #[cfg(any(target_arch = "x86", target_arch = "arm"))] - const __PTHREAD_COND_SIZE__: uint = 24; + const __PTHREAD_COND_SIZE__: usize = 24; #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] - const __PTHREAD_RWLOCK_SIZE__: uint = 192; + const __PTHREAD_RWLOCK_SIZE__: usize = 192; #[cfg(any(target_arch = "x86", target_arch = "arm"))] - const __PTHREAD_RWLOCK_SIZE__: uint = 124; + const __PTHREAD_RWLOCK_SIZE__: usize = 124; const _PTHREAD_MUTEX_SIG_INIT: libc::c_long = 0x32AAABA7; const _PTHREAD_COND_SIG_INIT: libc::c_long = 0x3CB0B1BB; @@ -125,15 +125,15 @@ mod os { // minus 8 because we have an 'align' field #[cfg(target_arch = "x86_64")] - const __SIZEOF_PTHREAD_MUTEX_T: uint = 40 - 8; + const __SIZEOF_PTHREAD_MUTEX_T: usize = 40 - 8; #[cfg(any(target_arch = "x86", target_arch = "arm", target_arch = "mips", target_arch = "mipsel", target_arch = "powerpc"))] - const __SIZEOF_PTHREAD_MUTEX_T: uint = 24 - 8; + const __SIZEOF_PTHREAD_MUTEX_T: usize = 24 - 8; #[cfg(target_arch = "aarch64")] - const __SIZEOF_PTHREAD_MUTEX_T: uint = 48 - 8; + const __SIZEOF_PTHREAD_MUTEX_T: usize = 48 - 8; #[cfg(any(target_arch = "x86_64", target_arch = "x86", @@ -142,18 +142,18 @@ mod os { target_arch = "mips", target_arch = "mipsel", target_arch = "powerpc"))] - const __SIZEOF_PTHREAD_COND_T: uint = 48 - 8; + const __SIZEOF_PTHREAD_COND_T: usize = 48 - 8; #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] - const __SIZEOF_PTHREAD_RWLOCK_T: uint = 56 - 8; + const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56 - 8; #[cfg(any(target_arch = "x86", target_arch = "arm", target_arch = "mips", target_arch = "mipsel", target_arch = "powerpc"))] - const __SIZEOF_PTHREAD_RWLOCK_T: uint = 32 - 8; + const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32 - 8; #[repr(C)] pub struct pthread_mutex_t { diff --git a/src/libstd/sys/unix/tcp.rs b/src/libstd/sys/unix/tcp.rs index 2a6994824c7..a9f2198208b 100644 --- a/src/libstd/sys/unix/tcp.rs +++ b/src/libstd/sys/unix/tcp.rs @@ -64,7 +64,7 @@ impl TcpListener { pub fn fd(&self) -> sock_t { self.inner.fd() } - pub fn listen(self, backlog: int) -> IoResult<TcpAcceptor> { + pub fn listen(self, backlog: isize) -> IoResult<TcpAcceptor> { match unsafe { libc::listen(self.fd(), backlog as libc::c_int) } { -1 => Err(last_net_error()), _ => { diff --git a/src/libstd/sys/unix/timer.rs b/src/libstd/sys/unix/timer.rs index b6d2aca9a52..d9a162302fc 100644 --- a/src/libstd/sys/unix/timer.rs +++ b/src/libstd/sys/unix/timer.rs @@ -69,7 +69,7 @@ pub trait Callback { } pub struct Timer { - id: uint, + id: usize, inner: Option<Box<Inner>>, } @@ -78,7 +78,7 @@ pub struct Inner { interval: u64, repeat: bool, target: u64, - id: uint, + id: usize, } pub enum Req { @@ -87,7 +87,7 @@ pub enum Req { // Remove a timer based on its id and then send it back on the channel // provided - RemoveTimer(uint, Sender<Box<Inner>>), + RemoveTimer(usize, Sender<Box<Inner>>), } // returns the current time (in milliseconds) @@ -121,7 +121,7 @@ fn helper(input: libc::c_int, messages: Receiver<Req>, _: ()) { // signals the first requests in the queue, possible re-enqueueing it. fn signal(active: &mut Vec<Box<Inner>>, - dead: &mut Vec<(uint, Box<Inner>)>) { + dead: &mut Vec<(usize, Box<Inner>)>) { if active.is_empty() { return } let mut timer = active.remove(0); @@ -216,7 +216,7 @@ fn helper(input: libc::c_int, messages: Receiver<Req>, _: ()) { impl Timer { pub fn new() -> IoResult<Timer> { - // See notes above regarding using int return value + // See notes above regarding using isize return value // instead of () HELPER.boot(|| {}, helper); @@ -244,7 +244,7 @@ impl Timer { tv_nsec: ((ms % 1000) * 1000000) as libc::c_long, }; while unsafe { libc::nanosleep(&to_sleep, &mut to_sleep) } != 0 { - if os::errno() as int != libc::EINTR as int { + if os::errno() as isize != libc::EINTR as isize { panic!("failed to sleep, but not because of EINTR?"); } } diff --git a/src/libstd/sys/unix/tty.rs b/src/libstd/sys/unix/tty.rs index e4973a8f9f3..2f6fd713bfb 100644 --- a/src/libstd/sys/unix/tty.rs +++ b/src/libstd/sys/unix/tty.rs @@ -46,7 +46,7 @@ impl TTY { } } - pub fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { + pub fn read(&mut self, buf: &mut [u8]) -> IoResult<usize> { self.fd.read(buf) } pub fn write(&mut self, buf: &[u8]) -> IoResult<()> { @@ -56,7 +56,7 @@ impl TTY { Err(sys_common::unimpl()) } - pub fn get_winsize(&mut self) -> IoResult<(int, int)> { + pub fn get_winsize(&mut self) -> IoResult<(isize, isize)> { unsafe { #[repr(C)] struct winsize { @@ -74,7 +74,7 @@ impl TTY { detail: None, }) } else { - Ok((size.ws_col as int, size.ws_row as int)) + Ok((size.ws_col as isize, size.ws_row as isize)) } } } diff --git a/src/libstd/sys/windows/backtrace.rs b/src/libstd/sys/windows/backtrace.rs index ffa4b37b487..509205a20b1 100644 --- a/src/libstd/sys/windows/backtrace.rs +++ b/src/libstd/sys/windows/backtrace.rs @@ -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 { diff --git a/src/libstd/sys/windows/fs.rs b/src/libstd/sys/windows/fs.rs index e7a01478908..3330130c770 100644 --- a/src/libstd/sys/windows/fs.rs +++ b/src/libstd/sys/windows/fs.rs @@ -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(()) } diff --git a/src/libstd/sys/windows/pipe.rs b/src/libstd/sys/windows/pipe.rs index 17fdd6755c6..064c003bd15 100644 --- a/src/libstd/sys/windows/pipe.rs +++ b/src/libstd/sys/windows/pipe.rs @@ -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(()) } diff --git a/src/libstd/sys/windows/process.rs b/src/libstd/sys/windows/process.rs index e08a6e6b3cd..297f6e173ab 100644 --- a/src/libstd/sys/windows/process.rs +++ b/src/libstd/sys/windows/process.rs @@ -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; } diff --git a/src/libstd/sys/windows/stack_overflow.rs b/src/libstd/sys/windows/stack_overflow.rs index b0410701ee1..79b7de4f341 100644 --- a/src/libstd/sys/windows/stack_overflow.rs +++ b/src/libstd/sys/windows/stack_overflow.rs @@ -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" { diff --git a/src/libstd/sys/windows/tcp.rs b/src/libstd/sys/windows/tcp.rs index 6e46bf97d1b..2ac8ac10aa9 100644 --- a/src/libstd/sys/windows/tcp.rs +++ b/src/libstd/sys/windows/tcp.rs @@ -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()), diff --git a/src/libstd/sys/windows/thread.rs b/src/libstd/sys/windows/thread.rs index d1d4ad90081..98e4a737c7b 100644 --- a/src/libstd/sys/windows/thread.rs +++ b/src/libstd/sys/windows/thread.rs @@ -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() {} } diff --git a/src/libstd/sys/windows/thread_local.rs b/src/libstd/sys/windows/thread_local.rs index c908c791247..cbabab8acb7 100644 --- a/src/libstd/sys/windows/thread_local.rs +++ b/src/libstd/sys/windows/thread_local.rs @@ -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; diff --git a/src/libstd/sys/windows/timer.rs b/src/libstd/sys/windows/timer.rs index 9bcae926eea..8856cc26b2e 100644 --- a/src/libstd/sys/windows/timer.rs +++ b/src/libstd/sys/windows/timer.rs @@ -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)); } } } diff --git a/src/libstd/sys/windows/tty.rs b/src/libstd/sys/windows/tty.rs index 52f4cce4aa3..38faabf3276 100644 --- a/src/libstd/sys/windows/tty.rs +++ b/src/libstd/sys/windows/tty.rs @@ -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)), } } } |
