6 #define IS32BIT(x) !((x)+0x80000000ULL>>32)
11 long long offset, freq, maxerror, esterror;
14 long long constant, precision, tolerance;
15 long long time_sec, time_usec;
16 long long tick, ppsfreq, jitter;
19 long long stabil, jitcnt, calcnt, errcnt, stbcnt;
26 long offset, freq, maxerror, esterror;
28 long constant, precision, tolerance;
29 long time_sec, time_usec;
30 long tick, ppsfreq, jitter;
32 long stabil, jitcnt, calcnt, errcnt, stbcnt;
37 int clock_adjtime (clockid_t clock_id, struct timex *utx)
40 #ifdef SYS_clock_adjtime64
41 if (SYS_clock_adjtime == SYS_clock_adjtime64 ||
42 (utx->modes & ADJ_SETOFFSET) && !IS32BIT(utx->time.tv_sec)) {
43 struct ktimex64 ktx = {
45 .offset = utx->offset,
47 .maxerror = utx->maxerror,
48 .esterror = utx->esterror,
49 .status = utx->status,
50 .constant = utx->constant,
51 .precision = utx->precision,
52 .tolerance = utx->tolerance,
53 .time_sec = utx->time.tv_sec,
54 .time_usec = utx->time.tv_usec,
56 .ppsfreq = utx->ppsfreq,
57 .jitter = utx->jitter,
59 .stabil = utx->stabil,
60 .jitcnt = utx->jitcnt,
61 .calcnt = utx->calcnt,
62 .errcnt = utx->errcnt,
63 .stbcnt = utx->stbcnt,
66 r = __syscall(SYS_clock_adjtime, clock_id, &ktx);
68 utx->modes = ktx.modes;
69 utx->offset = ktx.offset;
71 utx->maxerror = ktx.maxerror;
72 utx->esterror = ktx.esterror;
73 utx->status = ktx.status;
74 utx->constant = ktx.constant;
75 utx->precision = ktx.precision;
76 utx->tolerance = ktx.tolerance;
77 utx->time.tv_sec = ktx.time_sec;
78 utx->time.tv_usec = ktx.time_usec;
80 utx->ppsfreq = ktx.ppsfreq;
81 utx->jitter = ktx.jitter;
82 utx->shift = ktx.shift;
83 utx->stabil = ktx.stabil;
84 utx->jitcnt = ktx.jitcnt;
85 utx->calcnt = ktx.calcnt;
86 utx->errcnt = ktx.errcnt;
87 utx->stbcnt = ktx.stbcnt;
91 if (SYS_clock_adjtime == SYS_clock_adjtime64 || r!=-ENOSYS)
92 return __syscall_ret(r);
93 if ((utx->modes & ADJ_SETOFFSET) && !IS32BIT(utx->time.tv_sec))
94 return __syscall_ret(-ENOTSUP);
96 if (sizeof(time_t) > sizeof(long)) {
99 .offset = utx->offset,
101 .maxerror = utx->maxerror,
102 .esterror = utx->esterror,
103 .status = utx->status,
104 .constant = utx->constant,
105 .precision = utx->precision,
106 .tolerance = utx->tolerance,
107 .time_sec = utx->time.tv_sec,
108 .time_usec = utx->time.tv_usec,
110 .ppsfreq = utx->ppsfreq,
111 .jitter = utx->jitter,
113 .stabil = utx->stabil,
114 .jitcnt = utx->jitcnt,
115 .calcnt = utx->calcnt,
116 .errcnt = utx->errcnt,
117 .stbcnt = utx->stbcnt,
121 if (clock_id==CLOCK_REALTIME) r = __syscall(SYS_adjtimex, &ktx);
124 r = __syscall(SYS_clock_adjtime, clock_id, &ktx);
126 utx->modes = ktx.modes;
127 utx->offset = ktx.offset;
128 utx->freq = ktx.freq;
129 utx->maxerror = ktx.maxerror;
130 utx->esterror = ktx.esterror;
131 utx->status = ktx.status;
132 utx->constant = ktx.constant;
133 utx->precision = ktx.precision;
134 utx->tolerance = ktx.tolerance;
135 utx->time.tv_sec = ktx.time_sec;
136 utx->time.tv_usec = ktx.time_usec;
137 utx->tick = ktx.tick;
138 utx->ppsfreq = ktx.ppsfreq;
139 utx->jitter = ktx.jitter;
140 utx->shift = ktx.shift;
141 utx->stabil = ktx.stabil;
142 utx->jitcnt = ktx.jitcnt;
143 utx->calcnt = ktx.calcnt;
144 utx->errcnt = ktx.errcnt;
145 utx->stbcnt = ktx.stbcnt;
148 return __syscall_ret(r);
151 if (clock_id==CLOCK_REALTIME) return syscall(SYS_adjtimex, utx);
153 return syscall(SYS_clock_adjtime, clock_id, utx);