windows: Fix several tests on 64-bit.

Signed-off-by: Peter Atashian <retep998@gmail.com>
This commit is contained in:
Peter Atashian 2014-08-07 04:05:00 -04:00
parent 51e19e7501
commit feb219d23f
4 changed files with 34 additions and 16 deletions

View File

@ -1142,18 +1142,17 @@ pub mod types {
pub mod os {
pub mod common {
pub mod posix01 {
use types::os::arch::c95::{c_short, time_t, suseconds_t,
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};
use types::os::arch::posix88::mode_t;
// pub Note: this is the struct called stat64 in win32. Not stat,
// nor stati64.
pub struct stat {
pub st_dev: dev_t,
pub st_ino: ino_t,
pub st_mode: mode_t,
pub st_mode: u16,
pub st_nlink: c_short,
pub st_uid: c_short,
pub st_gid: c_short,
@ -1171,8 +1170,8 @@ pub mod types {
}
pub struct timeval {
pub tv_sec: time_t,
pub tv_usec: suseconds_t,
pub tv_sec: c_long,
pub tv_usec: c_long,
}
pub struct timespec {
@ -1186,7 +1185,7 @@ pub mod types {
pub mod bsd44 {
use types::os::arch::c95::{c_char, c_int, c_uint, size_t};
pub type SOCKET = c_uint;
pub type SOCKET = uint;
pub type socklen_t = c_int;
pub type sa_family_t = u16;
pub type in_port_t = u16;
@ -1197,6 +1196,7 @@ pub mod types {
}
pub struct sockaddr_storage {
pub ss_family: sa_family_t,
pub __ss_pad1: [u8, ..6],
pub __ss_align: i64,
pub __ss_pad2: [u8, ..112],
}
@ -1293,12 +1293,9 @@ pub mod types {
pub mod posix88 {
pub type off_t = i32;
pub type dev_t = u32;
pub type ino_t = i16;
pub type ino_t = u16;
#[cfg(target_arch = "x86")]
pub type pid_t = i32;
#[cfg(target_arch = "x86_64")]
pub type pid_t = i64;
pub type pid_t = u32;
pub type useconds_t = u32;
pub type mode_t = u16;
@ -1415,7 +1412,7 @@ pub mod types {
pub dwPageSize: DWORD,
pub lpMinimumApplicationAddress: LPVOID,
pub lpMaximumApplicationAddress: LPVOID,
pub dwActiveProcessorMask: DWORD,
pub dwActiveProcessorMask: uint,
pub dwNumberOfProcessors: DWORD,
pub dwProcessorType: DWORD,
pub dwAllocationGranularity: DWORD,

View File

@ -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;

View File

@ -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,

View File

@ -1592,10 +1592,11 @@ mod test {
let tmpdir = tmpdir();
let path = tmpdir.join("a");
check!(File::create(&path));
check!(change_file_times(&path, 1000, 2000));
assert_eq!(check!(path.stat()).accessed, 1000);
assert_eq!(check!(path.stat()).modified, 2000);
// These numbers have to be bigger than the time in the day to account for timezones
// Windows in particular will fail in certain timezones with small enough values
check!(change_file_times(&path, 100000, 200000));
assert_eq!(check!(path.stat()).accessed, 100000);
assert_eq!(check!(path.stat()).modified, 200000);
})
iotest!(fn utime_noexist() {