Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
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. Public Function

fadvise

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

Params

  • fd: fd_t
  • offset: i64
  • len: i64
  • advice: usize

File

os/linux.zig:3067
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
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,
        );
    }
}