aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYeongju Kang <979156@gmail.com>2024-08-19 08:51:52 +0900
committerYeongju Kang <979156@gmail.com>2024-08-19 08:53:07 +0900
commitf96991364a8e0fe29c8c1e6c1915ed39776b5fea (patch)
treec01059f9b107260df255e0988c2ae15bdba8cada
parentbbb5593f87ce889b9517208ad82d5dfb53f395a6 (diff)
implement clock_settime, clock_getres and clock_nanosleep
-rw-r--r--core/sys/linux/sys.odin32
1 files changed, 29 insertions, 3 deletions
diff --git a/core/sys/linux/sys.odin b/core/sys/linux/sys.odin
index f4f609ab9..8aa2f09cc 100644
--- a/core/sys/linux/sys.odin
+++ b/core/sys/linux/sys.odin
@@ -2404,17 +2404,43 @@ timer_delete :: proc "contextless" (timer: Timer) -> (Errno) {
return Errno(-ret)
}
-// TODO(flysand): clock_settime
+/*
+ Set the time of the specified clock.
+ Available since Linux 2.6.
+*/
+clock_settime :: proc "contextless" (clock: Clock_Id, ts: ^Time_Spec) -> (Errno) {
+ ret := syscall(SYS_clock_settime, clock, ts)
+ return Errno(-ret)
+}
+/*
+ Retrieve the time of the specified clock.
+ Available since Linux 2.6.
+*/
clock_gettime :: proc "contextless" (clock: Clock_Id) -> (ts: Time_Spec, err: Errno) {
ret := syscall(SYS_clock_gettime, clock, &ts)
err = Errno(-ret)
return
}
-// TODO(flysand): clock_getres
-// TODO(flysand): clock_nanosleep
+/*
+ Finds the resolution of the specified clock.
+ Available since Linux 2.6.
+*/
+clock_getres :: proc "contextless" (clock: Clock_Id, res: ^Time_Spec) -> (Errno) {
+ ret := syscall(SYS_clock_getres, clock, res)
+ return Errno(-ret)
+}
+
+/*
+ Sleep for an interval specified with nanosecond precision.
+ Available since Linux 2.6.
+*/
+clock_nanosleep :: proc "contextless" (clock: Clock_Id, flags: ITimer_Flags, request: ^Time_Spec, remain: ^Time_Spec) -> (Errno) {
+ ret := syscall(SYS_clock_nanosleep, clock, transmute(u32) flags, request, remain)
+ return Errno(-ret)
+}
/*
Exit the thread group.