Last change
on this file since 403 was 337, checked in by coas-nagasima, 6 years ago |
ASP3版ECNLを追加
|
-
Property svn:eol-style
set to
native
-
Property svn:mime-type
set to
text/x-csrc;charset=UTF-8
|
File size:
596 bytes
|
Line | |
---|
1 | #define _GNU_SOURCE
|
---|
2 | #include <sys/time.h>
|
---|
3 | #include <sys/timex.h>
|
---|
4 | #include <errno.h>
|
---|
5 | #include "syscall.h"
|
---|
6 |
|
---|
7 | int adjtime(const struct timeval *in, struct timeval *out)
|
---|
8 | {
|
---|
9 | struct timex tx = { 0 };
|
---|
10 | if (in) {
|
---|
11 | if (in->tv_sec > 1000 || in->tv_usec > 1000000000) {
|
---|
12 | errno = EINVAL;
|
---|
13 | return -1;
|
---|
14 | }
|
---|
15 | tx.offset = in->tv_sec*1000000 + in->tv_usec;
|
---|
16 | tx.modes = ADJ_OFFSET_SINGLESHOT;
|
---|
17 | }
|
---|
18 | if (syscall(SYS_adjtimex, &tx) < 0) return -1;
|
---|
19 | if (out) {
|
---|
20 | out->tv_sec = tx.offset / 1000000;
|
---|
21 | if ((out->tv_usec = tx.offset % 1000000) < 0) {
|
---|
22 | out->tv_sec--;
|
---|
23 | out->tv_usec += 1000000;
|
---|
24 | }
|
---|
25 | }
|
---|
26 | return 0;
|
---|
27 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.