Skip to content

Commit c651c2d

Browse files
committed
fix compile on mac os
Signed-off-by: qupeng <qupeng@pingcap.com>
1 parent 06e9b01 commit c651c2d

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

src/pipe_log.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use log::{info, warn};
1010
use nix::errno::Errno;
1111
use nix::fcntl::{self, OFlag};
1212
use nix::sys::stat::Mode;
13-
use nix::sys::uio::{pread, pwrite, pwritev, IoVec as NixIoVec};
13+
use nix::sys::uio::{pread, pwrite, IoVec as NixIoVec};
1414
use nix::unistd::{close, fsync, ftruncate, lseek, Whence};
1515
use nix::NixPath;
1616
use protobuf::Message;
@@ -691,6 +691,7 @@ fn pwrite_exact(fd: RawFd, mut offset: u64, content: &[u8]) -> Result<()> {
691691
Ok(())
692692
}
693693

694+
#[cfg(unix)]
694695
fn pwritev_exact<'a>(
695696
fd: RawFd,
696697
mut offset: u64,
@@ -719,7 +720,7 @@ fn pwritev_exact<'a>(
719720
}
720721

721722
while !vecs.is_empty() {
722-
let bytes = match pwritev(fd, vecs, offset as _) {
723+
let bytes = match nix::sys::uio::pwritev(fd, vecs, offset as _) {
723724
Ok(bytes) => bytes,
724725
Err(e) if e.as_errno() == Some(Errno::EAGAIN) => continue,
725726
Err(e) => return Err(parse_nix_error(e, "pwrite")),
@@ -730,6 +731,17 @@ fn pwritev_exact<'a>(
730731
Ok(())
731732
}
732733

734+
#[cfg(not(unix))]
735+
fn pwritev_exact<'a>(fd: RawFd, mut offset: u64, vecs: &'a [NixIoVec<&'a [u8]>]) -> Result<()> {
736+
for vec in vecs {
737+
let content = vec.as_slice();
738+
let len = content.len();
739+
pwrite_exact(fd, offset, content)?;
740+
offset += len as u64;
741+
}
742+
Ok(())
743+
}
744+
733745
fn write_file_header(fd: RawFd) -> Result<usize> {
734746
let len = FILE_MAGIC_HEADER.len() + VERSION.len();
735747
let mut header = Vec::with_capacity(len);

0 commit comments

Comments
 (0)