aboutsummaryrefslogtreecommitdiffstats
path: root/multimespec.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2018-11-19 21:39:11 +0100
committerMattias Andrée <maandree@kth.se>2018-11-19 21:39:11 +0100
commite8a7e1c358caec60751460d337f634ff6957ff9d (patch)
treeb0fe92173edbf210d2890ecd35141cc39decf8dc /multimespec.c
parentAdd memelemscan (diff)
downloadlibsimple-e8a7e1c358caec60751460d337f634ff6957ff9d.tar.gz
libsimple-e8a7e1c358caec60751460d337f634ff6957ff9d.tar.bz2
libsimple-e8a7e1c358caec60751460d337f634ff6957ff9d.tar.xz
Add a bunch of function and macros
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'multimespec.c')
-rw-r--r--multimespec.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/multimespec.c b/multimespec.c
index c2a58c1..bc73055 100644
--- a/multimespec.c
+++ b/multimespec.c
@@ -31,13 +31,11 @@ libsimple_multimespec(struct timespec *prod, const struct timespec *multiplicand
xs = ns / 1000000000L;
ns %= 1000000000L;
- if (s > TIME_MAX / multiplier)
+ if (LIBSIMPLE_SMUL_OVERFLOW_AP_BP(s, multiplier, &s, TIME_MIN, TIME_MAX))
goto overflow;
- s *= multiplier;
- if (s > TIME_MAX - (time_t)xs)
+ if (LIBSIMPLE_SADD_OVERFLOW_NONNEG(s, (time_t)xs, &s, TIME_MIN, TIME_MAX))
goto overflow;
- s += (time_t)xs;
if (neg) {
s = -s;