authorgravatar for quae@daurnimator.comdaurnimator <quae@daurnimator.com> 2019-05-20 23:25:11+10:00
committergravatar for quae@daurnimator.comdaurnimator <quae@daurnimator.com> 2019-06-10 14:40:54+10:00
logae604b446488e2b0931e84c796819d3f817fa66f
treebcb2d28ef241698cf52d0318b9bb9b2aed6ce035
parenta712a5515d2d7a418d77bc419e4fc0a7fe5639f5
signaturelock-open Commit is signed but in an unrecognized format.

std: add linux kernel_rwf type and preadv2+pwritev2


2 files changed, 25 insertions(+), 0 deletions(-)

std/os/bits/linux.zig+17
......@@ -119,6 +119,23 @@ pub const O_RDONLY = 0o0;
119119pub const O_WRONLY = 0o1;
120120pub const O_RDWR = 0o2;
121121
122pub const kernel_rwf = u32;
123
124/// high priority request, poll if possible
125pub const RWF_HIPRI = kernel_rwf(0x00000001);
126
127/// per-IO O_DSYNC
128pub const RWF_DSYNC = kernel_rwf(0x00000002);
129
130/// per-IO O_SYNC
131pub const RWF_SYNC = kernel_rwf(0x00000004);
132
133/// per-IO, return -EAGAIN if operation would block
134pub const RWF_NOWAIT = kernel_rwf(0x00000008);
135
136/// per-IO O_APPEND
137pub const RWF_APPEND = kernel_rwf(0x00000010);
138
122139pub const SEEK_SET = 0;
123140pub const SEEK_CUR = 1;
124141pub const SEEK_END = 2;
std/os/linux.zig+8
......@@ -189,6 +189,10 @@ pub fn preadv(fd: i32, iov: [*]const iovec, count: usize, offset: u64) usize {
189189 return syscall4(SYS_preadv, @bitCast(usize, isize(fd)), @ptrToInt(iov), count, offset);
190190}
191191
192pub fn preadv2(fd: i32, iov: [*]const iovec, count: usize, offset: u64, flags: kernel_rwf) usize {
193 return syscall5(SYS_preadv2, @bitCast(usize, isize(fd)), @ptrToInt(iov), count, offset, flags);
194}
195
192196pub fn readv(fd: i32, iov: [*]const iovec, count: usize) usize {
193197 return syscall3(SYS_readv, @bitCast(usize, isize(fd)), @ptrToInt(iov), count);
194198}
......@@ -201,6 +205,10 @@ pub fn pwritev(fd: i32, iov: [*]const iovec_const, count: usize, offset: u64) us
201205 return syscall4(SYS_pwritev, @bitCast(usize, isize(fd)), @ptrToInt(iov), count, offset);
202206}
203207
208pub fn pwritev2(fd: i32, iov: [*]const iovec_const, count: usize, offset: u64, flags: kernel_rwf) usize {
209 return syscall5(SYS_pwritev2, @bitCast(usize, isize(fd)), @ptrToInt(iov), count, offset, flags);
210}
211
204212// TODO https://github.com/ziglang/zig/issues/265
205213pub fn rmdir(path: [*]const u8) usize {
206214 if (@hasDecl(@This(), "SYS_rmdir")) {