1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 23:37:36 +00:00

LibC: Implement gettimeofday() in terms of clock_gettime(CLOCK_REALTIME)

This commit is contained in:
Andreas Kling 2021-08-10 12:48:37 +02:00
parent 1be59d663a
commit 5f6e0e0162

View file

@ -38,8 +38,17 @@ int adjtime(const struct timeval* delta, struct timeval* old_delta)
int gettimeofday(struct timeval* __restrict__ tv, void* __restrict__)
{
int rc = syscall(SC_gettimeofday, tv);
__RETURN_WITH_ERRNO(rc, rc, -1);
if (!tv) {
errno = EFAULT;
return -1;
}
struct timespec ts = {};
if (clock_gettime(CLOCK_REALTIME, &ts) < 0)
return -1;
TIMESPEC_TO_TIMEVAL(tv, &ts);
return 0;
}
int settimeofday(struct timeval* __restrict__ tv, void* __restrict__)