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 › perf_event_open Public Function perf_event_open Doc Source Public Function std.posix.perf_event_open
pub fn perf_event_open (
attr : *system .perf_event_attr ,
pid : pid_t ,
cpu : i32 ,
group_fd : fd_t ,
flags : usize ,
) PerfEventOpenError !fd_t Params attr : *system .perf_event_attr pid : pid_t cpu : i32 group_fd : fd_t flags : usize File posix.zig: 1477
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508 pub fn perf_event_open (
attr : *system .perf_event_attr ,
pid : pid_t ,
cpu : i32 ,
group_fd : fd_t ,
flags : usize ,
) PerfEventOpenError !fd_t {
if (native_os == .linux ) {
// There is no syscall wrapper for this function exposed by libcs
const rc = linux .perf_event_open (attr , pid , cpu , group_fd , flags );
switch (linux .errno (rc )) {
.SUCCESS => return @intCast (rc ),
.@"2BIG" => return error .TooBig ,
.ACCES => return error .PermissionDenied ,
.BADF => unreachable , // group_fd file descriptor is not valid.
.BUSY => return error .DeviceBusy ,
.FAULT => unreachable , // Segmentation fault.
.INVAL => unreachable , // Bad attr settings.
.INTR => unreachable , // Mixed perf and ftrace handling for a uprobe.
.MFILE => return error .ProcessResources ,
.NODEV => return error .EventRequiresUnsupportedCpuFeature ,
.NOENT => unreachable , // Invalid type setting.
.NOSPC => return error .TooManyBreakpoints ,
.NOSYS => return error .SampleStackNotSupported ,
.OPNOTSUPP => return error .EventNotSupported ,
.OVERFLOW => return error .SampleMaxStackOverflow ,
.PERM => return error .PermissionDenied ,
.SRCH => return error .ProcessNotFound ,
else => |err | return unexpectedErrno (err ),
}
}
}