From ad2c91dbd286bf8e11476af7b4007de09879bdbe Mon Sep 17 00:00:00 2001 From: Zapaxe Date: Sun, 31 May 2026 12:19:17 +0530 Subject: [PATCH] Add timespec, Nanosleep(), ClockGettime() and syscall constants --- Src/Syscall.rux | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Src/Syscall.rux b/Src/Syscall.rux index 0d43225..81213d6 100644 --- a/Src/Syscall.rux +++ b/Src/Syscall.rux @@ -18,7 +18,10 @@ module Linux { const SYS_MUNMAP: uint64 = 11u64; const SYS_BRK: uint64 = 12u64; const SYS_GETPID: uint64 = 39u64; + const SYS_NANOSLEEP: uint64 = 35u64; const SYS_EXIT: uint64 = 60u64; + const SYS_TIME: uint64 = 201u64; + const SYS_CLOCK_GETTIME: uint64 = 228u64; // mmap protection and mapping flags used by Mmap. const PROT_READ: int32 = 1i32; @@ -111,4 +114,23 @@ module Linux { func Errno(result: int64) -> int64 { return IsError(result) ? -result : 0i64; } + + struct timespec { + tv_sec: int64; + tv_nsec: int64; + } + + @[Import(lib: "rux-linux")] + extern { + func __rux_linux_nanosleep(req: *timespec, rem: *timespec) -> int64; + func __rux_linux_clock_gettime(clk_id: int32, tp: *timespec) -> int64; + } + + func Nanosleep(req: *timespec, rem: *timespec) -> int64 { + return __rux_linux_nanosleep(req, rem); + } + + func ClockGettime(clk_id: int32, tp: *timespec) -> int64 { + return __rux_linux_clock_gettime(clk_id, tp); + } }