From 79e46469093fc5bbbf4e358822e1e9ac9a1d1638 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Wed, 24 Nov 2010 12:48:17 +0000 Subject: Add utility function u64_range, which computes the range between two u64 values. --- util.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'util.c') diff --git a/util.c b/util.c index d292bf8..4e4c0af 100644 --- a/util.c +++ b/util.c @@ -201,3 +201,19 @@ err_close: fclose(f); return -1; } + +/* Returns end - start + 1, assuming start < end */ +u64 u64_range(u64 start, u64 end) +{ + u64 res; + + res.h = end.h - start.h; + res.l = end.l - start.l; + + if (end.l < start.l) + res.h--; + if (++res.l == 0) + res.h++; + + return res; +} -- cgit v1.2.1