diff options
Diffstat (limited to 'src/taia.c')
-rw-r--r-- | src/taia.c | 39 |
1 files changed, 23 insertions, 16 deletions
@@ -1,7 +1,8 @@ -#include <sys/types.h> -#include <sys/time.h> #include "taia.h" +#include <sys/time.h> +#include <sys/types.h> + /** @file taia.c @author djb @@ -11,7 +12,7 @@ /* XXX: breaks tai encapsulation */ -void taia_add(struct taia *t,struct taia *u,struct taia *v) +void taia_add(struct taia *t, struct taia *u, struct taia *v) { t->sec.x = u->sec.x + v->sec.x; t->nano = u->nano + v->nano; @@ -36,7 +37,7 @@ double taia_frac(struct taia *t) return (t->atto * 0.000000001 + t->nano) * 0.000000001; } -int taia_less(struct taia *t,struct taia *u) +int taia_less(struct taia *t, struct taia *u) { if (t->sec.x < u->sec.x) return 1; if (t->sec.x > u->sec.x) return 0; @@ -48,8 +49,8 @@ int taia_less(struct taia *t,struct taia *u) int taia_now(struct taia *t) { struct timeval now; - if (gettimeofday(&now,(struct timezone *) 0) == 0) { - tai_unix(&t->sec,now.tv_sec); + if (gettimeofday(&now, (struct timezone *)0) == 0) { + tai_unix(&t->sec, now.tv_sec); t->nano = 1000 * now.tv_usec + 500; t->atto = 0; return 0; @@ -59,26 +60,32 @@ int taia_now(struct taia *t) return -1; } -void taia_pack(char *s,struct taia *t) +void taia_pack(char *s, struct taia *t) { unsigned long x; - tai_pack(s,&t->sec); + tai_pack(s, &t->sec); s += 8; x = t->atto; - s[7] = x & 255; x >>= 8; - s[6] = x & 255; x >>= 8; - s[5] = x & 255; x >>= 8; + s[7] = x & 255; + x >>= 8; + s[6] = x & 255; + x >>= 8; + s[5] = x & 255; + x >>= 8; s[4] = x; x = t->nano; - s[3] = x & 255; x >>= 8; - s[2] = x & 255; x >>= 8; - s[1] = x & 255; x >>= 8; + s[3] = x & 255; + x >>= 8; + s[2] = x & 255; + x >>= 8; + s[1] = x & 255; + x >>= 8; s[0] = x; } -void taia_sub(struct taia *t,struct taia *u,struct taia *v) +void taia_sub(struct taia *t, struct taia *u, struct taia *v) { unsigned long unano = u->nano; unsigned long uatto = u->atto; @@ -96,7 +103,7 @@ void taia_sub(struct taia *t,struct taia *u,struct taia *v) } } -void taia_uint(struct taia *t,unsigned int s) +void taia_uint(struct taia *t, unsigned int s) { t->sec.x = s; t->nano = 0; |