mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 20:58:22 +00:00
syscalls: implement clock_getres
This commit is contained in:
@@ -102,6 +102,7 @@ extern syscall_yield
|
||||
extern syscall_fstatvfs
|
||||
extern syscall_fstatvfsat
|
||||
extern syscall_getsockopt
|
||||
extern syscall_clock_getres
|
||||
syscalltab:
|
||||
dq syscall_print
|
||||
dq syscall_mmap
|
||||
@@ -206,7 +207,8 @@ dq syscall_yield
|
||||
dq syscall_fstatvfs
|
||||
dq syscall_fstatvfsat
|
||||
dq syscall_getsockopt
|
||||
syscallcount equ 103
|
||||
dq syscall_clock_getres
|
||||
syscallcount equ 104
|
||||
section .text
|
||||
global arch_syscall_entry
|
||||
; on entry:
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
void arch_interrupt_disable();
|
||||
void arch_interrupt_enable();
|
||||
|
||||
#define SYSCALL_COUNT 103
|
||||
#define SYSCALL_COUNT 104
|
||||
#define LOGSTR(x) arch_e9_puts(x)
|
||||
|
||||
static char *name[] = {
|
||||
@@ -116,6 +116,7 @@ static char *name[] = {
|
||||
"fstatvfs",
|
||||
"fstatvfsat",
|
||||
"getsockopt",
|
||||
"clock_getres",
|
||||
};
|
||||
|
||||
static char *args[] = {
|
||||
@@ -222,6 +223,7 @@ static char *args[] = {
|
||||
"fd %d ustat %p", // fstatvfs
|
||||
"dirfd %d path %s ustat %p flags %d", // fstatvfsat
|
||||
"fd %d level %d optname %d optval %p optlen %p", // getsockopt
|
||||
"clockid %d timespec %p", // clock_getres
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
#include <kernel/syscalls.h>
|
||||
#include <time.h>
|
||||
#include <kernel/usercopy.h>
|
||||
|
||||
#define CLOCK_REALTIME 0
|
||||
#define CLOCK_MONOTONIC 1
|
||||
#define CLOCK_BOOTTIME 7
|
||||
|
||||
syscallret_t syscall_clock_getres(context_t *, int clockid, timespec_t *res) {
|
||||
syscallret_t ret;
|
||||
|
||||
switch (clockid) {
|
||||
case CLOCK_REALTIME:
|
||||
case CLOCK_MONOTONIC:
|
||||
case CLOCK_BOOTTIME:
|
||||
if (res) {
|
||||
timespec_t ts = {
|
||||
.s = 0,
|
||||
.ns = 1
|
||||
};
|
||||
|
||||
ret.errno = usercopy_touser(res, &ts, sizeof(timespec_t));
|
||||
} else {
|
||||
ret.errno = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ret.errno = EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
ret.ret = ret.errno ? -1 : 0;
|
||||
return ret;
|
||||
}
|
||||
Reference in New Issue
Block a user