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