zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit ae604b446488e2b0931e84c796819d3f817fa66f (tree)
parent a712a5515d2d7a418d77bc419e4fc0a7fe5639f5
Author: daurnimator <quae@daurnimator.com>
Date:   Mon, 20 May 2019 23:25:11 +1000

std: add linux kernel_rwf type and preadv2+pwritev2

Diffstat:
Mstd/os/bits/linux.zig | 17+++++++++++++++++
Mstd/os/linux.zig | 8++++++++
2 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/std/os/bits/linux.zig b/std/os/bits/linux.zig @@ -119,6 +119,23 @@ pub const O_RDONLY = 0o0; pub const O_WRONLY = 0o1; 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_CUR = 1; pub const SEEK_END = 2; diff --git a/std/os/linux.zig b/std/os/linux.zig @@ -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); } +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 { 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); } +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 pub fn rmdir(path: [*]const u8) usize { if (@hasDecl(@This(), "SYS_rmdir")) {