auto merge of #16336 : retep998/rust/master, r=brson
Several of the tests in `make check-fast` were failing so this fixes those tests.
This commit is contained in:
commit
57630eb809
8 changed files with 50 additions and 33 deletions
|
|
@ -1142,18 +1142,16 @@ pub mod types {
|
|||
pub mod os {
|
||||
pub mod common {
|
||||
pub mod posix01 {
|
||||
use types::os::arch::c95::{c_short, time_t, suseconds_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};
|
||||
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 +1169,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 +1184,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 +1195,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 +1292,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 +1411,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,
|
||||
|
|
@ -1950,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;
|
||||
|
|
@ -1979,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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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<Vec<CString>> {
|
|||
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<CString> {
|
|||
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
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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() };
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue