diff options
| author | Stephen Gregoratto <dev@sgregoratto.me> | 2023-09-28 18:27:37 +1000 |
|---|---|---|
| committer | Stephen Gregoratto <dev@sgregoratto.me> | 2023-09-28 18:58:05 +1000 |
| commit | bc0bf4e97ac7ac45731b7a7e629e680e51d8eefe (patch) | |
| tree | 4db8ba4f7e1fe0aa7b720c9b2972416290451104 /lib/std/os/linux.zig | |
| parent | 5f456b2b97bc4a4c4860fd7cb6287c400e215eae (diff) | |
| download | zig-bc0bf4e97ac7ac45731b7a7e629e680e51d8eefe.tar.gz zig-bc0bf4e97ac7ac45731b7a7e629e680e51d8eefe.zip | |
Linux: Add cachestat wrapper.
Can be tested using this program I whipped up:
https://gist.github.com/The-King-of-Toasters/aee448f5975c50f735fd1946794574f7
Diffstat (limited to 'lib/std/os/linux.zig')
| -rw-r--r-- | lib/std/os/linux.zig | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig index 4a59446a8d..dea3cea875 100644 --- 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, +}; |
