@@ -44,9 +44,9 @@ use unstable::finally::Finally;
4444use sync:: atomics:: { AtomicInt , INIT_ATOMIC_INT , SeqCst } ;
4545
4646/// 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 {
4848 unsafe {
49- libc:: close ( fd)
49+ libc:: close ( fd as c_int ) as int
5050 }
5151}
5252
@@ -57,7 +57,7 @@ static BUF_BYTES : uint = 2048u;
5757pub fn getcwd ( ) -> Path {
5858 use c_str:: CString ;
5959
60- let mut buf = [ 0 as libc :: c_char , ..BUF_BYTES ] ;
60+ let mut buf = [ 0 as c_char , ..BUF_BYTES ] ;
6161 unsafe {
6262 if libc:: getcwd ( buf. as_mut_ptr ( ) , buf. len ( ) as size_t ) . is_null ( ) {
6363 fail ! ( )
@@ -164,7 +164,7 @@ pub fn env() -> ~[(~str,~str)] {
164164 os:: last_os_error( ) ) ;
165165 }
166166 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| {
168168 result. push ( cstr. as_str ( ) . unwrap ( ) . to_owned ( ) ) ;
169169 } ) ;
170170 FreeEnvironmentStringsA ( ch) ;
@@ -173,7 +173,7 @@ pub fn env() -> ~[(~str,~str)] {
173173 #[ cfg( unix) ]
174174 unsafe fn get_env_pairs ( ) -> ~[ ~str ] {
175175 extern {
176- fn rust_env_pairs ( ) -> * * libc :: c_char ;
176+ fn rust_env_pairs ( ) -> * * c_char ;
177177 }
178178 let environ = rust_env_pairs ( ) ;
179179 if environ as uint == 0 {
@@ -306,9 +306,9 @@ pub struct Pipe {
306306#[ cfg( unix) ]
307307pub fn pipe ( ) -> Pipe {
308308 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 ) ;
312312 return Pipe { input : fds. input , out : fds. out } ;
313313 }
314314}
@@ -321,13 +321,13 @@ pub fn pipe() -> Pipe {
321321 // fully understand. Here we explicitly make the pipe non-inheritable,
322322 // which means to pass it to a subprocess they need to be duplicated
323323 // 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 } ;
326326 let res = libc:: pipe ( & mut fds. input , 1024 as :: libc:: c_uint ,
327327 ( 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 ) ) ;
331331 return Pipe { input : fds. input , out : fds. out } ;
332332 }
333333}
@@ -699,7 +699,7 @@ pub fn get_exit_status() -> int {
699699}
700700
701701#[ 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 ] {
703703 let mut args = ~[ ] ;
704704 for i in range ( 0 u, argc as uint ) {
705705 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] {
715715#[ cfg( target_os = "macos" ) ]
716716fn real_args ( ) -> ~[ ~str ] {
717717 unsafe {
718- let ( argc, argv) = ( * _NSGetArgc ( ) as c_int ,
718+ let ( argc, argv) = ( * _NSGetArgc ( ) as int ,
719719 * _NSGetArgv ( ) as * * c_char ) ;
720720 load_argc_and_argv ( argc, argv)
721721 }
@@ -833,7 +833,7 @@ pub struct MemoryMap {
833833 /// Pointer to the memory created or modified by this map.
834834 data : * mut u8 ,
835835 /// Number of bytes this map applies to
836- len : size_t ,
836+ len : uint ,
837837 /// Type of mapping
838838 kind : MemoryMapKind
839839}
@@ -842,7 +842,7 @@ pub struct MemoryMap {
842842pub enum MemoryMapKind {
843843 /// Memory-mapped file. On Windows, the inner pointer is a handle to the mapping, and
844844 /// corresponds to `CreateFileMapping`. Elsewhere, it is null.
845- MapFile ( * c_void ) ,
845+ MapFile ( * u8 ) ,
846846 /// Virtual memory map. Usually used to change the permissions of a given chunk of memory.
847847 /// Corresponds to `VirtualAlloc` on Windows.
848848 MapVirtual
@@ -857,7 +857,7 @@ pub enum MapOption {
857857 /// The memory should be executable
858858 MapExecutable ,
859859 /// Create a map for a specific address range. Corresponds to `MAP_FIXED` on POSIX.
860- MapAddr ( * c_void ) ,
860+ MapAddr ( * u8 ) ,
861861 /// Create a memory mapping for a file with a given fd.
862862 MapFd ( c_int ) ,
863863 /// When using `MapFd`, the start of the map is `uint` bytes from the start of the file.
@@ -881,7 +881,7 @@ pub enum MapError {
881881 /// using `MapFd`, the target of the fd didn't have enough resources to fulfill the request.
882882 ErrNoMem ,
883883 /// Unrecognized error. The inner value is the unrecognized errno.
884- ErrUnknown ( libc :: c_int ) ,
884+ ErrUnknown ( int ) ,
885885 /// ## The following are win32-specific
886886 ///
887887 /// Unsupported combination of protection flags (`MapReadable`/`MapWritable`/`MapExecutable`).
@@ -926,12 +926,12 @@ impl MemoryMap {
926926 pub fn new( min_len : uint, options : & [ MapOption ] ) -> Result < MemoryMap , MapError > {
927927 use libc:: off_t;
928928
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( ) ) ;
935935
936936 for & o in options. iter ( ) {
937937 match o {
@@ -952,7 +952,7 @@ impl MemoryMap {
952952 if fd == -1 { flags |= libc:: MAP_ANON ; }
953953
954954 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)
956956 } ;
957957 if r. equiv ( & libc:: MAP_FAILED ) {
958958 Err ( match errno ( ) as c_int {
@@ -961,7 +961,7 @@ impl MemoryMap {
961961 libc:: EINVAL => ErrUnaligned ,
962962 libc:: ENODEV => ErrNoMapSupport ,
963963 libc:: ENOMEM => ErrNoMem ,
964- code => ErrUnknown ( code)
964+ code => ErrUnknown ( code as int )
965965 } )
966966 } else {
967967 Ok ( MemoryMap {
@@ -987,7 +987,7 @@ impl Drop for MemoryMap {
987987 /// Unmap the mapping. Fails the task if `munmap` fails.
988988 fn drop( & mut self) {
989989 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 ) {
991991 0 => ( ) ,
992992 -1 => match errno( ) as c_int {
993993 libc : : EINVAL => error ! ( "invalid addr or len" ) ,
@@ -1011,7 +1011,7 @@ impl MemoryMap {
10111011 let mut executable = false ;
10121012 let mut fd: c_int = -1 ;
10131013 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( ) ) ;
10151015
10161016 for & o in options. iter ( ) {
10171017 match o {
@@ -1040,7 +1040,7 @@ impl MemoryMap {
10401040 }
10411041 let r = unsafe {
10421042 libc:: VirtualAlloc ( lpAddress,
1043- len,
1043+ len as SIZE_T ,
10441044 libc:: MEM_COMMIT | libc:: MEM_RESERVE ,
10451045 flProtect)
10461046 } ;
@@ -1085,7 +1085,7 @@ impl MemoryMap {
10851085 _ => Ok ( MemoryMap {
10861086 data : r as * mut u8 ,
10871087 len : len,
1088- kind : MapFile ( mapping as * c_void )
1088+ kind : MapFile ( mapping as * u8 )
10891089 } )
10901090 }
10911091 }
@@ -1116,7 +1116,7 @@ impl Drop for MemoryMap {
11161116 match self . kind {
11171117 MapVirtual => {
11181118 if libc:: VirtualFree ( self . data as * mut c_void ,
1119- self . len ,
1119+ self . len as size_t ,
11201120 libc:: MEM_RELEASE ) == FALSE {
11211121 error ! ( "VirtualFree failed: {}" , errno( ) ) ;
11221122 }
0 commit comments