1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
| | #include "time32.h"
#include <time.h>
#include <sys/time.h>
#include <sys/timex.h>
#include <string.h>
#include <stddef.h>
struct oldtimex {
unsigned modes;
long offset, freq, maxerror, esterror;
int status;
long constant, precision, tolerance;
long time_sec, time_usec;
long tick, ppsfreq, jitter;
int shift;
long stabil, jitcnt, calcnt, errcnt, stbcnt;
int tai;
int __padding[11];
};
int __adjtimex_time32(struct timex *tx32)
{
struct timex utx;
memcpy(&utx, tx32, sizeof(struct oldtimex));
utx.time.tv_sec =
*(long *)((char *)tx32 + offsetof(struct oldtimex,time_sec));
utx.time.tv_usec =
*(long *)((char *)tx32 + offsetof(struct oldtimex,time_usec));
int r = adjtimex(&utx);
if (r<0) return r;
memcpy(tx32, &utx, sizeof(struct oldtimex));
*(long *)((char *)tx32 + offsetof(struct oldtimex,time_sec)) =
utx.time.tv_sec;
*(long *)((char *)tx32 + offsetof(struct oldtimex,time_usec)) =
utx.time.tv_usec;
return r;
}
|