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 › os › linux › bpf › prog_load Public Function prog_load Doc Source Public Function std.os.linux.bpf.prog_load
pub fn prog_load (
prog_type : ProgType ,
insns : []const Insn ,
log : ?*Log ,
license : []const u8 ,
kern_version : u32 ,
flags : u32 ,
) !fd_t Params prog_type : ProgType insns : []const Insn log : ?*Log license : []const u8 kern_version : u32 flags : u32 File os/linux/bpf.zig: 1760
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794 pub fn prog_load (
prog_type : ProgType ,
insns : []const Insn ,
log : ?*Log ,
license : []const u8 ,
kern_version : u32 ,
flags : u32 ,
) !fd_t {
var attr = Attr {
.prog_load = std .mem .zeroes (ProgLoadAttr ),
};
attr .prog_load .prog_type = @backingInt (prog_type );
attr .prog_load .insns = @intFromPtr (insns .ptr );
attr .prog_load .insn_cnt = @as (u32 , @intCast (insns .len ));
attr .prog_load .license = @intFromPtr (license .ptr );
attr .prog_load .kern_version = kern_version ;
attr .prog_load .prog_flags = flags ;
if (log ) |l | {
attr .prog_load .log_buf = @intFromPtr (l .buf .ptr );
attr .prog_load .log_size = @as (u32 , @intCast (l .buf .len ));
attr .prog_load .log_level = l .level ;
}
const rc = linux .bpf (.prog_load , &attr , @sizeOf (ProgLoadAttr ));
return switch (errno (rc )) {
.SUCCESS => @as (fd_t , @intCast (rc )),
.ACCES => error .UnsafeProgram ,
.FAULT => unreachable ,
.INVAL => error .InvalidProgram ,
.PERM => error .PermissionDenied ,
else => |err | unexpectedErrno (err ),
};
}