X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2FRtsUtils.c;h=dc11cb46ef23bc0c2055742e0efb5bee06a59420;hb=661c97c65e5fa47177502e592bb763f752b487ac;hp=51c1250682e9e15c3bf54db74c47a13bfc36c3f0;hpb=a35d65c3465de9661325a9295715b1ef298eb888;p=ghc-hetmet.git diff --git a/rts/RtsUtils.c b/rts/RtsUtils.c index 51c1250..dc11cb4 100644 --- a/rts/RtsUtils.c +++ b/rts/RtsUtils.c @@ -138,8 +138,8 @@ static void addAllocation(void *addr, size_t len) { /* This doesn't actually help as we haven't looked at the flags * at the time that it matters (while running constructors) */ IF_DEBUG(sanity, - debugBelch("Ignoring allocation %p %zd as allocs is NULL\n", - addr, len);) + debugBelch("Ignoring allocation %p %d as allocs is NULL\n", + addr, (int)len);) } } @@ -330,25 +330,74 @@ time_str(void) -------------------------------------------------------------------------- */ char * -ullong_format_string(ullong x, char *s, rtsBool with_commas) +showStgWord64(StgWord64 x, char *s, rtsBool with_commas) { - if (x < (ullong)1000) - sprintf(s, "%lu", (lnat)x); - else if (x < (ullong)1000000) - sprintf(s, (with_commas) ? "%lu,%3.3lu" : "%lu%3.3lu", - (lnat)((x)/(ullong)1000), - (lnat)((x)%(ullong)1000)); - else if (x < (ullong)1000000000) - sprintf(s, (with_commas) ? "%lu,%3.3lu,%3.3lu" : "%lu%3.3lu%3.3lu", - (lnat)((x)/(ullong)1000000), - (lnat)((x)/(ullong)1000%(ullong)1000), - (lnat)((x)%(ullong)1000)); - else - sprintf(s, (with_commas) ? "%lu,%3.3lu,%3.3lu,%3.3lu" : "%lu%3.3lu%3.3lu%3.3lu", - (lnat)((x)/(ullong)1000000000), - (lnat)((x)/(ullong)1000000%(ullong)1000), - (lnat)((x)/(ullong)1000%(ullong)1000), - (lnat)((x)%(ullong)1000)); + if (with_commas) { + if (x < (StgWord64)1e3) + sprintf(s, "%" FMT_Word64, (StgWord64)x); + else if (x < (StgWord64)1e6) + sprintf(s, "%" FMT_Word64 ",%03" FMT_Word64, + (StgWord64)(x / 1000), + (StgWord64)(x % 1000)); + else if (x < (StgWord64)1e9) + sprintf(s, "%" FMT_Word64 + ",%03" FMT_Word64 + ",%03" FMT_Word64, + (StgWord64)(x / 1e6), + (StgWord64)((x / 1000) % 1000), + (StgWord64)(x % 1000)); + else if (x < (StgWord64)1e12) + sprintf(s, "%" FMT_Word64 + ",%03" FMT_Word64 + ",%03" FMT_Word64 + ",%03" FMT_Word64, + (StgWord64)(x / (StgWord64)1e9), + (StgWord64)((x / (StgWord64)1e6) % 1000), + (StgWord64)((x / (StgWord64)1e3) % 1000), + (StgWord64)(x % 1000)); + else if (x < (StgWord64)1e15) + sprintf(s, "%" FMT_Word64 + ",%03" FMT_Word64 + ",%03" FMT_Word64 + ",%03" FMT_Word64 + ",%03" FMT_Word64, + (StgWord64)(x / (StgWord64)1e12), + (StgWord64)((x / (StgWord64)1e9) % 1000), + (StgWord64)((x / (StgWord64)1e6) % 1000), + (StgWord64)((x / (StgWord64)1e3) % 1000), + (StgWord64)(x % 1000)); + else if (x < (StgWord64)1e18) + sprintf(s, "%" FMT_Word64 + ",%03" FMT_Word64 + ",%03" FMT_Word64 + ",%03" FMT_Word64 + ",%03" FMT_Word64 + ",%03" FMT_Word64, + (StgWord64)(x / (StgWord64)1e15), + (StgWord64)((x / (StgWord64)1e12) % 1000), + (StgWord64)((x / (StgWord64)1e9) % 1000), + (StgWord64)((x / (StgWord64)1e6) % 1000), + (StgWord64)((x / (StgWord64)1e3) % 1000), + (StgWord64)(x % 1000)); + else + sprintf(s, "%" FMT_Word64 + ",%03" FMT_Word64 + ",%03" FMT_Word64 + ",%03" FMT_Word64 + ",%03" FMT_Word64 + ",%03" FMT_Word64 + ",%03" FMT_Word64, + (StgWord64)(x / (StgWord64)1e18), + (StgWord64)((x / (StgWord64)1e15) % 1000), + (StgWord64)((x / (StgWord64)1e12) % 1000), + (StgWord64)((x / (StgWord64)1e9) % 1000), + (StgWord64)((x / (StgWord64)1e6) % 1000), + (StgWord64)((x / (StgWord64)1e3) % 1000), + (StgWord64)(x % 1000)); + } + else { + sprintf(s, "%" FMT_Word64, x); + } return s; }