summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@gnu.org>2009-03-17 20:14:33 +0100
committerNeal H. Walfield <neal@gnu.org>2009-03-17 20:14:33 +0100
commit979756b27981ecd8983716e022b408512ababf48 (patch)
tree0fb9b51656108a9e2987636b881438821af2a3b0
parent4ce61a66a6dc7aa8126a722649f20a3ba5846fad (diff)
Change PAGES_FMT to support negative values.
-rw-r--r--viengoos/memory.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/viengoos/memory.h b/viengoos/memory.h
index a79982b..dd6af26 100644
--- a/viengoos/memory.h
+++ b/viengoos/memory.h
@@ -27,15 +27,24 @@
#define PAGES_FMT "%"PRIdPTR" %s"
#define PAGES_PRINTF(pages) \
({ \
- uint64_t p_ = (pages) * PAGESIZE; \
+ int64_t p_ = (pages) * PAGESIZE; \
+ int neg = p_ < 0; \
+ if (neg) \
+ p_ = -p_; \
+ \
if (p_ > 10 * 1024 * 1024) \
p_ /= 1024 * 1024; \
else if (p_ > 10 * 1024) \
p_ /= 1024; \
+ \
+ if (neg) \
+ p_ = -p_; \
p_; \
}), \
({ \
- uint64_t p_ = (pages) * PAGESIZE; \
+ int64_t p_ = (pages) * PAGESIZE; \
+ if (p_ < 0) \
+ p_ = -p_; \
char *s_ = "bytes"; \
if (p_ > 10 * 1024 * 1024) \
s_ = "mb"; \