Skip to content

Commit 380d402

Browse files
rrichardsoncarllerche
authored andcommitted
changed uint and int to usize and isize respectively
1 parent f70a60e commit 380d402

File tree

13 files changed

+57
-59
lines changed

13 files changed

+57
-59
lines changed

src/errno.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ impl SysError {
2525
SysError { kind: kind }
2626
}
2727

28-
pub fn errno(&self) -> uint {
29-
self.kind as uint
28+
pub fn errno(&self) -> usize {
29+
self.kind as usize
3030
}
3131

3232
pub fn desc(&self) -> &'static str {

src/features.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@ mod os {
99
// * pipe2: 2.6.27
1010
// * accept4: 2.6.28
1111

12-
static VERS_UNKNOWN: uint = 1;
13-
static VERS_2_6_18: uint = 2;
14-
static VERS_2_6_27: uint = 3;
15-
static VERS_2_6_28: uint = 4;
16-
static VERS_3: uint = 5;
12+
static VERS_UNKNOWN: usize = 1;
13+
static VERS_2_6_18: usize = 2;
14+
static VERS_2_6_27: usize = 3;
15+
static VERS_2_6_28: usize = 4;
16+
static VERS_3: usize = 5;
1717

18-
fn parse_kernel_version() -> uint {
18+
fn parse_kernel_version() -> usize {
1919
let u = uname();
2020

2121
#[inline]
22-
fn digit(dst: &mut uint, b: u8) {
22+
fn digit(dst: &mut usize, b: u8) {
2323
*dst *= 10;
24-
*dst += (b - b'0') as uint;
24+
*dst += (b - b'0') as usize;
2525
}
2626

27-
let mut curr = 0u;
27+
let mut curr = 0us;
2828
let mut major = 0;
2929
let mut minor = 0;
3030
let mut patch = 0;
@@ -70,8 +70,8 @@ mod os {
7070
}
7171
}
7272

73-
fn kernel_version() -> uint {
74-
static mut KERNEL_VERS: uint = 0;
73+
fn kernel_version() -> usize {
74+
static mut KERNEL_VERS: usize = 0;
7575

7676
unsafe {
7777
if KERNEL_VERS == 0 {

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#![crate_name = "nix"]
22

33
#![feature(linkage)]
4-
#![feature(int_uint)]
54
#![allow(unstable)]
65
#![allow(non_camel_case_types)]
76

src/sched.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,38 +31,38 @@ pub static CLONE_IO: CloneFlags = 0x80000000;
3131
#[cfg(target_arch = "x86_64")]
3232
mod cpuset_attribs {
3333
use super::CpuMask;
34-
pub const CPU_SETSIZE: uint = 1024u;
35-
pub const CPU_MASK_BITS: uint = 64u;
34+
pub const CPU_SETSIZE: usize = 1024us;
35+
pub const CPU_MASK_BITS: usize = 64us;
3636

3737
#[inline]
38-
pub fn set_cpu_mask_flag(cur: CpuMask, bit: uint) -> CpuMask {
38+
pub fn set_cpu_mask_flag(cur: CpuMask, bit: usize) -> CpuMask {
3939
cur | (1u64 << bit)
4040
}
4141

4242
#[inline]
43-
pub fn clear_cpu_mask_flag(cur: CpuMask, bit: uint) -> CpuMask {
43+
pub fn clear_cpu_mask_flag(cur: CpuMask, bit: usize) -> CpuMask {
4444
cur & !(1u64 << bit)
4545
}
4646
}
4747

4848
#[cfg(target_arch = "x86")]
4949
mod cpuset_attribs {
5050
use super::CpuMask;
51-
pub const CPU_SETSIZE: uint = 1024u;
52-
pub const CPU_MASK_BITS: uint = 32u;
51+
pub const CPU_SETSIZE: usize = 1024us;
52+
pub const CPU_MASK_BITS: usize = 32us;
5353

5454
#[inline]
55-
pub fn set_cpu_mask_flag(cur: CpuMask, bit: uint) -> CpuMask {
55+
pub fn set_cpu_mask_flag(cur: CpuMask, bit: usize) -> CpuMask {
5656
cur | (1u32 << bit)
5757
}
5858

5959
#[inline]
60-
pub fn clear_cpu_mask_flag(cur: CpuMask, bit: uint) -> CpuMask {
60+
pub fn clear_cpu_mask_flag(cur: CpuMask, bit: usize) -> CpuMask {
6161
cur & !(1u32 << bit)
6262
}
6363
}
6464

65-
pub type CloneCb<'a> = Box<FnMut() -> int + 'a>;
65+
pub type CloneCb<'a> = Box<FnMut() -> isize + 'a>;
6666

6767
// A single CPU mask word
6868
pub type CpuMask = c_ulong;
@@ -81,14 +81,14 @@ impl CpuSet {
8181
}
8282
}
8383

84-
pub fn set(&mut self, field: uint) {
84+
pub fn set(&mut self, field: usize) {
8585
let word = field / cpuset_attribs::CPU_MASK_BITS;
8686
let bit = field % cpuset_attribs::CPU_MASK_BITS;
8787

8888
self.cpu_mask[word] = cpuset_attribs::set_cpu_mask_flag(self.cpu_mask[word], bit);
8989
}
9090

91-
pub fn unset(&mut self, field: uint) {
91+
pub fn unset(&mut self, field: usize) {
9292
let word = field / cpuset_attribs::CPU_MASK_BITS;
9393
let bit = field % cpuset_attribs::CPU_MASK_BITS;
9494

@@ -123,7 +123,7 @@ mod ffi {
123123
}
124124
}
125125

126-
pub fn sched_setaffinity(pid: int, cpuset: &CpuSet) -> SysResult<()> {
126+
pub fn sched_setaffinity(pid: isize, cpuset: &CpuSet) -> SysResult<()> {
127127
use libc::{pid_t, size_t};
128128

129129
let res = unsafe {
@@ -144,7 +144,7 @@ pub fn clone(mut cb: CloneCb, stack: &mut [u8], flags: CloneFlags) -> SysResult<
144144
}
145145

146146
let res = unsafe {
147-
let ptr = stack.as_mut_ptr().offset(stack.len() as int);
147+
let ptr = stack.as_mut_ptr().offset(stack.len() as isize);
148148
ffi::clone(mem::transmute(callback), ptr as *mut c_void, flags, &mut cb)
149149
};
150150

src/sys/epoll.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ pub fn epoll_ctl(epfd: Fd, op: EpollOp, fd: Fd, event: &EpollEvent) -> SysResult
102102
}
103103

104104
#[inline]
105-
pub fn epoll_wait(epfd: Fd, events: &mut [EpollEvent], timeout_ms: uint) -> SysResult<uint> {
105+
pub fn epoll_wait(epfd: Fd, events: &mut [EpollEvent], timeout_ms: usize) -> SysResult<usize> {
106106
let res = unsafe {
107107
ffi::epoll_wait(epfd, events.as_mut_ptr(), events.len() as c_int, timeout_ms as c_int)
108108
};
@@ -111,5 +111,5 @@ pub fn epoll_wait(epfd: Fd, events: &mut [EpollEvent], timeout_ms: uint) -> SysR
111111
return Err(SysError::last());
112112
}
113113

114-
Ok(res as uint)
114+
Ok(res as usize)
115115
}

src/sys/event.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ mod ffi {
2020
pub flags: EventFlag, // 2
2121
pub fflags: FilterFlag, // 4
2222
pub data: intptr_t, // 8
23-
pub udata: uint // 8
23+
pub udata: usize // 8
2424
}
2525

2626
// Bug in rustc, cannot determine that kevent is #[repr(C)]
@@ -171,7 +171,7 @@ pub fn kqueue() -> SysResult<Fd> {
171171
pub fn kevent(kq: Fd,
172172
changelist: &[KEvent],
173173
eventlist: &mut [KEvent],
174-
timeout_ms: uint) -> SysResult<uint> {
174+
timeout_ms: usize) -> SysResult<usize> {
175175

176176
// Convert ms to timespec
177177
let timeout = timespec {
@@ -193,16 +193,16 @@ pub fn kevent(kq: Fd,
193193
return Err(SysError::last());
194194
}
195195

196-
return Ok(res as uint)
196+
return Ok(res as usize)
197197
}
198198

199199
#[inline]
200200
pub fn ev_set(ev: &mut KEvent,
201-
ident: uint,
201+
ident: usize,
202202
filter: EventFilter,
203203
flags: EventFlag,
204204
fflags: FilterFlag,
205-
udata: uint) {
205+
udata: usize) {
206206

207207
ev.ident = ident as uintptr_t;
208208
ev.filter = filter;

src/sys/eventfd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ bitflags!(
1111
}
1212
);
1313

14-
pub fn eventfd(initval: uint, flags: EventFdFlag) -> SysResult<Fd> {
14+
pub fn eventfd(initval: usize, flags: EventFdFlag) -> SysResult<Fd> {
1515
type F = unsafe extern "C" fn(initval: c_uint, flags: c_int) -> c_int;
1616

1717
extern {

src/sys/mman.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ mod consts {
6464
pub const MS_SYNC : MmapSync = 4;
6565
pub const MS_INVALIDATE : MmapSync = 2;
6666

67-
pub const MAP_FAILED: int = -1;
67+
pub const MAP_FAILED: isize = -1;
6868
}
6969

7070
#[cfg(any(target_os = "macos",
@@ -109,7 +109,7 @@ mod consts {
109109
pub const MS_KILLPAGES : MmapSync = 0x0004; /* invalidate pages, leave mapped */
110110
pub const MS_DEACTIVATE : MmapSync = 0x0008; /* deactivate pages, leave mapped */
111111

112-
pub const MAP_FAILED: int = -1;
112+
pub const MAP_FAILED: isize = -1;
113113
}
114114

115115
mod ffi {
@@ -147,7 +147,7 @@ pub fn munlock(addr: *const c_void, length: size_t) -> SysResult<()> {
147147
pub fn mmap(addr: *mut c_void, length: size_t, prot: MmapProt, flags: MmapFlag, fd: Fd, offset: off_t) -> SysResult<*mut c_void> {
148148
let ret = unsafe { ffi::mmap(addr, length, prot, flags, fd, offset) };
149149

150-
if ret as int == MAP_FAILED {
150+
if ret as isize == MAP_FAILED {
151151
Err(SysError::last())
152152
} else {
153153
Ok(ret)

src/sys/socket.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ pub fn socket(domain: AddressFamily, mut ty: SockType, flags: SockFlag) -> SysRe
252252
Ok(res)
253253
}
254254

255-
pub fn listen(sockfd: Fd, backlog: uint) -> SysResult<()> {
255+
pub fn listen(sockfd: Fd, backlog: usize) -> SysResult<()> {
256256
let res = unsafe { ffi::listen(sockfd, backlog as c_int) };
257257
from_ffi(res)
258258
}
@@ -368,7 +368,7 @@ mod sa_helpers {
368368
}
369369
}
370370

371-
pub fn recvfrom(sockfd: Fd, buf: &mut [u8]) -> SysResult<(uint, SockAddr)> {
371+
pub fn recvfrom(sockfd: Fd, buf: &mut [u8]) -> SysResult<(usize, SockAddr)> {
372372
let saddr : sockaddr_storage = unsafe { mem::zeroed() };
373373
let mut len = mem::size_of::<sockaddr_storage>() as socklen_t;
374374

@@ -380,7 +380,7 @@ pub fn recvfrom(sockfd: Fd, buf: &mut [u8]) -> SysResult<(uint, SockAddr)> {
380380
return Err(SysError::last());
381381
}
382382

383-
Ok((ret as uint,
383+
Ok((ret as usize,
384384
match saddr.ss_family as i32 {
385385
AF_INET => { sa_helpers::to_sockaddr_ipv4(&saddr) },
386386
AF_INET6 => { sa_helpers::to_sockaddr_ipv6(&saddr) },
@@ -427,7 +427,7 @@ fn sendto_sockaddr<T>(sockfd: Fd, buf: &[u8], flags: SockMessageFlags, addr: &T)
427427
}
428428
}
429429

430-
pub fn sendto(sockfd: Fd, buf: &[u8], addr: &SockAddr, flags: SockMessageFlags) -> SysResult<uint> {
430+
pub fn sendto(sockfd: Fd, buf: &[u8], addr: &SockAddr, flags: SockMessageFlags) -> SysResult<usize> {
431431
use self::SockAddr::*;
432432

433433
let ret = match *addr {
@@ -439,7 +439,7 @@ pub fn sendto(sockfd: Fd, buf: &[u8], addr: &SockAddr, flags: SockMessageFlags)
439439
if ret < 0 {
440440
Err(SysError::last())
441441
} else {
442-
Ok(ret as uint)
442+
Ok(ret as usize)
443443
}
444444
}
445445

@@ -450,7 +450,7 @@ pub struct linger {
450450
pub l_linger: c_int
451451
}
452452

453-
pub fn getsockopt<T>(fd: Fd, level: SockLevel, opt: SockOpt, val: &mut T) -> SysResult<uint> {
453+
pub fn getsockopt<T>(fd: Fd, level: SockLevel, opt: SockOpt, val: &mut T) -> SysResult<usize> {
454454
let mut len = mem::size_of::<T>() as socklen_t;
455455

456456
let res = unsafe {
@@ -464,7 +464,7 @@ pub fn getsockopt<T>(fd: Fd, level: SockLevel, opt: SockOpt, val: &mut T) -> Sys
464464
return Err(SysError::last());
465465
}
466466

467-
Ok(len as uint)
467+
Ok(len as usize)
468468
}
469469

470470
pub fn setsockopt<T>(fd: Fd, level: SockLevel, opt: SockOpt, val: &T) -> SysResult<()> {

src/sys/stat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub fn mknod(path: &Path, kind: SFlag, perm: FilePermission, dev: dev_t) -> SysR
4242
}
4343

4444
#[cfg(target_os = "linux")]
45-
const MINORBITS: uint = 20;
45+
const MINORBITS: usize = 20;
4646

4747
#[cfg(target_os = "linux")]
4848
pub fn mkdev(major: u64, minor: u64) -> dev_t {

src/sys/utsname.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ mod ffi {
1313
}
1414

1515

16-
const UTSNAME_LEN: uint = 65;
16+
const UTSNAME_LEN: usize = 65;
1717

1818
#[repr(C)]
1919
#[derive(Copy)]

src/unistd.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ pub fn fork() -> SysResult<Fork> {
9797
// let mut v = Vec::new();
9898
// let iov = Iovec::from_slice(immutable_vec.as_slice());
9999
// v.push(iov);
100-
// let _:SysResult<uint> = readv(fd, v.as_slice());
100+
// let _:SysResult<usize> = readv(fd, v.as_slice());
101101

102102
// We do not want <T> to appear in ffi functions, so we provide this aliases.
103103
type IovecR = Iovec<ToRead>;
@@ -117,7 +117,7 @@ pub struct Iovec<T> {
117117
impl <T> Iovec<T> {
118118
#[inline]
119119
pub fn as_slice<'a>(&'a self) -> &'a [u8] {
120-
unsafe { mem::transmute(RawSlice { data: self.iov_base as *const u8, len: self.iov_len as uint }) }
120+
unsafe { mem::transmute(RawSlice { data: self.iov_base as *const u8, len: self.iov_len as usize }) }
121121
}
122122
}
123123

@@ -271,42 +271,42 @@ pub fn close(fd: Fd) -> SysResult<()> {
271271
from_ffi(res)
272272
}
273273

274-
pub fn read(fd: Fd, buf: &mut [u8]) -> SysResult<uint> {
274+
pub fn read(fd: Fd, buf: &mut [u8]) -> SysResult<usize> {
275275
let res = unsafe { ffi::read(fd, buf.as_mut_ptr() as *mut c_void, buf.len() as size_t) };
276276

277277
if res < 0 {
278278
return Err(SysError::last());
279279
}
280280

281-
return Ok(res as uint)
281+
return Ok(res as usize)
282282
}
283283

284-
pub fn write(fd: Fd, buf: &[u8]) -> SysResult<uint> {
284+
pub fn write(fd: Fd, buf: &[u8]) -> SysResult<usize> {
285285
let res = unsafe { ffi::write(fd, buf.as_ptr() as *const c_void, buf.len() as size_t) };
286286

287287
if res < 0 {
288288
return Err(SysError::last());
289289
}
290290

291-
return Ok(res as uint)
291+
return Ok(res as usize)
292292
}
293293

294-
pub fn writev(fd: Fd, iov: &[Iovec<ToWrite>]) -> SysResult<uint> {
294+
pub fn writev(fd: Fd, iov: &[Iovec<ToWrite>]) -> SysResult<usize> {
295295
let res = unsafe { ffi::writev(fd, iov.as_ptr(), iov.len() as c_int) };
296296
if res < 0 {
297297
return Err(SysError::last());
298298
}
299299

300-
return Ok(res as uint)
300+
return Ok(res as usize)
301301
}
302302

303-
pub fn readv(fd: Fd, iov: &mut [Iovec<ToRead>]) -> SysResult<uint> {
303+
pub fn readv(fd: Fd, iov: &mut [Iovec<ToRead>]) -> SysResult<usize> {
304304
let res = unsafe { ffi::readv(fd, iov.as_ptr(), iov.len() as c_int) };
305305
if res < 0 {
306306
return Err(SysError::last());
307307
}
308308

309-
return Ok(res as uint)
309+
return Ok(res as usize)
310310
}
311311

312312
pub fn pipe() -> SysResult<(Fd, Fd)> {

tests/unistd.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![allow(unstable)]
2-
#![feature(int_uint)]
32

43
extern crate nix;
54

@@ -43,7 +42,7 @@ mod test {
4342
let read_res = read(reader, read_buf.as_mut_slice());
4443
// Successful read
4544
assert!(read_res.is_ok());
46-
let read = read_res.ok().unwrap() as uint;
45+
let read = read_res.ok().unwrap() as usize;
4746
// Check we have read as much as we written
4847
assert_eq!(read, written);
4948
// Check equality of written and read data

0 commit comments

Comments
 (0)