summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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"; \