zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit bc0bf4e97ac7ac45731b7a7e629e680e51d8eefe (tree)
parent 5f456b2b97bc4a4c4860fd7cb6287c400e215eae
Author: Stephen Gregoratto <dev@sgregoratto.me>
Date:   Thu, 28 Sep 2023 18:27:37 +1000

Linux: Add cachestat wrapper.

Can be tested using this program I whipped up:
https://gist.github.com/The-King-of-Toasters/aee448f5975c50f735fd1946794574f7

Diffstat:
Mlib/std/os/linux.zig | 28++++++++++++++++++++++++++++
1 file changed, 28 insertions(+), 0 deletions(-)

diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig @@ -1876,6 +1876,21 @@ pub fn ptrace( ); } +pub fn cachestat( + fd: fd_t, + cstat_range: *const cache_stat_range, + cstat: *cache_stat, + flags: u32, +) usize { + return syscall4( + .cachestat, + @as(usize, @bitCast(@as(isize, fd))), + @intFromPtr(cstat_range), + @intFromPtr(cstat), + flags, + ); +} + pub const E = switch (native_arch) { .mips, .mipsel => @import("linux/errno/mips.zig").E, .sparc, .sparcel, .sparc64 => @import("linux/errno/sparc.zig").E, @@ -5829,3 +5844,16 @@ pub const PTRACE = struct { pub const SECCOMP_GET_METADATA = 0x420d; pub const GET_SYSCALL_INFO = 0x420e; }; + +pub const cache_stat_range = extern struct { + off: u64, + len: u64, +}; + +pub const cache_stat = extern struct { + cache: u64, + dirty: u64, + writeback: u64, + evicted: u64, + recently_evicted: u64, +};