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.

buf_ring_add

Assigns buffer with the br buffer ring. buffer_id is identifier which will be returned in the CQE. buffer_offset is the offset to insert at from the current tail. If just one buffer is provided before the ring tail is committed with advance then offset should be 0. If buffers are provided in a loop before being committed, the offset must be incremented by one for each buffer added.

IoUring.buf_ring_add
pub fn buf_ring_add(
    br: *linux.io_uring_buf_ring,
    buffer: []u8,
    buffer_id: u16,
    mask: u16,
    buffer_offset: u16,
) void

File

lib/std/os/linux/IoUring.zig:1836

Code

pub fn buf_ring_add(
    br: *linux.io_uring_buf_ring,
    buffer: []u8,
    buffer_id: u16,
    mask: u16,
    buffer_offset: u16,
) void {
    const bufs: [*]linux.io_uring_buf = @ptrCast(br);
    const buf: *linux.io_uring_buf = &bufs[(br.tail +% buffer_offset) & mask];

    buf.addr = @intFromPtr(buffer.ptr);
    buf.len = @intCast(buffer.len);
    buf.bid = buffer_id;
}