diff options
Diffstat (limited to '')
-rw-r--r-- | libc-top-half/musl/src/linux/settimeofday.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libc-top-half/musl/src/linux/settimeofday.c b/libc-top-half/musl/src/linux/settimeofday.c new file mode 100644 index 0000000..860fb5d --- /dev/null +++ b/libc-top-half/musl/src/linux/settimeofday.c @@ -0,0 +1,13 @@ +#define _BSD_SOURCE +#include <sys/time.h> +#include <time.h> +#include <errno.h> +#include "syscall.h" + +int settimeofday(const struct timeval *tv, const struct timezone *tz) +{ + if (!tv) return 0; + if (tv->tv_usec >= 1000000ULL) return __syscall_ret(-EINVAL); + return clock_settime(CLOCK_REALTIME, &((struct timespec){ + .tv_sec = tv->tv_sec, .tv_nsec = tv->tv_usec * 1000})); +} |