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 library itself.
Zig › std/ › posix.zig › prctl
prctl
posix.prctl
pub fn prctl (option : PR , args : anytype ) PrctlError !u31
File
Code
pub fn prctl (option : PR , args : anytype ) PrctlError !u31 {
if (@typeInfo (@TypeOf (args )) != .@"struct" )
@compileError ("Expected tuple or struct argument, found " ++ @typeName (@TypeOf (args )));
if (args .len > 4 )
@compileError ("prctl takes a maximum of 4 optional arguments" );
var buf : [4 ]usize = undefined ;
{
comptime var i = 0 ;
inline while (i < args .len ) : (i += 1 ) buf [i ] = args [i ];
}
const rc = system .prctl (@backingInt (option ), buf [0 ], buf [1 ], buf [2 ], buf [3 ]);
switch (errno (rc )) {
.SUCCESS => return @intCast (rc ),
.ACCES => return error .AccessDenied ,
.BADF => return error .InvalidFileDescriptor ,
.FAULT => return error .InvalidAddress ,
.INVAL => unreachable ,
.NODEV , .NXIO => return error .UnsupportedFeature ,
.OPNOTSUPP => return error .OperationUnsupported ,
.PERM , .BUSY => return error .PermissionDenied ,
.RANGE => unreachable ,
else => |err | return unexpectedErrno (err ),
}
}