aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Salcher <dev.felix.salcher@gmail.com>2025-12-13 17:27:32 +0100
committerFelix Salcher <dev.felix.salcher@gmail.com>2025-12-13 17:27:32 +0100
commita325ab469fb1367da3f2d37cb7fc15fafd5a1122 (patch)
treec99df7521b862335db75392bfdd657fedcf39196
parentab9a05ed2d2e0eb76ef53709f91c54534aee543a (diff)
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