blob: 237b4a52696f31679781c39e266548b1c15e1035 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#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}));
}
#ifdef TEST
int
main(void) {
return 0;
}
#endif
|