mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 12:59:04 +00:00
Merge pull request #6356 from jorangreef/io_uring
std: add io_uring library
This commit is contained in:
commit
a41c0b63bb
@ -1200,6 +1200,8 @@ pub const IORING_FEAT_NODROP = 1 << 1;
|
||||
pub const IORING_FEAT_SUBMIT_STABLE = 1 << 2;
|
||||
pub const IORING_FEAT_RW_CUR_POS = 1 << 3;
|
||||
pub const IORING_FEAT_CUR_PERSONALITY = 1 << 4;
|
||||
pub const IORING_FEAT_FAST_POLL = 1 << 5;
|
||||
pub const IORING_FEAT_POLL_32BITS = 1 << 6;
|
||||
|
||||
// io_uring_params.flags
|
||||
|
||||
@ -1252,6 +1254,9 @@ pub const io_sqring_offsets = extern struct {
|
||||
/// needs io_uring_enter wakeup
|
||||
pub const IORING_SQ_NEED_WAKEUP = 1 << 0;
|
||||
|
||||
/// kernel has cqes waiting beyond the cq ring
|
||||
pub const IORING_SQ_CQ_OVERFLOW = 1 << 1;
|
||||
|
||||
pub const io_cqring_offsets = extern struct {
|
||||
head: u32,
|
||||
tail: u32,
|
||||
@ -1263,48 +1268,19 @@ pub const io_cqring_offsets = extern struct {
|
||||
};
|
||||
|
||||
pub const io_uring_sqe = extern struct {
|
||||
pub const union1 = extern union {
|
||||
off: u64,
|
||||
addr2: u64,
|
||||
};
|
||||
|
||||
pub const union2 = extern union {
|
||||
rw_flags: kernel_rwf,
|
||||
fsync_flags: u32,
|
||||
poll_events: u16,
|
||||
sync_range_flags: u32,
|
||||
msg_flags: u32,
|
||||
timeout_flags: u32,
|
||||
accept_flags: u32,
|
||||
cancel_flags: u32,
|
||||
open_flags: u32,
|
||||
statx_flags: u32,
|
||||
fadvise_flags: u32,
|
||||
};
|
||||
|
||||
pub const union3 = extern union {
|
||||
struct1: extern struct {
|
||||
/// index into fixed buffers, if used
|
||||
buf_index: u16,
|
||||
|
||||
/// personality to use, if used
|
||||
personality: u16,
|
||||
},
|
||||
__pad2: [3]u64,
|
||||
};
|
||||
opcode: IORING_OP,
|
||||
flags: u8,
|
||||
ioprio: u16,
|
||||
fd: i32,
|
||||
|
||||
union1: union1,
|
||||
off: u64,
|
||||
addr: u64,
|
||||
len: u32,
|
||||
|
||||
union2: union2,
|
||||
rw_flags: u32,
|
||||
user_data: u64,
|
||||
|
||||
union3: union3,
|
||||
buf_index: u16,
|
||||
personality: u16,
|
||||
splice_fd_in: i32,
|
||||
__pad2: [2]u64
|
||||
};
|
||||
|
||||
pub const IOSQE_BIT = extern enum(u8) {
|
||||
@ -1313,7 +1289,8 @@ pub const IOSQE_BIT = extern enum(u8) {
|
||||
IO_LINK,
|
||||
IO_HARDLINK,
|
||||
ASYNC,
|
||||
|
||||
BUFFER_SELECT,
|
||||
|
||||
_,
|
||||
};
|
||||
|
||||
@ -1332,7 +1309,10 @@ pub const IOSQE_IO_LINK = 1 << @enumToInt(IOSQE_BIT.IO_LINK);
|
||||
pub const IOSQE_IO_HARDLINK = 1 << @enumToInt(IOSQE_BIT.IO_HARDLINK);
|
||||
|
||||
/// always go async
|
||||
pub const IOSQE_ASYNC = 1 << IOSQE_BIT.ASYNC;
|
||||
pub const IOSQE_ASYNC = 1 << @enumToInt(IOSQE_BIT.ASYNC);
|
||||
|
||||
/// select buffer from buf_group
|
||||
pub const IOSQE_BUFFER_SELECT = 1 << @enumToInt(IOSQE_BIT.BUFFER_SELECT);
|
||||
|
||||
pub const IORING_OP = extern enum(u8) {
|
||||
NOP,
|
||||
@ -1365,6 +1345,10 @@ pub const IORING_OP = extern enum(u8) {
|
||||
RECV,
|
||||
OPENAT2,
|
||||
EPOLL_CTL,
|
||||
SPLICE,
|
||||
PROVIDE_BUFFERS,
|
||||
REMOVE_BUFFERS,
|
||||
TEE,
|
||||
|
||||
_,
|
||||
};
|
||||
|
||||
@ -383,6 +383,9 @@ pub const SYS = extern enum(usize) {
|
||||
statx = Linux + 366,
|
||||
rseq = Linux + 367,
|
||||
io_pgetevents = Linux + 368,
|
||||
io_uring_setup = Linux + 425,
|
||||
io_uring_enter = Linux + 426,
|
||||
io_uring_register = Linux + 427,
|
||||
openat2 = Linux + 437,
|
||||
pidfd_getfd = Linux + 438,
|
||||
|
||||
|
||||
@ -31,6 +31,7 @@ pub usingnamespace switch (builtin.arch) {
|
||||
pub usingnamespace @import("bits.zig");
|
||||
pub const tls = @import("linux/tls.zig");
|
||||
pub const BPF = @import("linux/bpf.zig");
|
||||
pub usingnamespace @import("linux/io_uring.zig");
|
||||
|
||||
/// Set by startup code, used by `getauxval`.
|
||||
pub var elf_aux_maybe: ?[*]std.elf.Auxv = null;
|
||||
|
||||
1218
lib/std/os/linux/io_uring.zig
Normal file
1218
lib/std/os/linux/io_uring.zig
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user