Skip to content

Commit 6aff4c6

Browse files
committed
std: Bind write() on Win64
1 parent 37e99ae commit 6aff4c6

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/libstd/io.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ use container::Container;
5353
use int;
5454
use iterator::Iterator;
5555
use libc::consts::os::posix88::*;
56-
use libc::{c_int, c_long, c_void, size_t, ssize_t};
56+
use libc::{c_int, c_void, size_t};
5757
use libc;
5858
use num;
5959
use ops::Drop;
@@ -970,7 +970,7 @@ impl Reader for *libc::FILE {
970970

971971
unsafe {
972972
assert!(libc::fseek(*self,
973-
offset as c_long,
973+
offset as libc::c_long,
974974
convert_whence(whence)) == 0 as c_int);
975975
}
976976
}
@@ -1199,7 +1199,7 @@ impl Writer for *libc::FILE {
11991199

12001200
unsafe {
12011201
assert!(libc::fseek(*self,
1202-
offset as c_long,
1202+
offset as libc::c_long,
12031203
convert_whence(whence)) == 0 as c_int);
12041204
}
12051205
}
@@ -1240,13 +1240,23 @@ impl Writer for fd_t {
12401240
fn write(&self, v: &[u8]) {
12411241
#[fixed_stack_segment]; #[inline(never)];
12421242

1243+
#[cfg(windows)]
1244+
type IoSize = libc::c_uint;
1245+
#[cfg(windows)]
1246+
type IoRet = c_int;
1247+
1248+
#[cfg(unix)]
1249+
type IoSize = size_t;
1250+
#[cfg(unix)]
1251+
type IoRet = libc::ssize_t;
1252+
12431253
unsafe {
12441254
let mut count = 0u;
12451255
do v.as_imm_buf |vbuf, len| {
12461256
while count < len {
12471257
let vb = ptr::offset(vbuf, count as int) as *c_void;
1248-
let nout = libc::write(*self, vb, len as size_t);
1249-
if nout < 0 as ssize_t {
1258+
let nout = libc::write(*self, vb, len as IoSize);
1259+
if nout < 0 as IoRet {
12501260
error!("error writing buffer");
12511261
error!("%s", os::last_os_error());
12521262
fail!();

0 commit comments

Comments
 (0)