xref: /aosp_15_r20/external/musl/compat/time32/clock_adjtime32.c (revision c9945492fdd68bbe62686c5b452b4dc1be3f8453)
1*c9945492SAndroid Build Coastguard Worker #include "time32.h"
2*c9945492SAndroid Build Coastguard Worker #include <time.h>
3*c9945492SAndroid Build Coastguard Worker #include <sys/time.h>
4*c9945492SAndroid Build Coastguard Worker #include <sys/timex.h>
5*c9945492SAndroid Build Coastguard Worker #include <string.h>
6*c9945492SAndroid Build Coastguard Worker #include <stddef.h>
7*c9945492SAndroid Build Coastguard Worker 
8*c9945492SAndroid Build Coastguard Worker struct timex32 {
9*c9945492SAndroid Build Coastguard Worker 	unsigned modes;
10*c9945492SAndroid Build Coastguard Worker 	long offset, freq, maxerror, esterror;
11*c9945492SAndroid Build Coastguard Worker 	int status;
12*c9945492SAndroid Build Coastguard Worker 	long constant, precision, tolerance;
13*c9945492SAndroid Build Coastguard Worker 	struct timeval32 time;
14*c9945492SAndroid Build Coastguard Worker 	long tick, ppsfreq, jitter;
15*c9945492SAndroid Build Coastguard Worker 	int shift;
16*c9945492SAndroid Build Coastguard Worker 	long stabil, jitcnt, calcnt, errcnt, stbcnt;
17*c9945492SAndroid Build Coastguard Worker 	int tai;
18*c9945492SAndroid Build Coastguard Worker 	int __padding[11];
19*c9945492SAndroid Build Coastguard Worker };
20*c9945492SAndroid Build Coastguard Worker 
__clock_adjtime32(clockid_t clock_id,struct timex32 * tx32)21*c9945492SAndroid Build Coastguard Worker int __clock_adjtime32(clockid_t clock_id, struct timex32 *tx32)
22*c9945492SAndroid Build Coastguard Worker {
23*c9945492SAndroid Build Coastguard Worker 	struct timex utx = {
24*c9945492SAndroid Build Coastguard Worker 		.modes = tx32->modes,
25*c9945492SAndroid Build Coastguard Worker 		.offset = tx32->offset,
26*c9945492SAndroid Build Coastguard Worker 		.freq = tx32->freq,
27*c9945492SAndroid Build Coastguard Worker 		.maxerror = tx32->maxerror,
28*c9945492SAndroid Build Coastguard Worker 		.esterror = tx32->esterror,
29*c9945492SAndroid Build Coastguard Worker 		.status = tx32->status,
30*c9945492SAndroid Build Coastguard Worker 		.constant = tx32->constant,
31*c9945492SAndroid Build Coastguard Worker 		.precision = tx32->precision,
32*c9945492SAndroid Build Coastguard Worker 		.tolerance = tx32->tolerance,
33*c9945492SAndroid Build Coastguard Worker 		.time.tv_sec = tx32->time.tv_sec,
34*c9945492SAndroid Build Coastguard Worker 		.time.tv_usec = tx32->time.tv_usec,
35*c9945492SAndroid Build Coastguard Worker 		.tick = tx32->tick,
36*c9945492SAndroid Build Coastguard Worker 		.ppsfreq = tx32->ppsfreq,
37*c9945492SAndroid Build Coastguard Worker 		.jitter = tx32->jitter,
38*c9945492SAndroid Build Coastguard Worker 		.shift = tx32->shift,
39*c9945492SAndroid Build Coastguard Worker 		.stabil = tx32->stabil,
40*c9945492SAndroid Build Coastguard Worker 		.jitcnt = tx32->jitcnt,
41*c9945492SAndroid Build Coastguard Worker 		.calcnt = tx32->calcnt,
42*c9945492SAndroid Build Coastguard Worker 		.errcnt = tx32->errcnt,
43*c9945492SAndroid Build Coastguard Worker 		.stbcnt = tx32->stbcnt,
44*c9945492SAndroid Build Coastguard Worker 		.tai = tx32->tai,
45*c9945492SAndroid Build Coastguard Worker 	};
46*c9945492SAndroid Build Coastguard Worker 	int r = clock_adjtime(clock_id, &utx);
47*c9945492SAndroid Build Coastguard Worker 	if (r<0) return r;
48*c9945492SAndroid Build Coastguard Worker 	tx32->modes = utx.modes;
49*c9945492SAndroid Build Coastguard Worker 	tx32->offset = utx.offset;
50*c9945492SAndroid Build Coastguard Worker 	tx32->freq = utx.freq;
51*c9945492SAndroid Build Coastguard Worker 	tx32->maxerror = utx.maxerror;
52*c9945492SAndroid Build Coastguard Worker 	tx32->esterror = utx.esterror;
53*c9945492SAndroid Build Coastguard Worker 	tx32->status = utx.status;
54*c9945492SAndroid Build Coastguard Worker 	tx32->constant = utx.constant;
55*c9945492SAndroid Build Coastguard Worker 	tx32->precision = utx.precision;
56*c9945492SAndroid Build Coastguard Worker 	tx32->tolerance = utx.tolerance;
57*c9945492SAndroid Build Coastguard Worker 	tx32->time.tv_sec = utx.time.tv_sec;
58*c9945492SAndroid Build Coastguard Worker 	tx32->time.tv_usec = utx.time.tv_usec;
59*c9945492SAndroid Build Coastguard Worker 	tx32->tick = utx.tick;
60*c9945492SAndroid Build Coastguard Worker 	tx32->ppsfreq = utx.ppsfreq;
61*c9945492SAndroid Build Coastguard Worker 	tx32->jitter = utx.jitter;
62*c9945492SAndroid Build Coastguard Worker 	tx32->shift = utx.shift;
63*c9945492SAndroid Build Coastguard Worker 	tx32->stabil = utx.stabil;
64*c9945492SAndroid Build Coastguard Worker 	tx32->jitcnt = utx.jitcnt;
65*c9945492SAndroid Build Coastguard Worker 	tx32->calcnt = utx.calcnt;
66*c9945492SAndroid Build Coastguard Worker 	tx32->errcnt = utx.errcnt;
67*c9945492SAndroid Build Coastguard Worker 	tx32->stbcnt = utx.stbcnt;
68*c9945492SAndroid Build Coastguard Worker 	tx32->tai = utx.tai;
69*c9945492SAndroid Build Coastguard Worker 	return r;
70*c9945492SAndroid Build Coastguard Worker }
71