diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libstddjb/tai_add.c | 3 | ||||
-rw-r--r-- | src/libstddjb/tai_sub.c | 3 | ||||
-rw-r--r-- | src/libstddjb/tain_add.c | 12 | ||||
-rw-r--r-- | src/libstddjb/tain_addsec.c | 11 | ||||
-rw-r--r-- | src/libstddjb/tain_sub.c | 6 |
5 files changed, 17 insertions, 18 deletions
diff --git a/src/libstddjb/tai_add.c b/src/libstddjb/tai_add.c index ad481ea..5a3d47a 100644 --- a/src/libstddjb/tai_add.c +++ b/src/libstddjb/tai_add.c @@ -4,5 +4,6 @@ int tai_add (tai_t *t, tai_t const *u, tai_t const *v) { - return tai_u64(t, tai_sec(u) + tai_sec(v)) ; + t->x = u->x + v->x ; + return 1 ; } diff --git a/src/libstddjb/tai_sub.c b/src/libstddjb/tai_sub.c index e0cda7a..b85f1f2 100644 --- a/src/libstddjb/tai_sub.c +++ b/src/libstddjb/tai_sub.c @@ -4,5 +4,6 @@ int tai_sub (tai_t *t, tai_t const *u, tai_t const *v) { - return tai_u64(t, tai_sec(u) - tai_sec(v)) ; + t->x = u->x - v->x ; + return 1 ; } diff --git a/src/libstddjb/tain_add.c b/src/libstddjb/tain_add.c index aa6e705..b119270 100644 --- a/src/libstddjb/tain_add.c +++ b/src/libstddjb/tain_add.c @@ -4,14 +4,12 @@ int tain_add (tain_t *t, tain_t const *u, tain_t const *v) { - tain_t tt = *u ; - if (!tai_add(&tt.sec, &u->sec, &v->sec)) return 0 ; - tt.nano = u->nano + v->nano ; - if (tt.nano > 999999999U) + t->sec.x = u->sec.x + v->sec.x ; + t->nano = u->nano + v->nano ; + if (t->nano > 999999999U) { - if (!tai_u64(&tt.sec, tai_sec(&tt.sec) + 1)) return 0 ; - tt.nano -= 1000000000U ; + t->sec.x++ ; + t->nano -= 1000000000U ; } - *t = tt ; return 1 ; } diff --git a/src/libstddjb/tain_addsec.c b/src/libstddjb/tain_addsec.c index 524ac20..b0d19e2 100644 --- a/src/libstddjb/tain_addsec.c +++ b/src/libstddjb/tain_addsec.c @@ -1,20 +1,19 @@ /* ISC license. */ +#include <skalibs/uint64.h> #include <skalibs/tai.h> int tain_addsec (tain_t *b, tain_t const *a, int c) { if (c >= 0) { - tai_t t ; - if (!tai_u64(&t, c)) return 0 ; - if (!tai_add(&b->sec, &a->sec, &t)) return 0 ; + tai_t t = { .x = (uint64)c } ; + tai_add(&b->sec, &a->sec, &t) ; } else { - tai_t t ; - if (!tai_u64(&t, -c)) return 0 ; - if (!tai_sub(&b->sec, &a->sec, &t)) return 0 ; + tai_t t = { .x = (uint64)-c } ; + tai_sub(&b->sec, &a->sec, &t) ; } b->nano = a->nano ; return 1 ; diff --git a/src/libstddjb/tain_sub.c b/src/libstddjb/tain_sub.c index 2921aa6..0d756e7 100644 --- a/src/libstddjb/tain_sub.c +++ b/src/libstddjb/tain_sub.c @@ -4,12 +4,12 @@ int tain_sub (tain_t *t, tain_t const *u, tain_t const *v) { - tain_t tt = *u ; - if (!tai_sub(&tt.sec, &u->sec, &v->sec)) return 0 ; + tain_t tt ; + tt.sec.x = u->sec.x - v->sec.x ; tt.nano = u->nano - v->nano ; if (tt.nano > u->nano) { - if (!tai_u64(&tt.sec, tai_sec(&tt.sec) - 1)) return 0 ; + tt.sec.x-- ; tt.nano += 1000000000U ; } *t = tt ; |