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.

fadvise

linux.fadvise
pub fn fadvise(fd: fd_t, offset: i64, len: i64, advice: usize) usize

File

lib/std/os/linux.zig:3062

Code

pub fn fadvise(fd: fd_t, offset: i64, len: i64, advice: usize) usize {
    if (native_arch.isMIPS32()) {
        // MIPS O32 weirdly differs from the other architectures that require
        // aligned register pairs for this specific syscall.

        const offset_halves = splitValue64(offset);
        const length_halves = splitValue64(len);

        return syscall7(
            .fadvise64,
            @as(u32, @bitCast(fd)),
            0,
            offset_halves[0],
            offset_halves[1],
            length_halves[0],
            length_halves[1],
            advice,
        );
    } else if (require_aligned_register_pair) {
        const offset_halves = splitValue64(offset);
        const length_halves = splitValue64(len);

        return syscall6(
            .fadvise64_64,
            @as(u32, @bitCast(fd)),
            advice,
            offset_halves[0],
            offset_halves[1],
            length_halves[0],
            length_halves[1],
        );
    } else if (@sizeOf(syscall_arg_t) < @sizeOf(u64)) {
        const offset_halves = splitValue64(offset);
        const length_halves = splitValue64(len);

        return syscall6(
            .fadvise64_64,
            @as(u32, @bitCast(fd)),
            offset_halves[0],
            offset_halves[1],
            length_halves[0],
            length_halves[1],
            advice,
        );
    } else {
        return syscall4(
            .fadvise64,
            @as(u32, @bitCast(fd)),
            @as(u64, @bitCast(offset)),
            @as(u64, @bitCast(len)),
            advice,
        );
    }
}