diff options
author | Jean Delvare <jdelvare@suse.de> | 2010-11-24 12:48:17 +0000 |
---|---|---|
committer | Jean Delvare <jdelvare@suse.de> | 2010-11-24 12:48:17 +0000 |
commit | 79e46469093fc5bbbf4e358822e1e9ac9a1d1638 (patch) | |
tree | d99e2a5fd59eabb6e1721b4125621e73884c6960 /util.c | |
parent | 84a09e7d5b4739ad93b998de18384e0755596761 (diff) | |
download | dmidecode-git-79e46469093fc5bbbf4e358822e1e9ac9a1d1638.tar.gz |
Add utility function u64_range, which computes the range between two
u64 values.
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -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; +} |