aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaytan <laytanlaats@hotmail.com>2025-12-20 21:25:19 +0100
committerGitHub <noreply@github.com>2025-12-20 21:25:19 +0100
commit7640a0511fc7baf8bc3f375a90b3d30616c703f0 (patch)
treebb91a943ec5fd703b97608fb4a0ce754c5c886de
parent00ede472e3adacafa9eaa3a64db5104169c9a0cd (diff)
parenta325ab469fb1367da3f2d37cb7fc15fafd5a1122 (diff)
Merge pull request #6015 from salfel/linux-syscalls
core:sys/linux Add timerfd syscall wrappers
-rw-r--r--core/sys/linux/sys.odin27
1 files changed, 24 insertions, 3 deletions
diff --git a/core/sys/linux/sys.odin b/core/sys/linux/sys.odin
index 04305ece1..faeda6f43 100644
--- a/core/sys/linux/sys.odin
+++ b/core/sys/linux/sys.odin
@@ -2992,15 +2992,36 @@ epoll_pwait :: proc(epfd: Fd, events: [^]EPoll_Event, count: i32, timeout: i32,
// TODO(flysand): signalfd
-// TODO(flysand): timerfd_create
+/*
+ Create Linux file descriptor based timer.
+ Available since Linux 2.6.25
+*/
+timerfd_create :: proc "contextless" (clock_id: Clock_Id, flags: Open_Flags) -> (Fd, Errno) {
+ ret := syscall(SYS_timerfd_create, clock_id, transmute(u32)flags)
+ return errno_unwrap2(ret, Fd)
+}
// TODO(flysand): eventfd
// TODO(flysand): fallocate
-// TODO(flysand): timerfd_settime
+/*
+ Arm/disarm the state of the Linux file descriptor based timer.
+ Available since Linux 2.6.25
+*/
+timerfd_settime :: proc "contextless" (fd: Fd, flags: ITimer_Flags, new_value: ^ITimer_Spec, old_value: ^ITimer_Spec) -> Errno {
+ ret := syscall(SYS_timerfd_settime, fd, transmute(u32)flags, new_value, old_value)
+ return Errno(-ret)
+}
-// TODO(flysand): timerfd_gettime
+/*
+ Get the state of the Linux file descriptor based timer.
+ Available since Linux 2.6.25
+*/
+timerfd_gettime :: proc "contextless" (fd: Fd, curr_value: ^ITimer_Spec) -> Errno {
+ ret := syscall(SYS_timerfd_gettime, fd, curr_value)
+ return Errno(-ret)
+}
// TODO(flysand): accept4