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 {...@@ -1272,7 +1272,7 @@ pub const io_uring_sqe = extern struct {
1272 off: u64,1272 off: u64,
1273 addr: u64,1273 addr: u64,
1274 len: u32,1274 len: u32,
1275 opflags: u32,1275 rw_flags: u32,
1276 user_data: u64,1276 user_data: u64,
1277 buf_index: u16,1277 buf_index: u16,
1278 personality: u16,1278 personality: u16,
lib/std/os/linux/io_uring.zig+5-5
...@@ -319,13 +319,13 @@ pub const IO_Uring = struct {...@@ -319,13 +319,13 @@ pub const IO_Uring = struct {
319 sqe.off = @ptrToInt(addrlen); // `addr2` is a newer union member that maps to `off`.319 sqe.off = @ptrToInt(addrlen); // `addr2` is a newer union member that maps to `off`.
320 sqe.addr = @ptrToInt(addr);320 sqe.addr = @ptrToInt(addr);
321 sqe.user_data = user_data;321 sqe.user_data = user_data;
322 sqe.opflags = accept_flags;322 sqe.rw_flags = accept_flags;
323 return sqe;323 return sqe;
324 }324 }
325325
326 /// Queues (but does not submit) an SQE to perform an `fsync(2)`.326 /// Queues (but does not submit) an SQE to perform an `fsync(2)`.
327 /// Returns a pointer to the SQE so that you can further modify the SQE for advanced use cases.327 /// 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`.
329 /// N.B. While SQEs are initiated in the order in which they appear in the submission queue,329 /// N.B. While SQEs are initiated in the order in which they appear in the submission queue,
330 /// operations execute in parallel and completions are unordered. Therefore, an application that330 /// operations execute in parallel and completions are unordered. Therefore, an application that
331 /// submits a write followed by an fsync in the submission queue cannot expect the fsync to331 /// 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 {...@@ -392,7 +392,7 @@ pub const IO_Uring = struct {
392392
393 /// Queues (but does not submit) an SQE to perform a `preadv()`.393 /// Queues (but does not submit) an SQE to perform a `preadv()`.
394 /// Returns a pointer to the SQE so that you can further modify the SQE for advanced use cases.394 /// 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.
396 /// See https://linux.die.net/man/2/preadv.396 /// See https://linux.die.net/man/2/preadv.
397 pub fn queue_readv(397 pub fn queue_readv(
398 self: *IO_Uring,398 self: *IO_Uring,
...@@ -413,7 +413,7 @@ pub const IO_Uring = struct {...@@ -413,7 +413,7 @@ pub const IO_Uring = struct {
413413
414 /// Queues (but does not submit) an SQE to perform a `pwritev()`.414 /// Queues (but does not submit) an SQE to perform a `pwritev()`.
415 /// Returns a pointer to the SQE so that you can further modify the SQE for advanced use cases.415 /// 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.
417 /// See https://linux.die.net/man/2/pwritev.417 /// See https://linux.die.net/man/2/pwritev.
418 pub fn queue_writev(418 pub fn queue_writev(
419 self: *IO_Uring,419 self: *IO_Uring,
...@@ -636,7 +636,7 @@ test "queue_nop" {...@@ -636,7 +636,7 @@ test "queue_nop" {
636 .off = 0,636 .off = 0,
637 .addr = 0,637 .addr = 0,
638 .len = 0,638 .len = 0,
639 .opflags = 0,639 .rw_flags = 0,
640 .user_data = @intCast(u64, 0xaaaaaaaa),640 .user_data = @intCast(u64, 0xaaaaaaaa),
641 .buf_index = 0,641 .buf_index = 0,
642 .personality = 0,642 .personality = 0,