diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2015-06-03 14:59:53 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2015-06-03 14:59:53 +0000 |
commit | 380b8a59dccaf828f5fc0c0961195c71479217dd (patch) | |
tree | 5300b324e64a89059386719468e024bde44c2664 | |
parent | effe4db8a69d475ae77bb7bf85bf53c009445d0e (diff) | |
download | skalibs-380b8a59dccaf828f5fc0c0961195c71479217dd.tar.gz skalibs-380b8a59dccaf828f5fc0c0961195c71479217dd.tar.xz skalibs-380b8a59dccaf828f5fc0c0961195c71479217dd.zip |
Bugfix: remove overflow checking in tai?_add/sub v2.3.5.0
(because it doesn't work with relative times, duh!)
-rw-r--r-- | package/deps.mak | 2 | ||||
-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 |
6 files changed, 18 insertions, 19 deletions
diff --git a/package/deps.mak b/package/deps.mak index 8f1d960..e81c27d 100644 --- 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 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 ; |