@@ -44,9 +44,9 @@ use unstable::finally::Finally;
44
44
use sync:: atomics:: { AtomicInt , INIT_ATOMIC_INT , SeqCst } ;
45
45
46
46
/// Delegates to the libc close() function, returning the same return value.
47
- pub fn close ( fd : c_int ) -> c_int {
47
+ pub fn close ( fd : int ) -> int {
48
48
unsafe {
49
- libc:: close ( fd)
49
+ libc:: close ( fd as c_int ) as int
50
50
}
51
51
}
52
52
@@ -57,7 +57,7 @@ static BUF_BYTES : uint = 2048u;
57
57
pub fn getcwd ( ) -> Path {
58
58
use c_str:: CString ;
59
59
60
- let mut buf = [ 0 as libc :: c_char , ..BUF_BYTES ] ;
60
+ let mut buf = [ 0 as c_char , ..BUF_BYTES ] ;
61
61
unsafe {
62
62
if libc:: getcwd ( buf. as_mut_ptr ( ) , buf. len ( ) as size_t ) . is_null ( ) {
63
63
fail ! ( )
@@ -164,7 +164,7 @@ pub fn env() -> ~[(~str,~str)] {
164
164
os:: last_os_error( ) ) ;
165
165
}
166
166
let mut result = ~[ ] ;
167
- c_str:: from_c_multistring ( ch as * libc :: c_char , None , |cstr| {
167
+ c_str:: from_c_multistring ( ch as * c_char , None , |cstr| {
168
168
result. push ( cstr. as_str ( ) . unwrap ( ) . to_owned ( ) ) ;
169
169
} ) ;
170
170
FreeEnvironmentStringsA ( ch) ;
@@ -173,7 +173,7 @@ pub fn env() -> ~[(~str,~str)] {
173
173
#[ cfg( unix) ]
174
174
unsafe fn get_env_pairs ( ) -> ~[ ~str ] {
175
175
extern {
176
- fn rust_env_pairs ( ) -> * * libc :: c_char ;
176
+ fn rust_env_pairs ( ) -> * * c_char ;
177
177
}
178
178
let environ = rust_env_pairs ( ) ;
179
179
if environ as uint == 0 {
@@ -306,9 +306,9 @@ pub struct Pipe {
306
306
#[ cfg( unix) ]
307
307
pub fn pipe ( ) -> Pipe {
308
308
unsafe {
309
- let mut fds = Pipe { input : 0 as c_int ,
310
- out : 0 as c_int } ;
311
- assert_eq ! ( libc:: pipe( & mut fds. input) , ( 0 as c_int ) ) ;
309
+ let mut fds = Pipe { input : 0 ,
310
+ out : 0 } ;
311
+ assert_eq ! ( libc:: pipe( & mut fds. input) , 0 ) ;
312
312
return Pipe { input : fds. input , out : fds. out } ;
313
313
}
314
314
}
@@ -321,13 +321,13 @@ pub fn pipe() -> Pipe {
321
321
// fully understand. Here we explicitly make the pipe non-inheritable,
322
322
// which means to pass it to a subprocess they need to be duplicated
323
323
// first, as in std::run.
324
- let mut fds = Pipe { input : 0 as c_int ,
325
- out : 0 as c_int } ;
324
+ let mut fds = Pipe { input : 0 ,
325
+ out : 0 } ;
326
326
let res = libc:: pipe ( & mut fds. input , 1024 as :: libc:: c_uint ,
327
327
( libc:: O_BINARY | libc:: O_NOINHERIT ) as c_int ) ;
328
- assert_eq ! ( res, 0 as c_int ) ;
329
- assert ! ( ( fds. input != -1 as c_int && fds. input != 0 as c_int ) ) ;
330
- assert ! ( ( fds. out != -1 as c_int && fds. input != 0 as c_int ) ) ;
328
+ assert_eq ! ( res, 0 ) ;
329
+ assert ! ( ( fds. input != -1 && fds. input != 0 ) ) ;
330
+ assert ! ( ( fds. out != -1 && fds. input != 0 ) ) ;
331
331
return Pipe { input : fds. input , out : fds. out } ;
332
332
}
333
333
}
@@ -699,7 +699,7 @@ pub fn get_exit_status() -> int {
699
699
}
700
700
701
701
#[ cfg( target_os = "macos" ) ]
702
- unsafe fn load_argc_and_argv ( argc : c_int , argv : * * c_char ) -> ~[ ~str ] {
702
+ unsafe fn load_argc_and_argv ( argc : int , argv : * * c_char ) -> ~[ ~str ] {
703
703
let mut args = ~[ ] ;
704
704
for i in range ( 0 u, argc as uint ) {
705
705
args. push ( str:: raw:: from_c_str ( * argv. offset ( i as int ) ) ) ;
@@ -715,7 +715,7 @@ unsafe fn load_argc_and_argv(argc: c_int, argv: **c_char) -> ~[~str] {
715
715
#[ cfg( target_os = "macos" ) ]
716
716
fn real_args ( ) -> ~[ ~str ] {
717
717
unsafe {
718
- let ( argc, argv) = ( * _NSGetArgc ( ) as c_int ,
718
+ let ( argc, argv) = ( * _NSGetArgc ( ) as int ,
719
719
* _NSGetArgv ( ) as * * c_char ) ;
720
720
load_argc_and_argv ( argc, argv)
721
721
}
@@ -833,7 +833,7 @@ pub struct MemoryMap {
833
833
/// Pointer to the memory created or modified by this map.
834
834
data : * mut u8 ,
835
835
/// Number of bytes this map applies to
836
- len : size_t ,
836
+ len : uint ,
837
837
/// Type of mapping
838
838
kind : MemoryMapKind
839
839
}
@@ -842,7 +842,7 @@ pub struct MemoryMap {
842
842
pub enum MemoryMapKind {
843
843
/// Memory-mapped file. On Windows, the inner pointer is a handle to the mapping, and
844
844
/// corresponds to `CreateFileMapping`. Elsewhere, it is null.
845
- MapFile ( * c_void ) ,
845
+ MapFile ( * u8 ) ,
846
846
/// Virtual memory map. Usually used to change the permissions of a given chunk of memory.
847
847
/// Corresponds to `VirtualAlloc` on Windows.
848
848
MapVirtual
@@ -857,7 +857,7 @@ pub enum MapOption {
857
857
/// The memory should be executable
858
858
MapExecutable ,
859
859
/// Create a map for a specific address range. Corresponds to `MAP_FIXED` on POSIX.
860
- MapAddr ( * c_void ) ,
860
+ MapAddr ( * u8 ) ,
861
861
/// Create a memory mapping for a file with a given fd.
862
862
MapFd ( c_int ) ,
863
863
/// When using `MapFd`, the start of the map is `uint` bytes from the start of the file.
@@ -881,7 +881,7 @@ pub enum MapError {
881
881
/// using `MapFd`, the target of the fd didn't have enough resources to fulfill the request.
882
882
ErrNoMem ,
883
883
/// Unrecognized error. The inner value is the unrecognized errno.
884
- ErrUnknown ( libc :: c_int ) ,
884
+ ErrUnknown ( int ) ,
885
885
/// ## The following are win32-specific
886
886
///
887
887
/// Unsupported combination of protection flags (`MapReadable`/`MapWritable`/`MapExecutable`).
@@ -926,12 +926,12 @@ impl MemoryMap {
926
926
pub fn new( min_len : uint, options : & [ MapOption ] ) -> Result < MemoryMap , MapError > {
927
927
use libc:: off_t;
928
928
929
- let mut addr: * c_void = ptr:: null( ) ;
930
- let mut prot: c_int = 0 ;
931
- let mut flags: c_int = libc:: MAP_PRIVATE ;
932
- let mut fd: c_int = -1 ;
933
- let mut offset: off_t = 0 ;
934
- let len = round_up( min_len, page_size( ) ) as size_t ;
929
+ let mut addr: * u8 = ptr:: null( ) ;
930
+ let mut prot = 0 ;
931
+ let mut flags = libc:: MAP_PRIVATE ;
932
+ let mut fd = -1 ;
933
+ let mut offset = 0 ;
934
+ let len = round_up( min_len, page_size( ) ) ;
935
935
936
936
for & o in options. iter ( ) {
937
937
match o {
@@ -952,7 +952,7 @@ impl MemoryMap {
952
952
if fd == -1 { flags |= libc:: MAP_ANON ; }
953
953
954
954
let r = unsafe {
955
- libc : : mmap( addr, len, prot, flags, fd, offset)
955
+ libc : : mmap( addr as * c_void , len as size_t , prot, flags, fd, offset)
956
956
} ;
957
957
if r. equiv ( & libc:: MAP_FAILED ) {
958
958
Err ( match errno ( ) as c_int {
@@ -961,7 +961,7 @@ impl MemoryMap {
961
961
libc:: EINVAL => ErrUnaligned ,
962
962
libc:: ENODEV => ErrNoMapSupport ,
963
963
libc:: ENOMEM => ErrNoMem ,
964
- code => ErrUnknown ( code)
964
+ code => ErrUnknown ( code as int )
965
965
} )
966
966
} else {
967
967
Ok ( MemoryMap {
@@ -987,7 +987,7 @@ impl Drop for MemoryMap {
987
987
/// Unmap the mapping. Fails the task if `munmap` fails.
988
988
fn drop( & mut self) {
989
989
unsafe {
990
- match libc : : munmap( self . data as * c_void, self . len) {
990
+ match libc : : munmap( self . data as * c_void, self . len as libc :: size_t ) {
991
991
0 => ( ) ,
992
992
-1 => match errno( ) as c_int {
993
993
libc : : EINVAL => error ! ( "invalid addr or len" ) ,
@@ -1011,7 +1011,7 @@ impl MemoryMap {
1011
1011
let mut executable = false ;
1012
1012
let mut fd: c_int = -1 ;
1013
1013
let mut offset: uint = 0 ;
1014
- let len = round_up( min_len, page_size( ) ) as SIZE_T ;
1014
+ let len = round_up( min_len, page_size( ) ) ;
1015
1015
1016
1016
for & o in options. iter ( ) {
1017
1017
match o {
@@ -1040,7 +1040,7 @@ impl MemoryMap {
1040
1040
}
1041
1041
let r = unsafe {
1042
1042
libc:: VirtualAlloc ( lpAddress,
1043
- len,
1043
+ len as SIZE_T ,
1044
1044
libc:: MEM_COMMIT | libc:: MEM_RESERVE ,
1045
1045
flProtect)
1046
1046
} ;
@@ -1085,7 +1085,7 @@ impl MemoryMap {
1085
1085
_ => Ok ( MemoryMap {
1086
1086
data : r as * mut u8 ,
1087
1087
len : len,
1088
- kind : MapFile ( mapping as * c_void )
1088
+ kind : MapFile ( mapping as * u8 )
1089
1089
} )
1090
1090
}
1091
1091
}
@@ -1116,7 +1116,7 @@ impl Drop for MemoryMap {
1116
1116
match self . kind {
1117
1117
MapVirtual => {
1118
1118
if libc:: VirtualFree ( self . data as * mut c_void ,
1119
- self . len ,
1119
+ self . len as size_t ,
1120
1120
libc:: MEM_RELEASE ) == FALSE {
1121
1121
error ! ( "VirtualFree failed: {}" , errno( ) ) ;
1122
1122
}
0 commit comments