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 › Dispatch › fileLock Private Function fileLock Doc Source Private Function std.Io.Dispatch.fileLock
fn fileLock (userdata : ?*anyopaque , file : File , lock : File .Lock ) File .LockError !void Params userdata : ?*anyopaque file : File lock : File .Lock File Io/Dispatch.zig: 3708
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726 fn fileLock (userdata : ?*anyopaque , file : File , lock : File .Lock ) File .LockError !void {
const ev : *Evented = @ptrCast (@alignCast (userdata ));
_ = ev ;
const operation : i32 = switch (lock ) {
.none => c .LOCK .UN ,
.shared => c .LOCK .SH ,
.exclusive => c .LOCK .EX ,
};
while (true ) switch (c .errno (c .flock (file .handle , operation ))) {
.SUCCESS => return ,
.INTR => {},
.BADF => |err | return errnoBug (err ),
.INVAL => |err | return errnoBug (err ), // invalid parameters
.NOLCK => return error .SystemResources ,
.AGAIN => |err | return errnoBug (err ),
.OPNOTSUPP => return error .FileLocksUnsupported ,
else => |err | return unexpectedErrno (err ),
};
}