Files
vlibc/src/time/gettimeofday.c
T

30 lines
907 B
C

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <sys/time.h>
#include "../internal/syscall.h"
#if VLIBC_LEVEL_GE(2)
/*
* gettimeofday: the current wall-clock time, via SYS_gettimeofday.
*
* The kernel writes the two-field struct timeval (tv_sec, tv_usec) that is
* layout-identical to the public struct timeval on x86_64, so the pointer
* passes straight through. The tz argument is deliberately ignored: the
* historic second parameter is obsolete, POSIX.1-2008 removed struct
* timezone, and no caller may rely on it being filled — NULL is passed to
* the kernel, which then leaves any timezone record untouched. tv may also
* be NULL, in which case the kernel writes nothing and 0 is returned.
*/
int
gettimeofday(struct timeval *restrict tv, void *restrict tz)
{
(void)tz;
return syscall_ret(__syscall2(SYS_gettimeofday, (long)tv, 0));
}
#endif /* VLIBC_LEVEL_GE(2) */