Skip to content

Commit 5cf22b5

Browse files
committed
Hardcode more values in preadv2
Signed-off-by: Jiahao XU <[email protected]>
1 parent 5602ef7 commit 5cf22b5

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/unix.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,8 @@ mod linux {
398398

399399
use libc::{iovec, ssize_t, syscall, SYS_preadv2};
400400

401+
// TODO: Replace this with libc::RWF_NOWAIT once they have it for musl
402+
// targets
401403
const RWF_NOWAIT: c_int = 0x00000008;
402404

403405
fn cvt_ssize(t: ssize_t) -> io::Result<ssize_t> {
@@ -408,12 +410,14 @@ mod linux {
408410
}
409411
}
410412

411-
unsafe fn preadv2(fd: c_int, iov: *const iovec, iovcnt: c_int, flags: c_int) -> ssize_t {
413+
unsafe fn preadv2(fd: c_int, iov: &iovec) -> ssize_t {
414+
let iovcnt: c_int = 1;
415+
412416
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
413-
let res = syscall(SYS_preadv2, fd, iov, iovcnt, -1, 0, flags);
417+
let res = syscall(SYS_preadv2, fd, iov, iovcnt, -1, 0, RWF_NOWAIT);
414418

415419
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
416-
let res = syscall(SYS_preadv2, fd, iov, iovcnt, -1, flags);
420+
let res = syscall(SYS_preadv2, fd, iov, iovcnt, -1, RWF_NOWAIT);
417421

418422
#[cfg(not(target_arch = "x86_64"))]
419423
let res = syscall(
@@ -423,7 +427,7 @@ mod linux {
423427
iovcnt,
424428
-1 as libc::c_long,
425429
((-1 as u64) >> 32) as libc::c_long,
426-
flags,
430+
RWF_NOWAIT,
427431
);
428432

429433
res.try_into().unwrap()
@@ -443,8 +447,6 @@ mod linux {
443447
iov_base: buf.as_ptr() as *mut _,
444448
iov_len: buf.len(),
445449
},
446-
1,
447-
RWF_NOWAIT,
448450
)
449451
}) {
450452
Ok(cnt) => Ok(cnt.try_into().unwrap()),

0 commit comments

Comments
 (0)