提交 6aff4c67 编写于 作者: K klutzy

std: Bind write() on Win64

上级 37e99ae4
......@@ -53,7 +53,7 @@
use int;
use iterator::Iterator;
use libc::consts::os::posix88::*;
use libc::{c_int, c_long, c_void, size_t, ssize_t};
use libc::{c_int, c_void, size_t};
use libc;
use num;
use ops::Drop;
......@@ -970,7 +970,7 @@ fn seek(&self, offset: int, whence: SeekStyle) {
unsafe {
assert!(libc::fseek(*self,
offset as c_long,
offset as libc::c_long,
convert_whence(whence)) == 0 as c_int);
}
}
......@@ -1199,7 +1199,7 @@ fn seek(&self, offset: int, whence: SeekStyle) {
unsafe {
assert!(libc::fseek(*self,
offset as c_long,
offset as libc::c_long,
convert_whence(whence)) == 0 as c_int);
}
}
......@@ -1240,13 +1240,23 @@ impl Writer for fd_t {
fn write(&self, v: &[u8]) {
#[fixed_stack_segment]; #[inline(never)];
#[cfg(windows)]
type IoSize = libc::c_uint;
#[cfg(windows)]
type IoRet = c_int;
#[cfg(unix)]
type IoSize = size_t;
#[cfg(unix)]
type IoRet = libc::ssize_t;
unsafe {
let mut count = 0u;
do v.as_imm_buf |vbuf, len| {
while count < len {
let vb = ptr::offset(vbuf, count as int) as *c_void;
let nout = libc::write(*self, vb, len as size_t);
if nout < 0 as ssize_t {
let nout = libc::write(*self, vb, len as IoSize);
if nout < 0 as IoRet {
error!("error writing buffer");
error!("%s", os::last_os_error());
fail!();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册