about summary refs log tree commit diff
path: root/src/linux/settimeofday.c
blob: 860fb5de97b006c2d0c2c1e12a1cd6fd3f3a9a1b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
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}));
}