diff options
author | khali <khali> | 2010-11-24 12:48:17 +0000 |
---|---|---|
committer | khali <khali> | 2010-11-24 12:48:17 +0000 |
commit | d655f5995bc32efb72d6ba1543873067ab177004 (patch) | |
tree | d99e2a5fd59eabb6e1721b4125621e73884c6960 | |
parent | 9df32bcc4fa6fee3cba82115814f8cabe176ccd9 (diff) | |
download | dmidecode-d655f5995bc32efb72d6ba1543873067ab177004.tar.gz |
Add utility function u64_range, which computes the range between two
u64 values.
-rw-r--r-- | util.c | 16 | ||||
-rw-r--r-- | util.h | 1 |
2 files changed, 17 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; +} @@ -27,3 +27,4 @@ int checksum(const u8 *buf, size_t len); void *mem_chunk(size_t base, size_t len, const char *devmem); int write_dump(size_t base, size_t len, const void *data, const char *dumpfile, int add); +u64 u64_range(u64 start, u64 end); |