From feb219d23fd4236fc69ec86e34c088e232289534 Mon Sep 17 00:00:00 2001 From: Peter Atashian Date: Thu, 7 Aug 2014 04:05:00 -0400 Subject: windows: Fix several tests on 64-bit. Signed-off-by: Peter Atashian --- src/libnative/io/c_win32.rs | 12 ++++++++++++ src/libnative/io/util.rs | 8 ++++++++ 2 files changed, 20 insertions(+) (limited to 'src/libnative') diff --git a/src/libnative/io/c_win32.rs b/src/libnative/io/c_win32.rs index 482155c339c..80c9e91b48f 100644 --- a/src/libnative/io/c_win32.rs +++ b/src/libnative/io/c_win32.rs @@ -28,6 +28,7 @@ pub static ENABLE_PROCESSED_INPUT: libc::DWORD = 0x1; pub static ENABLE_QUICK_EDIT_MODE: libc::DWORD = 0x40; #[repr(C)] +#[cfg(target_arch = "x86")] pub struct WSADATA { pub wVersion: libc::WORD, pub wHighVersion: libc::WORD, @@ -37,6 +38,17 @@ pub struct WSADATA { pub iMaxUdpDg: u16, pub lpVendorInfo: *mut u8, } +#[repr(C)] +#[cfg(target_arch = "x86_64")] +pub struct WSADATA { + pub wVersion: libc::WORD, + pub wHighVersion: libc::WORD, + pub iMaxSockets: u16, + pub iMaxUdpDg: u16, + pub lpVendorInfo: *mut u8, + pub szDescription: [u8, ..WSADESCRIPTION_LEN + 1], + pub szSystemStatus: [u8, ..WSASYS_STATUS_LEN + 1], +} pub type LPWSADATA = *mut WSADATA; diff --git a/src/libnative/io/util.rs b/src/libnative/io/util.rs index 06046cc74cf..97518bbf199 100644 --- a/src/libnative/io/util.rs +++ b/src/libnative/io/util.rs @@ -52,6 +52,14 @@ pub fn eof() -> IoError { } } +#[cfg(windows)] +pub fn ms_to_timeval(ms: u64) -> libc::timeval { + libc::timeval { + tv_sec: (ms / 1000) as libc::c_long, + tv_usec: ((ms % 1000) * 1000) as libc::c_long, + } +} +#[cfg(not(windows))] pub fn ms_to_timeval(ms: u64) -> libc::timeval { libc::timeval { tv_sec: (ms / 1000) as libc::time_t, -- cgit 1.4.1-3-g733a5 From 24ebbb442014d0bca9f32b36c25f739bf18146bf Mon Sep 17 00:00:00 2001 From: Peter Atashian Date: Thu, 7 Aug 2014 16:40:12 -0400 Subject: windows: Fix INVALID_HANDLE_VALUE Made INVALID_HANDLE_VALUE actually a HANDLE. Removed all useless casts during INVALID_HANDLE_VALUE comparisons. Signed-off-by: Peter Atashian --- src/liblibc/lib.rs | 7 +++---- src/libnative/io/file_win32.rs | 6 +++--- src/libnative/io/pipe_win32.rs | 10 +++++----- src/libnative/io/process.rs | 10 +++++----- src/librustdoc/flock.rs | 2 +- 5 files changed, 17 insertions(+), 18 deletions(-) (limited to 'src/libnative') diff --git a/src/liblibc/lib.rs b/src/liblibc/lib.rs index fa29ab508ff..e368a564415 100644 --- a/src/liblibc/lib.rs +++ b/src/liblibc/lib.rs @@ -1142,8 +1142,7 @@ pub mod types { pub mod os { pub mod common { pub mod posix01 { - use types::os::arch::c95::{c_short, time_t, - c_long}; + use types::os::arch::c95::{c_short, time_t, c_long}; use types::os::arch::extra::{int64, time64_t}; use types::os::arch::posix88::{dev_t, ino_t}; @@ -1947,7 +1946,7 @@ pub mod consts { } pub mod extra { use types::os::arch::c95::c_int; - use types::os::arch::extra::{WORD, DWORD, BOOL}; + use types::os::arch::extra::{WORD, DWORD, BOOL, HANDLE}; pub static TRUE : BOOL = 1; pub static FALSE : BOOL = 0; @@ -1976,7 +1975,7 @@ pub mod consts { pub static ERROR_IO_PENDING: c_int = 997; pub static ERROR_FILE_INVALID : c_int = 1006; pub static ERROR_NOT_FOUND: c_int = 1168; - pub static INVALID_HANDLE_VALUE : c_int = -1; + pub static INVALID_HANDLE_VALUE: HANDLE = -1 as HANDLE; pub static DELETE : DWORD = 0x00010000; pub static READ_CONTROL : DWORD = 0x00020000; diff --git a/src/libnative/io/file_win32.rs b/src/libnative/io/file_win32.rs index a024d498ef3..fe29c024529 100644 --- a/src/libnative/io/file_win32.rs +++ b/src/libnative/io/file_win32.rs @@ -320,7 +320,7 @@ pub fn open(path: &CString, fm: rtio::FileMode, fa: rtio::FileAccess) dwFlagsAndAttributes, ptr::mut_null()) }; - if handle == libc::INVALID_HANDLE_VALUE as libc::HANDLE { + if handle == libc::INVALID_HANDLE_VALUE { Err(super::last_error()) } else { let fd = unsafe { @@ -368,7 +368,7 @@ pub fn readdir(p: &CString) -> IoResult> { let wfd_ptr = malloc_raw(rust_list_dir_wfd_size() as uint); let find_handle = libc::FindFirstFileW(path.as_ptr(), wfd_ptr as libc::HANDLE); - if find_handle as libc::c_int != libc::INVALID_HANDLE_VALUE { + if find_handle != libc::INVALID_HANDLE_VALUE { let mut paths = vec!(); let mut more_files = 1 as libc::c_int; while more_files != 0 { @@ -440,7 +440,7 @@ pub fn readlink(p: &CString) -> IoResult { libc::FILE_ATTRIBUTE_NORMAL, ptr::mut_null()) }; - if handle as int == libc::INVALID_HANDLE_VALUE as int { + if handle == libc::INVALID_HANDLE_VALUE { return Err(super::last_error()) } // Specify (sz - 1) because the documentation states that it's the size diff --git a/src/libnative/io/pipe_win32.rs b/src/libnative/io/pipe_win32.rs index 87129bba845..717915e5d23 100644 --- a/src/libnative/io/pipe_win32.rs +++ b/src/libnative/io/pipe_win32.rs @@ -223,7 +223,7 @@ impl UnixStream { libc::FILE_FLAG_OVERLAPPED, ptr::mut_null()) }; - if result != libc::INVALID_HANDLE_VALUE as libc::HANDLE { + if result != libc::INVALID_HANDLE_VALUE { return Some(result) } @@ -238,7 +238,7 @@ impl UnixStream { libc::FILE_FLAG_OVERLAPPED, ptr::mut_null()) }; - if result != libc::INVALID_HANDLE_VALUE as libc::HANDLE { + if result != libc::INVALID_HANDLE_VALUE { return Some(result) } } @@ -253,7 +253,7 @@ impl UnixStream { libc::FILE_FLAG_OVERLAPPED, ptr::mut_null()) }; - if result != libc::INVALID_HANDLE_VALUE as libc::HANDLE { + if result != libc::INVALID_HANDLE_VALUE { return Some(result) } } @@ -565,7 +565,7 @@ impl UnixListener { // and such. let addr_v = try!(to_utf16(addr)); let ret = unsafe { pipe(addr_v.as_ptr(), true) }; - if ret == libc::INVALID_HANDLE_VALUE as libc::HANDLE { + if ret == libc::INVALID_HANDLE_VALUE { Err(super::last_error()) } else { Ok(UnixListener { handle: ret, name: addr.clone() }) @@ -680,7 +680,7 @@ impl UnixAcceptor { // create a second server pipe. If this fails, we disconnect the // connected client and return an error (see comments above). let new_handle = unsafe { pipe(name.as_ptr(), false) }; - if new_handle == libc::INVALID_HANDLE_VALUE as libc::HANDLE { + if new_handle == libc::INVALID_HANDLE_VALUE { let ret = Err(super::last_error()); // If our disconnection fails, then there's not really a whole lot // that we can do, so fail the task. diff --git a/src/libnative/io/process.rs b/src/libnative/io/process.rs index c89a40d6513..d83e36a5e2a 100644 --- a/src/libnative/io/process.rs +++ b/src/libnative/io/process.rs @@ -359,13 +359,13 @@ fn spawn_process_os(cfg: ProcessConfig, libc::OPEN_EXISTING, 0, ptr::mut_null()); - if *slot == INVALID_HANDLE_VALUE as libc::HANDLE { + if *slot == INVALID_HANDLE_VALUE { return Err(super::last_error()) } } Some(ref fd) => { let orig = get_osfhandle(fd.fd()) as HANDLE; - if orig == INVALID_HANDLE_VALUE as HANDLE { + if orig == INVALID_HANDLE_VALUE { return Err(super::last_error()) } if DuplicateHandle(cur_proc, orig, cur_proc, slot, @@ -450,9 +450,9 @@ fn zeroed_startupinfo() -> libc::types::os::arch::extra::STARTUPINFO { wShowWindow: 0, cbReserved2: 0, lpReserved2: ptr::mut_null(), - hStdInput: libc::INVALID_HANDLE_VALUE as libc::HANDLE, - hStdOutput: libc::INVALID_HANDLE_VALUE as libc::HANDLE, - hStdError: libc::INVALID_HANDLE_VALUE as libc::HANDLE, + hStdInput: libc::INVALID_HANDLE_VALUE, + hStdOutput: libc::INVALID_HANDLE_VALUE, + hStdError: libc::INVALID_HANDLE_VALUE, } } diff --git a/src/librustdoc/flock.rs b/src/librustdoc/flock.rs index f22950e7a29..cb8be9c8997 100644 --- a/src/librustdoc/flock.rs +++ b/src/librustdoc/flock.rs @@ -197,7 +197,7 @@ mod imp { libc::FILE_ATTRIBUTE_NORMAL, ptr::mut_null()) }; - if handle as uint == libc::INVALID_HANDLE_VALUE as uint { + if handle == libc::INVALID_HANDLE_VALUE { fail!("create file error: {}", os::last_os_error()); } let mut overlapped: libc::OVERLAPPED = unsafe { mem::zeroed() }; -- cgit 1.4.1-3-g733a5