• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #define _GNU_SOURCE
2 #include <sys/time.h>
3 #include <sys/timex.h>
4 #include <errno.h>
5 #include "syscall.h"
6 #include <unsupported_api.h>
7 
adjtime(const struct timeval * in,struct timeval * out)8 int adjtime(const struct timeval *in, struct timeval *out)
9 {
10 	struct timex tx = { 0 };
11 	unsupported_api(__FUNCTION__);
12 	if (in) {
13 		if (in->tv_sec > 1000 || in->tv_usec > 1000000000) {
14 			errno = EINVAL;
15 			return -1;
16 		}
17 		tx.offset = in->tv_sec*1000000 + in->tv_usec;
18 		tx.modes = ADJ_OFFSET_SINGLESHOT;
19 	}
20 	if (adjtimex(&tx) < 0) return -1;
21 	if (out) {
22 		out->tv_sec = tx.offset / 1000000;
23 		if ((out->tv_usec = tx.offset % 1000000) < 0) {
24 			out->tv_sec--;
25 			out->tv_usec += 1000000;
26 		}
27 	}
28 	return 0;
29 }
30