fehQlibs 26
Qlibs
Loading...
Searching...
No Matches
tai.c
Go to the documentation of this file.
1#include <time.h>
2#include "tai.h"
3
11void tai_add(struct tai *t,const struct tai *u,const struct tai *v)
12{
13 t->x = u->x + v->x;
14}
15
16void tai_now(struct tai *t)
17{
18 tai_unix(t,time((time_t *) 0));
19}
20
21void tai_pack(char *s,const struct tai *t)
22{
23 uint64 x;
24
25 x = t->x;
26 s[7] = (char)x; x >>= 8;
27 s[6] = (char)x; x >>= 8;
28 s[5] = (char)x; x >>= 8;
29 s[4] = (char)x; x >>= 8;
30 s[3] = (char)x; x >>= 8;
31 s[2] = (char)x; x >>= 8;
32 s[1] = (char)x; x >>= 8;
33 s[0] = (char)x;
34}
35
36void tai_sub(struct tai *t,const struct tai *u,const struct tai *v)
37{
38 t->x = u->x - v->x;
39}
40
41void tai_uint(struct tai *t,unsigned int u)
42{
43 t->x = u;
44}
45
46void tai_unpack(const char *s,struct tai *t)
47{
48 uint64 x;
49
50 x = (unsigned char) s[0];
51 x <<= 8; x += (unsigned char) s[1];
52 x <<= 8; x += (unsigned char) s[2];
53 x <<= 8; x += (unsigned char) s[3];
54 x <<= 8; x += (unsigned char) s[4];
55 x <<= 8; x += (unsigned char) s[5];
56 x <<= 8; x += (unsigned char) s[6];
57 x <<= 8; x += (unsigned char) s[7];
58 t->x = x;
59}
void tai_sub(struct tai *t, const struct tai *u, const struct tai *v)
Definition: tai.c:36
void tai_pack(char *s, const struct tai *t)
Definition: tai.c:21
void tai_now(struct tai *t)
Definition: tai.c:16
void tai_unpack(const char *s, struct tai *t)
Definition: tai.c:46
void tai_add(struct tai *t, const struct tai *u, const struct tai *v)
Definition: tai.c:11
void tai_uint(struct tai *t, unsigned int u)
Definition: tai.c:41
#define tai_unix(t, u)
Definition: tai.h:35
unsigned long long uint64
Definition: uint_t.h:54
Definition: tai.h:30
uint64 x
Definition: tai.h:31