Luna/libs/libc/src/time.cpp
apio d93a4062a2 libc: Do not use the heavy variadic syscall() function for wrappers
That function is meant more for user programs, and should still be rarely used, since it's not portable.
Instead, we already know the number of arguments. We just call __lc_fast_syscallN, which also sets errno.
2022-10-27 17:42:00 +02:00

37 lines
885 B
C++

#include <luna.h>
#include <luna/syscall.h>
#include <sys/syscall.h>
#include <time.h>
#include <unistd.h>
extern "C"
{
clock_t clock()
{
return __lc_fast_syscall0(SYS_clock);
}
time_t time(
time_t* tloc) // Very big FIXME: This is not the time of day, this just returns the same as clock() but in
// seconds. This is definitely wrong, but I'm not implementing a whole time system right now.
{
time_t result = (time_t)(syscall(SYS_clock) / CLOCKS_PER_SEC);
if (tloc) { *tloc = result; }
return result;
}
struct tm* localtime(const time_t*)
{
NOT_IMPLEMENTED("localtime");
}
struct tm* gmtime(const time_t*)
{
NOT_IMPLEMENTED("gmtime");
}
size_t strftime(char*, size_t, const char*, const struct tm*)
{
NOT_IMPLEMENTED("strftime");
}
}