diff options
| author | Hayden Pope <stilbruch@protonmail.com> | 2022-11-14 12:46:45 -0600 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-11-15 02:38:28 -0500 |
| commit | ceb9fedb47d2a02b428e1dafaa3965104e752ddf (patch) | |
| tree | ba25fd1f3c7a6291606bf67ada48f8c68040bf11 /lib/std/os | |
| parent | 14986077ceefc3955fb90f869411dc6940727fa9 (diff) | |
| download | zig-ceb9fedb47d2a02b428e1dafaa3965104e752ddf.tar.gz zig-ceb9fedb47d2a02b428e1dafaa3965104e752ddf.zip | |
std.os.linux: Add setitimer and getitimer syscalls
Diffstat (limited to 'lib/std/os')
| -rw-r--r-- | lib/std/os/linux.zig | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig index 9d7a8fd718..f26a851a60 100644 --- a/lib/std/os/linux.zig +++ b/lib/std/os/linux.zig @@ -1523,6 +1523,21 @@ pub fn timerfd_settime(fd: i32, flags: u32, new_value: *const itimerspec, old_va return syscall4(.timerfd_settime, @bitCast(usize, @as(isize, fd)), flags, @ptrToInt(new_value), @ptrToInt(old_value)); } +// Flags for the 'setitimer' system call +pub const ITIMER = enum(i32) { + REAL = 0, + VIRTUAL = 1, + PROF = 2, +}; + +pub fn getitimer(which: i32, curr_value: *itimerspec) usize { + return syscall2(.getitimer, @bitCast(usize, @as(isize, which)), @ptrToInt(curr_value)); +} + +pub fn setitimer(which: i32, new_value: *const itimerspec, old_value: ?*itimerspec) usize { + return syscall3(.setitimer, @bitCast(usize, @as(isize, which)), @ptrToInt(new_value), @ptrToInt(old_value)); +} + pub fn unshare(flags: usize) usize { return syscall1(.unshare, flags); } |
