Skip to content

Commit 57630eb

Browse files
committed
auto merge of #16336 : retep998/rust/master, r=brson
Several of the tests in `make check-fast` were failing so this fixes those tests.
2 parents 98f1b0f + 24ebbb4 commit 57630eb

File tree

8 files changed

+50
-33
lines changed

8 files changed

+50
-33
lines changed

src/liblibc/lib.rs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,18 +1142,16 @@ pub mod types {
11421142
pub mod os {
11431143
pub mod common {
11441144
pub mod posix01 {
1145-
use types::os::arch::c95::{c_short, time_t, suseconds_t,
1146-
c_long};
1145+
use types::os::arch::c95::{c_short, time_t, c_long};
11471146
use types::os::arch::extra::{int64, time64_t};
11481147
use types::os::arch::posix88::{dev_t, ino_t};
1149-
use types::os::arch::posix88::mode_t;
11501148

11511149
// pub Note: this is the struct called stat64 in win32. Not stat,
11521150
// nor stati64.
11531151
pub struct stat {
11541152
pub st_dev: dev_t,
11551153
pub st_ino: ino_t,
1156-
pub st_mode: mode_t,
1154+
pub st_mode: u16,
11571155
pub st_nlink: c_short,
11581156
pub st_uid: c_short,
11591157
pub st_gid: c_short,
@@ -1171,8 +1169,8 @@ pub mod types {
11711169
}
11721170

11731171
pub struct timeval {
1174-
pub tv_sec: time_t,
1175-
pub tv_usec: suseconds_t,
1172+
pub tv_sec: c_long,
1173+
pub tv_usec: c_long,
11761174
}
11771175

11781176
pub struct timespec {
@@ -1186,7 +1184,7 @@ pub mod types {
11861184
pub mod bsd44 {
11871185
use types::os::arch::c95::{c_char, c_int, c_uint, size_t};
11881186

1189-
pub type SOCKET = c_uint;
1187+
pub type SOCKET = uint;
11901188
pub type socklen_t = c_int;
11911189
pub type sa_family_t = u16;
11921190
pub type in_port_t = u16;
@@ -1197,6 +1195,7 @@ pub mod types {
11971195
}
11981196
pub struct sockaddr_storage {
11991197
pub ss_family: sa_family_t,
1198+
pub __ss_pad1: [u8, ..6],
12001199
pub __ss_align: i64,
12011200
pub __ss_pad2: [u8, ..112],
12021201
}
@@ -1293,12 +1292,9 @@ pub mod types {
12931292
pub mod posix88 {
12941293
pub type off_t = i32;
12951294
pub type dev_t = u32;
1296-
pub type ino_t = i16;
1295+
pub type ino_t = u16;
12971296

1298-
#[cfg(target_arch = "x86")]
1299-
pub type pid_t = i32;
1300-
#[cfg(target_arch = "x86_64")]
1301-
pub type pid_t = i64;
1297+
pub type pid_t = u32;
13021298

13031299
pub type useconds_t = u32;
13041300
pub type mode_t = u16;
@@ -1415,7 +1411,7 @@ pub mod types {
14151411
pub dwPageSize: DWORD,
14161412
pub lpMinimumApplicationAddress: LPVOID,
14171413
pub lpMaximumApplicationAddress: LPVOID,
1418-
pub dwActiveProcessorMask: DWORD,
1414+
pub dwActiveProcessorMask: uint,
14191415
pub dwNumberOfProcessors: DWORD,
14201416
pub dwProcessorType: DWORD,
14211417
pub dwAllocationGranularity: DWORD,
@@ -1950,7 +1946,7 @@ pub mod consts {
19501946
}
19511947
pub mod extra {
19521948
use types::os::arch::c95::c_int;
1953-
use types::os::arch::extra::{WORD, DWORD, BOOL};
1949+
use types::os::arch::extra::{WORD, DWORD, BOOL, HANDLE};
19541950

19551951
pub static TRUE : BOOL = 1;
19561952
pub static FALSE : BOOL = 0;
@@ -1979,7 +1975,7 @@ pub mod consts {
19791975
pub static ERROR_IO_PENDING: c_int = 997;
19801976
pub static ERROR_FILE_INVALID : c_int = 1006;
19811977
pub static ERROR_NOT_FOUND: c_int = 1168;
1982-
pub static INVALID_HANDLE_VALUE : c_int = -1;
1978+
pub static INVALID_HANDLE_VALUE: HANDLE = -1 as HANDLE;
19831979

19841980
pub static DELETE : DWORD = 0x00010000;
19851981
pub static READ_CONTROL : DWORD = 0x00020000;

src/libnative/io/c_win32.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ pub static ENABLE_PROCESSED_INPUT: libc::DWORD = 0x1;
2828
pub static ENABLE_QUICK_EDIT_MODE: libc::DWORD = 0x40;
2929

3030
#[repr(C)]
31+
#[cfg(target_arch = "x86")]
3132
pub struct WSADATA {
3233
pub wVersion: libc::WORD,
3334
pub wHighVersion: libc::WORD,
@@ -37,6 +38,17 @@ pub struct WSADATA {
3738
pub iMaxUdpDg: u16,
3839
pub lpVendorInfo: *mut u8,
3940
}
41+
#[repr(C)]
42+
#[cfg(target_arch = "x86_64")]
43+
pub struct WSADATA {
44+
pub wVersion: libc::WORD,
45+
pub wHighVersion: libc::WORD,
46+
pub iMaxSockets: u16,
47+
pub iMaxUdpDg: u16,
48+
pub lpVendorInfo: *mut u8,
49+
pub szDescription: [u8, ..WSADESCRIPTION_LEN + 1],
50+
pub szSystemStatus: [u8, ..WSASYS_STATUS_LEN + 1],
51+
}
4052

4153
pub type LPWSADATA = *mut WSADATA;
4254

src/libnative/io/file_win32.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ pub fn open(path: &CString, fm: rtio::FileMode, fa: rtio::FileAccess)
320320
dwFlagsAndAttributes,
321321
ptr::mut_null())
322322
};
323-
if handle == libc::INVALID_HANDLE_VALUE as libc::HANDLE {
323+
if handle == libc::INVALID_HANDLE_VALUE {
324324
Err(super::last_error())
325325
} else {
326326
let fd = unsafe {
@@ -368,7 +368,7 @@ pub fn readdir(p: &CString) -> IoResult<Vec<CString>> {
368368
let wfd_ptr = malloc_raw(rust_list_dir_wfd_size() as uint);
369369
let find_handle = libc::FindFirstFileW(path.as_ptr(),
370370
wfd_ptr as libc::HANDLE);
371-
if find_handle as libc::c_int != libc::INVALID_HANDLE_VALUE {
371+
if find_handle != libc::INVALID_HANDLE_VALUE {
372372
let mut paths = vec!();
373373
let mut more_files = 1 as libc::c_int;
374374
while more_files != 0 {
@@ -440,7 +440,7 @@ pub fn readlink(p: &CString) -> IoResult<CString> {
440440
libc::FILE_ATTRIBUTE_NORMAL,
441441
ptr::mut_null())
442442
};
443-
if handle as int == libc::INVALID_HANDLE_VALUE as int {
443+
if handle == libc::INVALID_HANDLE_VALUE {
444444
return Err(super::last_error())
445445
}
446446
// Specify (sz - 1) because the documentation states that it's the size

src/libnative/io/pipe_win32.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ impl UnixStream {
223223
libc::FILE_FLAG_OVERLAPPED,
224224
ptr::mut_null())
225225
};
226-
if result != libc::INVALID_HANDLE_VALUE as libc::HANDLE {
226+
if result != libc::INVALID_HANDLE_VALUE {
227227
return Some(result)
228228
}
229229

@@ -238,7 +238,7 @@ impl UnixStream {
238238
libc::FILE_FLAG_OVERLAPPED,
239239
ptr::mut_null())
240240
};
241-
if result != libc::INVALID_HANDLE_VALUE as libc::HANDLE {
241+
if result != libc::INVALID_HANDLE_VALUE {
242242
return Some(result)
243243
}
244244
}
@@ -253,7 +253,7 @@ impl UnixStream {
253253
libc::FILE_FLAG_OVERLAPPED,
254254
ptr::mut_null())
255255
};
256-
if result != libc::INVALID_HANDLE_VALUE as libc::HANDLE {
256+
if result != libc::INVALID_HANDLE_VALUE {
257257
return Some(result)
258258
}
259259
}
@@ -565,7 +565,7 @@ impl UnixListener {
565565
// and such.
566566
let addr_v = try!(to_utf16(addr));
567567
let ret = unsafe { pipe(addr_v.as_ptr(), true) };
568-
if ret == libc::INVALID_HANDLE_VALUE as libc::HANDLE {
568+
if ret == libc::INVALID_HANDLE_VALUE {
569569
Err(super::last_error())
570570
} else {
571571
Ok(UnixListener { handle: ret, name: addr.clone() })
@@ -680,7 +680,7 @@ impl UnixAcceptor {
680680
// create a second server pipe. If this fails, we disconnect the
681681
// connected client and return an error (see comments above).
682682
let new_handle = unsafe { pipe(name.as_ptr(), false) };
683-
if new_handle == libc::INVALID_HANDLE_VALUE as libc::HANDLE {
683+
if new_handle == libc::INVALID_HANDLE_VALUE {
684684
let ret = Err(super::last_error());
685685
// If our disconnection fails, then there's not really a whole lot
686686
// that we can do, so fail the task.

src/libnative/io/process.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -359,13 +359,13 @@ fn spawn_process_os(cfg: ProcessConfig,
359359
libc::OPEN_EXISTING,
360360
0,
361361
ptr::mut_null());
362-
if *slot == INVALID_HANDLE_VALUE as libc::HANDLE {
362+
if *slot == INVALID_HANDLE_VALUE {
363363
return Err(super::last_error())
364364
}
365365
}
366366
Some(ref fd) => {
367367
let orig = get_osfhandle(fd.fd()) as HANDLE;
368-
if orig == INVALID_HANDLE_VALUE as HANDLE {
368+
if orig == INVALID_HANDLE_VALUE {
369369
return Err(super::last_error())
370370
}
371371
if DuplicateHandle(cur_proc, orig, cur_proc, slot,
@@ -450,9 +450,9 @@ fn zeroed_startupinfo() -> libc::types::os::arch::extra::STARTUPINFO {
450450
wShowWindow: 0,
451451
cbReserved2: 0,
452452
lpReserved2: ptr::mut_null(),
453-
hStdInput: libc::INVALID_HANDLE_VALUE as libc::HANDLE,
454-
hStdOutput: libc::INVALID_HANDLE_VALUE as libc::HANDLE,
455-
hStdError: libc::INVALID_HANDLE_VALUE as libc::HANDLE,
453+
hStdInput: libc::INVALID_HANDLE_VALUE,
454+
hStdOutput: libc::INVALID_HANDLE_VALUE,
455+
hStdError: libc::INVALID_HANDLE_VALUE,
456456
}
457457
}
458458

src/libnative/io/util.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ pub fn eof() -> IoError {
5252
}
5353
}
5454

55+
#[cfg(windows)]
56+
pub fn ms_to_timeval(ms: u64) -> libc::timeval {
57+
libc::timeval {
58+
tv_sec: (ms / 1000) as libc::c_long,
59+
tv_usec: ((ms % 1000) * 1000) as libc::c_long,
60+
}
61+
}
62+
#[cfg(not(windows))]
5563
pub fn ms_to_timeval(ms: u64) -> libc::timeval {
5664
libc::timeval {
5765
tv_sec: (ms / 1000) as libc::time_t,

src/librustdoc/flock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ mod imp {
197197
libc::FILE_ATTRIBUTE_NORMAL,
198198
ptr::mut_null())
199199
};
200-
if handle as uint == libc::INVALID_HANDLE_VALUE as uint {
200+
if handle == libc::INVALID_HANDLE_VALUE {
201201
fail!("create file error: {}", os::last_os_error());
202202
}
203203
let mut overlapped: libc::OVERLAPPED = unsafe { mem::zeroed() };

src/libstd/io/fs.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,10 +1592,11 @@ mod test {
15921592
let tmpdir = tmpdir();
15931593
let path = tmpdir.join("a");
15941594
check!(File::create(&path));
1595-
1596-
check!(change_file_times(&path, 1000, 2000));
1597-
assert_eq!(check!(path.stat()).accessed, 1000);
1598-
assert_eq!(check!(path.stat()).modified, 2000);
1595+
// These numbers have to be bigger than the time in the day to account for timezones
1596+
// Windows in particular will fail in certain timezones with small enough values
1597+
check!(change_file_times(&path, 100000, 200000));
1598+
assert_eq!(check!(path.stat()).accessed, 100000);
1599+
assert_eq!(check!(path.stat()).modified, 200000);
15991600
})
16001601

16011602
iotest!(fn utime_noexist() {

0 commit comments

Comments
 (0)