std: add linux kernel_rwf type and preadv2+pwritev2

master
daurnimator 2019-05-20 23:25:11 +10:00
parent a712a5515d
commit ae604b4464
No known key found for this signature in database
GPG Key ID: 45B429A8F9D9D22A
2 changed files with 25 additions and 0 deletions

View File

@ -119,6 +119,23 @@ pub const O_RDONLY = 0o0;
pub const O_WRONLY = 0o1; pub const O_WRONLY = 0o1;
pub const O_RDWR = 0o2; pub const O_RDWR = 0o2;
pub const kernel_rwf = u32;
/// high priority request, poll if possible
pub const RWF_HIPRI = kernel_rwf(0x00000001);
/// per-IO O_DSYNC
pub const RWF_DSYNC = kernel_rwf(0x00000002);
/// per-IO O_SYNC
pub const RWF_SYNC = kernel_rwf(0x00000004);
/// per-IO, return -EAGAIN if operation would block
pub const RWF_NOWAIT = kernel_rwf(0x00000008);
/// per-IO O_APPEND
pub const RWF_APPEND = kernel_rwf(0x00000010);
pub const SEEK_SET = 0; pub const SEEK_SET = 0;
pub const SEEK_CUR = 1; pub const SEEK_CUR = 1;
pub const SEEK_END = 2; pub const SEEK_END = 2;

View File

@ -189,6 +189,10 @@ pub fn preadv(fd: i32, iov: [*]const iovec, count: usize, offset: u64) usize {
return syscall4(SYS_preadv, @bitCast(usize, isize(fd)), @ptrToInt(iov), count, offset); return syscall4(SYS_preadv, @bitCast(usize, isize(fd)), @ptrToInt(iov), count, offset);
} }
pub fn preadv2(fd: i32, iov: [*]const iovec, count: usize, offset: u64, flags: kernel_rwf) usize {
return syscall5(SYS_preadv2, @bitCast(usize, isize(fd)), @ptrToInt(iov), count, offset, flags);
}
pub fn readv(fd: i32, iov: [*]const iovec, count: usize) usize { pub fn readv(fd: i32, iov: [*]const iovec, count: usize) usize {
return syscall3(SYS_readv, @bitCast(usize, isize(fd)), @ptrToInt(iov), count); return syscall3(SYS_readv, @bitCast(usize, isize(fd)), @ptrToInt(iov), count);
} }
@ -201,6 +205,10 @@ pub fn pwritev(fd: i32, iov: [*]const iovec_const, count: usize, offset: u64) us
return syscall4(SYS_pwritev, @bitCast(usize, isize(fd)), @ptrToInt(iov), count, offset); return syscall4(SYS_pwritev, @bitCast(usize, isize(fd)), @ptrToInt(iov), count, offset);
} }
pub fn pwritev2(fd: i32, iov: [*]const iovec_const, count: usize, offset: u64, flags: kernel_rwf) usize {
return syscall5(SYS_pwritev2, @bitCast(usize, isize(fd)), @ptrToInt(iov), count, offset, flags);
}
// TODO https://github.com/ziglang/zig/issues/265 // TODO https://github.com/ziglang/zig/issues/265
pub fn rmdir(path: [*]const u8) usize { pub fn rmdir(path: [*]const u8) usize {
if (@hasDecl(@This(), "SYS_rmdir")) { if (@hasDecl(@This(), "SYS_rmdir")) {