Skip to content

Commit feb219d

Browse files
committed
windows: Fix several tests on 64-bit.
Signed-off-by: Peter Atashian <[email protected]>
1 parent 51e19e7 commit feb219d

File tree

4 files changed

+34
-16
lines changed

4 files changed

+34
-16
lines changed

src/liblibc/lib.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,18 +1142,17 @@ 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,
1145+
use types::os::arch::c95::{c_short, time_t,
11461146
c_long};
11471147
use types::os::arch::extra::{int64, time64_t};
11481148
use types::os::arch::posix88::{dev_t, ino_t};
1149-
use types::os::arch::posix88::mode_t;
11501149

11511150
// pub Note: this is the struct called stat64 in win32. Not stat,
11521151
// nor stati64.
11531152
pub struct stat {
11541153
pub st_dev: dev_t,
11551154
pub st_ino: ino_t,
1156-
pub st_mode: mode_t,
1155+
pub st_mode: u16,
11571156
pub st_nlink: c_short,
11581157
pub st_uid: c_short,
11591158
pub st_gid: c_short,
@@ -1171,8 +1170,8 @@ pub mod types {
11711170
}
11721171

11731172
pub struct timeval {
1174-
pub tv_sec: time_t,
1175-
pub tv_usec: suseconds_t,
1173+
pub tv_sec: c_long,
1174+
pub tv_usec: c_long,
11761175
}
11771176

11781177
pub struct timespec {
@@ -1186,7 +1185,7 @@ pub mod types {
11861185
pub mod bsd44 {
11871186
use types::os::arch::c95::{c_char, c_int, c_uint, size_t};
11881187

1189-
pub type SOCKET = c_uint;
1188+
pub type SOCKET = uint;
11901189
pub type socklen_t = c_int;
11911190
pub type sa_family_t = u16;
11921191
pub type in_port_t = u16;
@@ -1197,6 +1196,7 @@ pub mod types {
11971196
}
11981197
pub struct sockaddr_storage {
11991198
pub ss_family: sa_family_t,
1199+
pub __ss_pad1: [u8, ..6],
12001200
pub __ss_align: i64,
12011201
pub __ss_pad2: [u8, ..112],
12021202
}
@@ -1293,12 +1293,9 @@ pub mod types {
12931293
pub mod posix88 {
12941294
pub type off_t = i32;
12951295
pub type dev_t = u32;
1296-
pub type ino_t = i16;
1296+
pub type ino_t = u16;
12971297

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

13031300
pub type useconds_t = u32;
13041301
pub type mode_t = u16;
@@ -1415,7 +1412,7 @@ pub mod types {
14151412
pub dwPageSize: DWORD,
14161413
pub lpMinimumApplicationAddress: LPVOID,
14171414
pub lpMaximumApplicationAddress: LPVOID,
1418-
pub dwActiveProcessorMask: DWORD,
1415+
pub dwActiveProcessorMask: uint,
14191416
pub dwNumberOfProcessors: DWORD,
14201417
pub dwProcessorType: DWORD,
14211418
pub dwAllocationGranularity: DWORD,

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/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/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)