Zig 0.17.0-dev (Split by item) This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig standard library.
std › Io › Uring › futexWaitUncancelable Private Function futexWaitUncancelable Doc Source Private Function std.Io.Uring.futexWaitUncancelable
fn futexWaitUncancelable (userdata : ?*anyopaque , ptr : *const u32 , expected : u32 ) void Params userdata : ?*anyopaque ptr : *const u32 expected : u32 File Io/Uring.zig: 2009
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041 fn futexWaitUncancelable (userdata : ?*anyopaque , ptr : *const u32 , expected : u32 ) void {
const ev : *Evented = @ptrCast (@alignCast (userdata ));
var cancel_region : CancelRegion = .initBlocked ();
defer cancel_region .deinit ();
const thread = cancel_region .awaitIoUring () catch |err | switch (err ) {
error .Canceled => unreachable , // blocked
};
thread .enqueue ().* = .{
.opcode = .FUTEX_WAIT ,
.flags = 0 ,
.ioprio = 0 ,
.fd = @bitCast (linux .FUTEX2_FLAGS { .size = .U32 , .private = true }),
.off = expected ,
.addr = @intFromPtr (ptr ),
.len = 0 ,
.rw_flags = 0 ,
.user_data = @intFromPtr (cancel_region .fiber ),
.buf_index = 0 ,
.personality = 0 ,
.splice_fd_in = 0 ,
.addr3 = std .math .maxInt (u32 ),
.resv = 0 ,
};
ev .yield (null , .nothing );
switch (cancel_region .errno ()) {
.SUCCESS => {}, // notified by `wake()`
.INTR , .CANCELED => {}, // caller's responsibility to retry
.AGAIN => {}, // ptr.* != expect
.INVAL => {}, // possibly timeout overflow
.FAULT => recoverableOsBugDetected (), // ptr was invalid
else => recoverableOsBugDetected (),
}
}