From a15ffcb0713e0f6a58fcdc83c6516c76b0f77992 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Mon, 4 Sep 2023 13:52:58 +0300 Subject: [PATCH] LibC: add time() implementation --- libc/time.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libc/time.cpp b/libc/time.cpp index 9d62dbc1..83122fbf 100644 --- a/libc/time.cpp +++ b/libc/time.cpp @@ -10,4 +10,14 @@ int clock_gettime(clockid_t clock_id, struct timespec* tp) int nanosleep(const struct timespec* rqtp, struct timespec* rmtp) { return syscall(SYS_NANOSLEEP, rqtp, rmtp); +} + +time_t time(time_t* tloc) +{ + timespec tp; + if (clock_gettime(CLOCK_REALTIME, &tp) == -1) + return -1; + if (tloc) + *tloc = tp.tv_sec; + return tp.tv_sec; } \ No newline at end of file