authorgravatar for joran@ronomon.comJoran Dirk Greef <joran@ronomon.com> 2020-09-19 18:50:24+02:00
committergravatar for joran@ronomon.comJoran Dirk Greef <joran@ronomon.com> 2020-09-19 18:50:24+02:00
log4bc1b7a7ac99d57619b4f9a84e159310820e83ff
treec27823f6eb0a5abace7a3ca9019a1e182041ee11
parent92407bfcd7b65f153b7523d97ac5f69193561d27

Fix io_uring_sqe to use the names of the first member of each union

Now we're really future-proof... no more `opflags` creeping in. When anonymous unions land, we can start using `accept_flags` etc. Until then, code using this struct won't break when the kernel adds features. Refs: https://github.com/ziglang/zig/issues/6349 Refs: https://github.com/ziglang/zig/issues/985

2 files changed, 6 insertions(+), 6 deletions(-)

lib/std/os/bits/linux.zig+1-1
......@@ -1272,7 +1272,7 @@ pub const io_uring_sqe = extern struct {
12721272 off: u64,
12731273 addr: u64,
12741274 len: u32,
1275 opflags: u32,
1275 rw_flags: u32,
12761276 user_data: u64,
12771277 buf_index: u16,
12781278 personality: u16,
lib/std/os/linux/io_uring.zig+5-5
......@@ -319,13 +319,13 @@ pub const IO_Uring = struct {
319319 sqe.off = @ptrToInt(addrlen); // `addr2` is a newer union member that maps to `off`.
320320 sqe.addr = @ptrToInt(addr);
321321 sqe.user_data = user_data;
322 sqe.opflags = accept_flags;
322 sqe.rw_flags = accept_flags;
323323 return sqe;
324324 }
325325
326326 /// Queues (but does not submit) an SQE to perform an `fsync(2)`.
327327 /// Returns a pointer to the SQE so that you can further modify the SQE for advanced use cases.
328 /// For example, for `fdatasync()` you can set `IORING_FSYNC_DATASYNC` in the SQE's `opflags`.
328 /// For example, for `fdatasync()` you can set `IORING_FSYNC_DATASYNC` in the SQE's `rw_flags`.
329329 /// N.B. While SQEs are initiated in the order in which they appear in the submission queue,
330330 /// operations execute in parallel and completions are unordered. Therefore, an application that
331331 /// submits a write followed by an fsync in the submission queue cannot expect the fsync to
......@@ -392,7 +392,7 @@ pub const IO_Uring = struct {
392392
393393 /// Queues (but does not submit) an SQE to perform a `preadv()`.
394394 /// Returns a pointer to the SQE so that you can further modify the SQE for advanced use cases.
395 /// For example, if you want to do a `preadv2()` then set `opflags` on the returned SQE.
395 /// For example, if you want to do a `preadv2()` then set `rw_flags` on the returned SQE.
396396 /// See https://linux.die.net/man/2/preadv.
397397 pub fn queue_readv(
398398 self: *IO_Uring,
......@@ -413,7 +413,7 @@ pub const IO_Uring = struct {
413413
414414 /// Queues (but does not submit) an SQE to perform a `pwritev()`.
415415 /// Returns a pointer to the SQE so that you can further modify the SQE for advanced use cases.
416 /// For example, if you want to do a `pwritev2()` then set `opflags` on the returned SQE.
416 /// For example, if you want to do a `pwritev2()` then set `rw_flags` on the returned SQE.
417417 /// See https://linux.die.net/man/2/pwritev.
418418 pub fn queue_writev(
419419 self: *IO_Uring,
......@@ -636,7 +636,7 @@ test "queue_nop" {
636636 .off = 0,
637637 .addr = 0,
638638 .len = 0,
639 .opflags = 0,
639 .rw_flags = 0,
640640 .user_data = @intCast(u64, 0xaaaaaaaa),
641641 .buf_index = 0,
642642 .personality = 0,