Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core:sys/linux - implement clock_settime, clock_getres and clock_nanosleep #4106

Merged
merged 2 commits into from
Aug 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 30 additions & 3 deletions core/sys/linux/sys.odin
Original file line number Diff line number Diff line change
Expand Up @@ -2404,17 +2404,44 @@ 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, err: Errno) {
ret := syscall(SYS_clock_getres, clock, &res)
err = Errno(-ret)
return
}

/*
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.
Expand Down