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 › posix › prctl Public Function prctl Doc Source Public Function std.posix.prctl
pub fn prctl (option : PR , args : anytype ) PrctlError !u31 Params File posix.zig: 1290
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315 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 ),
}
}