commit 380b8a59dccaf828f5fc0c0961195c71479217dd
parent effe4db8a69d475ae77bb7bf85bf53c009445d0e
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date: Wed, 3 Jun 2015 14:59:53 +0000
Bugfix: remove overflow checking in tai?_add/sub
(because it doesn't work with relative times, duh!)
Diffstat:
6 files changed, 18 insertions(+), 19 deletions(-)
diff --git a/package/deps.mak b/package/deps.mak
@@ -617,7 +617,7 @@ src/libstddjb/tai_u64.o src/libstddjb/tai_u64.lo: src/libstddjb/tai_u64.c src/in
src/libstddjb/tai_unpack.o src/libstddjb/tai_unpack.lo: src/libstddjb/tai_unpack.c src/include/skalibs/tai.h src/include/skalibs/uint64.h
src/libstddjb/tai_unpack_little.o src/libstddjb/tai_unpack_little.lo: src/libstddjb/tai_unpack_little.c src/include/skalibs/tai.h src/include/skalibs/uint64.h
src/libstddjb/tain_add.o src/libstddjb/tain_add.lo: src/libstddjb/tain_add.c src/include/skalibs/tai.h
-src/libstddjb/tain_addsec.o src/libstddjb/tain_addsec.lo: src/libstddjb/tain_addsec.c src/include/skalibs/tai.h
+src/libstddjb/tain_addsec.o src/libstddjb/tain_addsec.lo: src/libstddjb/tain_addsec.c src/include/skalibs/tai.h src/include/skalibs/uint64.h
src/libstddjb/tain_approx.o src/libstddjb/tain_approx.lo: src/libstddjb/tain_approx.c src/include/skalibs/tai.h
src/libstddjb/tain_clockmon.o src/libstddjb/tain_clockmon.lo: src/libstddjb/tain_clockmon.c src/include/skalibs/sysdeps.h src/include/skalibs/tai.h
src/libstddjb/tain_fmt.o src/libstddjb/tain_fmt.lo: src/libstddjb/tain_fmt.c src/include/skalibs/fmtscan.h src/include/skalibs/tai.h
diff --git 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
@@ -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
@@ -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
@@ -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
@@ -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 ;