Kernel/LibC: add clock_gettime() for CLOCK_MONOTONIC
This gets the number of milliseconds since boot
This commit is contained in:
@@ -14,6 +14,7 @@ set(LIBC_SOURCES
|
||||
sys/stat.cpp
|
||||
sys/wait.cpp
|
||||
termios.cpp
|
||||
time.cpp
|
||||
unistd.cpp
|
||||
math.S
|
||||
icxxabi.cpp
|
||||
|
||||
@@ -38,6 +38,7 @@ __BEGIN_DECLS
|
||||
#define SYS_GET_EGID 31
|
||||
#define SYS_GET_PWD 32
|
||||
#define SYS_SET_PWD 33
|
||||
#define SYS_CLOCK_GETTIME 34
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
||||
8
libc/time.cpp
Normal file
8
libc/time.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <sys/syscall.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int clock_gettime(clockid_t clock_id, struct timespec* tp)
|
||||
{
|
||||
return syscall(SYS_CLOCK_GETTIME, clock_id, tp);
|
||||
}
|
||||
@@ -244,6 +244,13 @@ long syscall(long syscall, ...)
|
||||
ret = Kernel::syscall(SYS_SET_PWD, (uintptr_t)path);
|
||||
break;
|
||||
}
|
||||
case SYS_CLOCK_GETTIME:
|
||||
{
|
||||
clockid_t clock_id = va_arg(args, clockid_t);
|
||||
timespec* tp = va_arg(args, timespec*);
|
||||
ret = Kernel::syscall(SYS_CLOCK_GETTIME, clock_id, (uintptr_t)tp);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
puts("LibC: Unhandeled syscall");
|
||||
ret = -ENOSYS;
|
||||
|
||||
Reference in New Issue
Block a user