feat(systime): gettimeofday/itimer/utimes

This commit is contained in:
2026-09-05 22:43:39 -04:00
parent d495d3eb89
commit c67e890b17
8 changed files with 780 additions and 1 deletions
+29
View File
@@ -0,0 +1,29 @@
#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) */