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:
parent
1be59d663a
commit
5f6e0e0162
1 changed files with 11 additions and 2 deletions
|
@ -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__)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue