21 static inline void tai_pack(unsigned char *s
, struct tai
*t
)
27 s
[7] = x
& 255; x
>>= 8;
28 s
[6] = x
& 255; x
>>= 8;
29 s
[5] = x
& 255; x
>>= 8;
30 s
[4] = x
& 255; x
>>= 8;
31 s
[3] = x
& 255; x
>>= 8;
32 s
[2] = x
& 255; x
>>= 8;
33 s
[1] = x
& 255; x
>>= 8;
37 static inline void tai_unpack(unsigned char *s
, struct tai
*t
)
41 x
= (unsigned char) s
[0];
42 x
<<= 8; x
+= (unsigned char) s
[1];
43 x
<<= 8; x
+= (unsigned char) s
[2];
44 x
<<= 8; x
+= (unsigned char) s
[3];
45 x
<<= 8; x
+= (unsigned char) s
[4];
46 x
<<= 8; x
+= (unsigned char) s
[5];
47 x
<<= 8; x
+= (unsigned char) s
[6];
48 x
<<= 8; x
+= (unsigned char) s
[7];
53 static inline void taia_pack(unsigned char *s
, struct taia
*t
)
63 s
[7] = x
& 255; x
>>= 8;
64 s
[6] = x
& 255; x
>>= 8;
65 s
[5] = x
& 255; x
>>= 8;
70 s
[3] = x
& 255; x
>>= 8;
71 s
[2] = x
& 255; x
>>= 8;
72 s
[1] = x
& 255; x
>>= 8;
76 static inline void taia_unpack(unsigned char *s
, struct taia
*t
)
80 tai_unpack(s
, &t
->sec
);
84 x
= (unsigned char) s
[4];
85 x
<<= 8; x
+= (unsigned char) s
[5];
86 x
<<= 8; x
+= (unsigned char) s
[6];
87 x
<<= 8; x
+= (unsigned char) s
[7];
91 x
= (unsigned char) s
[0];
92 x
<<= 8; x
+= (unsigned char) s
[1];
93 x
<<= 8; x
+= (unsigned char) s
[2];
94 x
<<= 8; x
+= (unsigned char) s
[3];
99 #define tai_unix(t, u) \
100 ((void) ((t)->x = 4611686018427387914ULL + \
103 static inline void taia_now(struct taia
*t
)
107 gettimeofday(&now
, NULL
);
109 tai_unix(&t
->sec
, now
.tv_sec
);
110 t
->nano
= 1000 * now
.tv_usec
+ 500;
111 /* We don't really have it, but bring some noise in. */
115 static inline void taia_sub(struct taia
*res
, const struct taia
*u
,
116 const struct taia
*v
)
118 unsigned long unano
= u
->nano
;
119 unsigned long uatto
= u
->atto
;
121 res
->sec
.x
= u
->sec
.x
- v
->sec
.x
;
122 res
->nano
= unano
- v
->nano
;
123 res
->atto
= uatto
- v
->atto
;
125 if (res
->atto
> uatto
) {
126 res
->atto
+= 1000000000UL;
130 if (res
->nano
> unano
) {
131 res
->nano
+= 1000000000UL;
136 static inline void taia_add(struct taia
*res
, const struct taia
*u
,
137 const struct taia
*v
)
139 res
->sec
.x
= u
->sec
.x
+ v
->sec
.x
;
140 res
->nano
= u
->nano
+ v
->nano
;
141 res
->atto
= u
->atto
+ v
->atto
;
143 if (res
->atto
> 999999999UL) {
144 res
->atto
-= 1000000000UL;
148 if (res
->nano
> 999999999UL) {
149 res
->nano
-= 1000000000UL;
154 static inline int taia_less(const struct taia
*t
, const struct taia
*u
)
156 if (t
->sec
.x
< u
->sec
.x
)
158 if (t
->sec
.x
> u
->sec
.x
)
160 if (t
->nano
< u
->nano
)
162 if (t
->nano
> u
->nano
)
164 return t
->atto
< u
->atto
;
167 extern bool taia_looks_good(struct taia
*arr_taia
, struct taia
*pkt_taia
);