From 3a52d8e639e1b1b5f7e4716796c821104366d08f Mon Sep 17 00:00:00 2001 From: Richard Brooksby Date: Tue, 27 Mar 2012 16:30:33 +0100 Subject: Fixing bt to use count for bit table length (and size for sizes throughout), rather than unsigned long. Copied from Perforce Change: 177813 ServerID: perforce.ravenbrook.com --- mps/code/bt.c | 16 ++++++++-------- mps/code/bt.h | 10 +++++----- 2 files changed, 13 insertions(+), 13 deletions(-) (limited to 'mps/code') diff --git a/mps/code/bt.c b/mps/code/bt.c index 3586b5ebcd2..176b18d99f0 100644 --- a/mps/code/bt.c +++ b/mps/code/bt.c @@ -228,7 +228,7 @@ static Bool BTCheck(BT bt) * See */ -size_t (BTSize)(unsigned long n) +Size (BTSize)(Count n) { /* check that the expression used in rounding up doesn't overflow */ AVER(n+MPS_WORD_WIDTH-1 > n); @@ -617,7 +617,7 @@ btFindResHighLabel:; \ static Bool BTFindResRange(Index *baseReturn, Index *limitReturn, BT bt, Index searchBase, Index searchLimit, - unsigned long minLength, unsigned long maxLength) + Count minLength, Count maxLength) { Bool foundRes; /* true if a reset bit is found */ Index resBase; /* base of a candidate reset range */ @@ -704,8 +704,8 @@ static Bool BTFindResRange(Index *baseReturn, Index *limitReturn, static Bool BTFindResRangeHigh(Index *baseReturn, Index *limitReturn, BT bt, Index searchBase, Index searchLimit, - unsigned long minLength, - unsigned long maxLength) + Count minLength, + Count maxLength) { Bool foundRes; /* true if a reset bit is found */ Index resLimit; /* limit of a candidate reset range */ @@ -797,7 +797,7 @@ static Bool BTFindResRangeHigh(Index *baseReturn, Index *limitReturn, Bool BTFindLongResRange(Index *baseReturn, Index *limitReturn, BT bt, Index searchBase, Index searchLimit, - unsigned long length) + Count length) { /* All parameters are checked by BTFindResRange. */ return BTFindResRange(baseReturn, limitReturn, @@ -815,7 +815,7 @@ Bool BTFindLongResRange(Index *baseReturn, Index *limitReturn, Bool BTFindLongResRangeHigh(Index *baseReturn, Index *limitReturn, BT bt, Index searchBase, Index searchLimit, - unsigned long length) + Count length) { /* All parameters are checked by BTFindResRangeHigh. */ return BTFindResRangeHigh(baseReturn, limitReturn, @@ -833,7 +833,7 @@ Bool BTFindLongResRangeHigh(Index *baseReturn, Index *limitReturn, Bool BTFindShortResRange(Index *baseReturn, Index *limitReturn, BT bt, Index searchBase, Index searchLimit, - unsigned long length) + Count length) { /* All parameters are checked by BTFindResRange. */ return BTFindResRange(baseReturn, limitReturn, @@ -852,7 +852,7 @@ Bool BTFindShortResRange(Index *baseReturn, Index *limitReturn, Bool BTFindShortResRangeHigh(Index *baseReturn, Index *limitReturn, BT bt, Index searchBase, Index searchLimit, - unsigned long length) + Count length) { /* All parameters are checked by BTFindResRangeHigh. */ return BTFindResRangeHigh(baseReturn, limitReturn, diff --git a/mps/code/bt.h b/mps/code/bt.h index 7f318f8ee85..29000b957b8 100644 --- a/mps/code/bt.h +++ b/mps/code/bt.h @@ -13,7 +13,7 @@ /* */ -extern size_t (BTSize)(unsigned long length); +extern Size (BTSize)(Count length); #define BTSize(n) (((n) + MPS_WORD_WIDTH-1) / MPS_WORD_WIDTH * sizeof(Word)) /* */ @@ -49,16 +49,16 @@ extern Bool BTIsResRange(BT bt, Index base, Index limit); extern Bool BTFindShortResRange(Index *baseReturn, Index *limitReturn, BT bt, Index searchBase, Index searchLimit, - unsigned long length); + Count length); extern Bool BTFindShortResRangeHigh(Index *baseReturn, Index *limitReturn, BT bt, Index searchBase, Index searchLimit, - unsigned long length); + Count length); extern Bool BTFindLongResRange(Index *baseReturn, Index *limitReturn, BT bt, Index searchBase, Index searchLimit, - unsigned long length); + Count length); extern Bool BTFindLongResRangeHigh(Index *baseReturn, Index *limitReturn, BT bt, Index searchBase, Index searchLimit, - unsigned long length); + Count length); extern Bool BTRangesSame(BT BTx, BT BTy, Index base, Index limit); -- cgit v1.2.1 From 5225a4be56d297778ab900f3e678b7374135ab88 Mon Sep 17 00:00:00 2001 From: Richard Brooksby Date: Tue, 27 Mar 2012 16:55:31 +0100 Subject: Introducing ulongest type. see design/types/#ulongest. Fixing WriteF to take ULongest rather than unsigned long, and fixing intrnal assumption that Word was as big as unsigned long. Copied from Perforce Change: 177814 ServerID: perforce.ravenbrook.com --- mps/code/mpm.c | 30 +++++++++++++++--------------- mps/code/mpmtypes.h | 5 +++-- mps/code/mpstd.h | 20 ++++++++++++++++++++ 3 files changed, 38 insertions(+), 17 deletions(-) (limited to 'mps/code') diff --git a/mps/code/mpm.c b/mps/code/mpm.c index a0d66350e7b..8af2ffff7ee 100644 --- a/mps/code/mpm.c +++ b/mps/code/mpm.c @@ -218,13 +218,13 @@ Bool ResIsAllocFailure(Res res) } -/* WriteWord -- output a textual representation of a word to a stream +/* WriteULongest -- output a textual representation of an integer to a stream * * Output as an unsigned value in the given base (2-16), padded to the * given width. */ -static Res WriteWord(mps_lib_FILE *stream, Word w, unsigned base, - unsigned width) +static Res WriteULongest(mps_lib_FILE *stream, ULongest w, unsigned base, + unsigned width) { static const char digit[16 + 1] = "0123456789ABCDEF"; /* + 1 for terminator: unused, but prevents compiler warning */ @@ -412,7 +412,7 @@ static Res WriteDouble(mps_lib_FILE *stream, double d) * .writef.des: See , also * * .writef.p: There is an assumption that void * fits in Word in - * the case of $P, and unsigned long for $U and $B. This is checked in + * the case of $P, and ULongest for $U and $B. This is checked in * MPMCheck. * * .writef.div: Although MPS_WORD_WIDTH/4 appears three times, there @@ -469,15 +469,15 @@ Res WriteF_firstformat_v(mps_lib_FILE *stream, switch(*format) { case 'A': { /* address */ WriteFA addr = va_arg(args, WriteFA); - res = WriteWord(stream, (Word)addr, 16, - (sizeof(WriteFA) * CHAR_BIT + 3) / 4); + res = WriteULongest(stream, (ULongest)addr, 16, + (sizeof(WriteFA) * CHAR_BIT + 3) / 4); if (res != ResOK) return res; } break; case 'P': { /* pointer, see .writef.p */ WriteFP p = va_arg(args, WriteFP); - res = WriteWord(stream, (Word)p, 16, - (sizeof(WriteFP) * CHAR_BIT + 3)/ 4); + res = WriteULongest(stream, (ULongest)p, 16, + (sizeof(WriteFP) * CHAR_BIT + 3)/ 4); if (res != ResOK) return res; } break; @@ -486,8 +486,8 @@ Res WriteF_firstformat_v(mps_lib_FILE *stream, WriteFF *fp = &f; /* dodge to placate splint */ Byte *b = *((Byte **)&fp); for(i=0; i < sizeof(WriteFF); i++) { - res = WriteWord(stream, (Word)(b[i]), 16, - (CHAR_BIT + 3) / 4); + res = WriteULongest(stream, (ULongest)(b[i]), 16, + (CHAR_BIT + 3) / 4); if (res != ResOK) return res; } } break; @@ -506,26 +506,26 @@ Res WriteF_firstformat_v(mps_lib_FILE *stream, case 'W': { /* word */ WriteFW w = va_arg(args, WriteFW); - res = WriteWord(stream, (Word)w, 16, - (sizeof(WriteFW) * CHAR_BIT + 3) / 4); + res = WriteULongest(stream, (ULongest)w, 16, + (sizeof(WriteFW) * CHAR_BIT + 3) / 4); if (res != ResOK) return res; } break; case 'U': { /* decimal, see .writef.p */ WriteFU u = va_arg(args, WriteFU); - res = WriteWord(stream, (Word)u, 10, 0); + res = WriteULongest(stream, (ULongest)u, 10, 0); if (res != ResOK) return res; } break; case '3': { /* decimal for thousandths */ WriteFU u = va_arg(args, WriteFU); - res = WriteWord(stream, (Word)u, 10, 3); + res = WriteULongest(stream, (ULongest)u, 10, 3); if (res != ResOK) return res; } break; case 'B': { /* binary, see .writef.p */ WriteFB b = va_arg(args, WriteFB); - res = WriteWord(stream, (Word)b, 2, sizeof(WriteFB) * CHAR_BIT); + res = WriteULongest(stream, (ULongest)b, 2, sizeof(WriteFB) * CHAR_BIT); if (res != ResOK) return res; } break; diff --git a/mps/code/mpmtypes.h b/mps/code/mpmtypes.h index 056ac0d2ec9..b424cb6d341 100644 --- a/mps/code/mpmtypes.h +++ b/mps/code/mpmtypes.h @@ -41,6 +41,7 @@ typedef unsigned Serial; /* */ typedef Addr Ref; /* */ typedef void *Pointer; /* */ typedef unsigned long Clock; /* processor time */ +typedef MPS_T_ULONGEST ULongest; /* */ typedef Word RefSet; /* design.mps.refset */ typedef Word ZoneSet; /* design.mps.refset */ @@ -441,8 +442,8 @@ typedef Addr WriteFA; typedef Pointer WriteFP; typedef const char *WriteFS; typedef Word WriteFW; -typedef unsigned long WriteFU; -typedef unsigned long WriteFB; +typedef ULongest WriteFU; +typedef ULongest WriteFB; typedef void *(*WriteFF)(void); typedef int WriteFC; /* Promoted */ typedef double WriteFD; diff --git a/mps/code/mpstd.h b/mps/code/mpstd.h index c7360ed942c..fd637864286 100644 --- a/mps/code/mpstd.h +++ b/mps/code/mpstd.h @@ -74,6 +74,7 @@ #define MPS_ARCH_M2 #define MPS_BUILD_CC #define MPS_T_WORD unsigned long +#define MPS_T_ULONGEST unsigned long #define MPS_WORD_WIDTH 32 #define MPS_WORD_SHIFT 5 #define MPS_PF_ALIGN 8 @@ -91,6 +92,7 @@ #define MPS_ARCH_M4 #define MPS_BUILD_CC #define MPS_T_WORD unsigned long +#define MPS_T_ULONGEST unsigned long #define MPS_WORD_WIDTH 32 #define MPS_WORD_SHIFT 5 #define MPS_PF_ALIGN 8 @@ -107,6 +109,7 @@ #define MPS_ARCH_AL #define MPS_BUILD_MV #define MPS_T_WORD unsigned long +#define MPS_T_ULONGEST unsigned long #define MPS_WORD_WIDTH 32 #define MPS_WORD_SHIFT 5 #define MPS_PF_ALIGN 4 @@ -123,6 +126,7 @@ #define MPS_ARCH_PP #define MPS_BUILD_MV #define MPS_T_WORD unsigned long +#define MPS_T_ULONGEST unsigned long #define MPS_WORD_WIDTH 32 #define MPS_WORD_SHIFT 5 #define MPS_PF_ALIGN 4 @@ -145,6 +149,7 @@ #define MPS_ARCH_I3 #define MPS_BUILD_MV #define MPS_T_WORD unsigned long +#define MPS_T_ULONGEST unsigned long #define MPS_WORD_WIDTH 32 #define MPS_WORD_SHIFT 5 #define MPS_PF_ALIGN 8 @@ -163,6 +168,7 @@ #define MPS_ARCH_60 #define MPS_BUILD_MW #define MPS_T_WORD unsigned long +#define MPS_T_ULONGEST unsigned long #define MPS_WORD_WIDTH 32 #define MPS_WORD_SHIFT 5 #define MPS_PF_ALIGN 1 @@ -181,6 +187,7 @@ #define MPS_ARCH_PP #define MPS_BUILD_MW #define MPS_T_WORD unsigned long +#define MPS_T_ULONGEST unsigned long #define MPS_WORD_WIDTH 32 #define MPS_WORD_SHIFT 5 #define MPS_PF_ALIGN 8 /* .macos.ppc.align */ @@ -201,6 +208,7 @@ #define MPS_ARCH_60 #define MPS_BUILD_AC #define MPS_T_WORD unsigned long +#define MPS_T_ULONGEST unsigned long #define MPS_WORD_WIDTH 32 #define MPS_WORD_SHIFT 5 #define MPS_PF_ALIGN 1 @@ -221,6 +229,7 @@ #define MPS_ARCH_PP #define MPS_BUILD_AC #define MPS_T_WORD unsigned long +#define MPS_T_ULONGEST unsigned long #define MPS_WORD_WIDTH 32 #define MPS_WORD_SHIFT 5 #define MPS_PF_ALIGN 8 /* .macos.ppc.align */ @@ -241,6 +250,7 @@ #define MPS_ARCH_PP #define MPS_BUILD_GC #define MPS_T_WORD unsigned long +#define MPS_T_ULONGEST unsigned long #define MPS_WORD_WIDTH 32 #define MPS_WORD_SHIFT 5 #define MPS_PF_ALIGN 8 /* .macos.ppc.align */ @@ -261,6 +271,7 @@ #define MPS_ARCH_I3 #define MPS_BUILD_GC #define MPS_T_WORD unsigned long +#define MPS_T_ULONGEST unsigned long #define MPS_WORD_WIDTH 32 #define MPS_WORD_SHIFT 5 #define MPS_PF_ALIGN 4 /* I'm just guessing. */ @@ -278,6 +289,7 @@ #define MPS_ARCH_S8 #define MPS_BUILD_GC #define MPS_T_WORD unsigned long +#define MPS_T_ULONGEST unsigned long #define MPS_WORD_WIDTH 32 #define MPS_WORD_SHIFT 5 #define MPS_PF_ALIGN 8 @@ -295,6 +307,7 @@ #define MPS_ARCH_S8 #define MPS_BUILD_LC #define MPS_T_WORD unsigned long +#define MPS_T_ULONGEST unsigned long #define MPS_WORD_WIDTH 32 #define MPS_WORD_SHIFT 5 #define MPS_PF_ALIGN 8 @@ -312,6 +325,7 @@ #define MPS_ARCH_S8 #define MPS_BUILD_GC #define MPS_T_WORD unsigned long +#define MPS_T_ULONGEST unsigned long #define MPS_WORD_WIDTH 32 #define MPS_WORD_SHIFT 5 #define MPS_PF_ALIGN 8 @@ -332,6 +346,7 @@ #define MPS_ARCH_S9 #define MPS_BUILD_SC #define MPS_T_WORD unsigned long +#define MPS_T_ULONGEST unsigned long #define MPS_WORD_WIDTH 32 #define MPS_WORD_SHIFT 5 #define MPS_PF_ALIGN 8 @@ -348,6 +363,7 @@ #define MPS_ARCH_AL #define MPS_BUILD_GC #define MPS_T_WORD unsigned long +#define MPS_T_ULONGEST unsigned long #define MPS_WORD_WIDTH 64 #define MPS_WORD_SHIFT 6 #define MPS_PF_ALIGN 8 @@ -364,6 +380,7 @@ #define MPS_ARCH_AL #define MPS_BUILD_CC #define MPS_T_WORD unsigned long +#define MPS_T_ULONGEST unsigned long #define MPS_WORD_WIDTH 64 #define MPS_WORD_SHIFT 6 #define MPS_PF_ALIGN 8 @@ -383,6 +400,7 @@ #define MPS_ARCH_I4 #define MPS_BUILD_GC #define MPS_T_WORD unsigned long +#define MPS_T_ULONGEST unsigned long #define MPS_WORD_WIDTH 32 #define MPS_WORD_SHIFT 5 #define MPS_PF_ALIGN 4 @@ -399,6 +417,7 @@ #define MPS_ARCH_PP #define MPS_BUILD_GC #define MPS_T_WORD unsigned long +#define MPS_T_ULONGEST unsigned long #define MPS_WORD_WIDTH 32 #define MPS_WORD_SHIFT 5 #define MPS_PF_ALIGN 8 /* @@@@ not tested */ @@ -416,6 +435,7 @@ #define MPS_ARCH_I4 #define MPS_BUILD_GC #define MPS_T_WORD unsigned long +#define MPS_T_ULONGEST unsigned long #define MPS_WORD_WIDTH 32 #define MPS_WORD_SHIFT 5 #define MPS_PF_ALIGN 4 -- cgit v1.2.1 From 382d044e970ec1beae9593d6a3ae22156e53a8a4 Mon Sep 17 00:00:00 2001 From: Richard Brooksby Date: Tue, 27 Mar 2012 17:15:25 +0100 Subject: Cbs and splay now pass size through as closure parameters, rather than messing with unsigned long. Copied from Perforce Change: 177816 ServerID: perforce.ravenbrook.com --- mps/code/cbs.c | 18 +++++++----------- mps/code/splay.c | 4 ++-- mps/code/splay.h | 8 ++++---- 3 files changed, 13 insertions(+), 17 deletions(-) (limited to 'mps/code') diff --git a/mps/code/cbs.c b/mps/code/cbs.c index 73474a02de9..6eff37a844e 100644 --- a/mps/code/cbs.c +++ b/mps/code/cbs.c @@ -194,36 +194,32 @@ static Compare cbsSplayCompare(void *key, SplayNode node) /* cbsTestNode, cbsTestTree -- test for nodes larger than the S parameter */ static Bool cbsTestNode(SplayTree tree, SplayNode node, - void *closureP, unsigned long closureS) + void *closureP, Size size) { - Size size; CBSBlock block; AVERT(SplayTree, tree); AVERT(SplayNode, node); AVER(closureP == NULL); - AVER(closureS > 0); + AVER(size > 0); AVER(cbsOfSplayTree(tree)->fastFind); - size = (Size)closureS; block = cbsBlockOfSplayNode(node); return CBSBlockSize(block) >= size; } static Bool cbsTestTree(SplayTree tree, SplayNode node, - void *closureP, unsigned long closureS) + void *closureP, Size size) { - Size size; CBSBlock block; AVERT(SplayTree, tree); AVERT(SplayNode, node); AVER(closureP == NULL); - AVER(closureS > 0); + AVER(size > 0); AVER(cbsOfSplayTree(tree)->fastFind); - size = (Size)closureS; block = cbsBlockOfSplayNode(node); return block->maxSize >= size; @@ -1396,7 +1392,7 @@ Bool CBSFindFirst(Addr *baseReturn, Addr *limitReturn, METER_ACC(cbs->splaySearch, cbs->splayTreeSize); found = SplayFindFirst(&node, splayTreeOfCBS(cbs), &cbsTestNode, - &cbsTestTree, NULL, (unsigned long)size); + &cbsTestTree, NULL, size); if (found) { CBSBlock block; @@ -1479,7 +1475,7 @@ Bool CBSFindLast(Addr *baseReturn, Addr *limitReturn, METER_ACC(cbs->splaySearch, cbs->splayTreeSize); found = SplayFindLast(&node, splayTreeOfCBS(cbs), &cbsTestNode, - &cbsTestTree, NULL, (unsigned long)size); + &cbsTestTree, NULL, size); if (found) { CBSBlock block; @@ -1573,7 +1569,7 @@ Bool CBSFindLargest(Addr *baseReturn, Addr *limitReturn, size = cbsBlockOfSplayNode(root)->maxSize; METER_ACC(cbs->splaySearch, cbs->splayTreeSize); found = SplayFindFirst(&node, splayTreeOfCBS(cbs), &cbsTestNode, - &cbsTestTree, NULL, (unsigned long)size); + &cbsTestTree, NULL, size); AVER(found); /* maxSize is exact, so we will find it. */ block = cbsBlockOfSplayNode(node); AVER(CBSBlockSize(block) >= size); diff --git a/mps/code/splay.c b/mps/code/splay.c index 7979af342c4..4668a23e48a 100644 --- a/mps/code/splay.c +++ b/mps/code/splay.c @@ -883,7 +883,7 @@ static Compare SplayFindLastCompare(void *key, SplayNode node) Bool SplayFindFirst(SplayNode *nodeReturn, SplayTree tree, SplayTestNodeMethod testNode, SplayTestTreeMethod testTree, - void *closureP, unsigned long closureS) + void *closureP, Size closureS) { SplayNode node; SplayFindClosureStruct closureStruct; @@ -919,7 +919,7 @@ Bool SplayFindFirst(SplayNode *nodeReturn, SplayTree tree, Bool SplayFindLast(SplayNode *nodeReturn, SplayTree tree, SplayTestNodeMethod testNode, SplayTestTreeMethod testTree, - void *closureP, unsigned long closureS) + void *closureP, Size closureS) { SplayNode node; SplayFindClosureStruct closureStruct; diff --git a/mps/code/splay.h b/mps/code/splay.h index bdb4d888f87..8fa31af7fd3 100644 --- a/mps/code/splay.h +++ b/mps/code/splay.h @@ -17,9 +17,9 @@ typedef struct SplayNodeStruct *SplayNode; typedef unsigned Compare; typedef Compare (*SplayCompareMethod)(void *key, SplayNode node); typedef Bool (*SplayTestNodeMethod)(SplayTree tree, SplayNode node, - void *closureP, unsigned long closureS); + void *closureP, Size closureS); typedef Bool (*SplayTestTreeMethod)(SplayTree tree, SplayNode node, - void *closureP, unsigned long closureS); + void *closureP, Size closureS); typedef void (*SplayUpdateNodeMethod)(SplayTree tree, SplayNode node, SplayNode leftChild, SplayNode rightChild); @@ -67,11 +67,11 @@ extern SplayNode SplayTreeNext(SplayTree tree, SplayNode oldNode, extern Bool SplayFindFirst(SplayNode *nodeReturn, SplayTree tree, SplayTestNodeMethod testNode, SplayTestTreeMethod testTree, - void *closureP, unsigned long closureS); + void *closureP, Size closureS); extern Bool SplayFindLast(SplayNode *nodeReturn, SplayTree tree, SplayTestNodeMethod testNode, SplayTestTreeMethod testTree, - void *closureP, unsigned long closureS); + void *closureP, Size closureS); extern void SplayNodeRefresh(SplayTree tree, SplayNode node, void *key); -- cgit v1.2.1 From ecb147b98f04d2bf193da1a874ea2f2392bf0e66 Mon Sep 17 00:00:00 2001 From: Richard Brooksby Date: Tue, 27 Mar 2012 18:12:52 +0100 Subject: Consistently passing closure sizes as size_t and not casting back and forth to size or anything else. Copied from Perforce Change: 177817 ServerID: perforce.ravenbrook.com --- mps/code/mpm.h | 4 ++-- mps/code/mpmtypes.h | 2 +- mps/code/pool.c | 2 +- mps/code/poolabs.c | 2 +- mps/code/walk.c | 6 +++--- 5 files changed, 8 insertions(+), 8 deletions(-) (limited to 'mps/code') diff --git a/mps/code/mpm.h b/mps/code/mpm.h index 371319aeee6..62dac8a381b 100644 --- a/mps/code/mpm.h +++ b/mps/code/mpm.h @@ -213,7 +213,7 @@ extern void PoolFixEmergency(Pool pool, ScanState ss, Seg seg, Addr *refIO); extern void PoolReclaim(Pool pool, Trace trace, Seg seg); extern void PoolTraceEnd(Pool pool, Trace trace); extern void PoolWalk(Pool pool, Seg seg, FormattedObjectsStepMethod f, - void *v, unsigned long s); + void *v, size_t s); extern void PoolFreeWalk(Pool pool, FreeBlockStepMethod f, void *p); extern Res PoolTrivInit(Pool pool, va_list arg); extern void PoolTrivFinish(Pool pool); @@ -262,7 +262,7 @@ extern Res PoolNoFramePop(Pool pool, Buffer buf, AllocFrame frame); extern Res PoolTrivFramePop(Pool pool, Buffer buf, AllocFrame frame); extern void PoolNoFramePopPending(Pool pool, Buffer buf, AllocFrame frame); extern void PoolNoWalk(Pool pool, Seg seg, FormattedObjectsStepMethod step, - void *p, unsigned long s); + void *p, size_t s); extern void PoolNoFreeWalk(Pool pool, FreeBlockStepMethod f, void *p); extern PoolDebugMixin PoolNoDebugMixin(Pool pool); extern BufferClass PoolNoBufferClass(void); diff --git a/mps/code/mpmtypes.h b/mps/code/mpmtypes.h index b424cb6d341..d1aaa1e4cf2 100644 --- a/mps/code/mpmtypes.h +++ b/mps/code/mpmtypes.h @@ -211,7 +211,7 @@ typedef void (*PoolFramePopPendingMethod)(Pool pool, Buffer buf, AllocFrame frame); typedef void (*PoolWalkMethod)(Pool pool, Seg seg, FormattedObjectsStepMethod f, - void *v, unsigned long s); + void *v, size_t s); typedef void (*PoolFreeWalkMethod)(Pool pool, FreeBlockStepMethod f, void *p); typedef BufferClass (*PoolBufferClassMethod)(void); typedef Res (*PoolDescribeMethod)(Pool pool, mps_lib_FILE *stream); diff --git a/mps/code/pool.c b/mps/code/pool.c index 509c5a52552..e2578cf3497 100644 --- a/mps/code/pool.c +++ b/mps/code/pool.c @@ -482,7 +482,7 @@ void PoolTraceEnd(Pool pool, Trace trace) /* PoolWalk -- walk objects in this segment */ void PoolWalk(Pool pool, Seg seg, FormattedObjectsStepMethod f, - void *p, Size s) + void *p, size_t s) { AVERT(Pool, pool); AVERT(Seg, seg); diff --git a/mps/code/poolabs.c b/mps/code/poolabs.c index 324975cb7c0..80b7f5323be 100644 --- a/mps/code/poolabs.c +++ b/mps/code/poolabs.c @@ -621,7 +621,7 @@ Res PoolTrivFramePop(Pool pool, Buffer buf, AllocFrame frame) void PoolNoWalk(Pool pool, Seg seg, - FormattedObjectsStepMethod f, void *p, Size s) + FormattedObjectsStepMethod f, void *p, size_t s) { AVERT(Pool, pool); AVERT(Seg, seg); diff --git a/mps/code/walk.c b/mps/code/walk.c index 6ea698de217..bb81a7aa152 100644 --- a/mps/code/walk.c +++ b/mps/code/walk.c @@ -36,7 +36,7 @@ static Bool FormattedObjectsStepClosureCheck(FormattedObjectsStepClosure c) static void ArenaFormattedObjectsStep(Addr object, Format format, Pool pool, - void *p, Size s) + void *p, size_t s) { FormattedObjectsStepClosure c; /* Can't check object */ @@ -56,7 +56,7 @@ static void ArenaFormattedObjectsStep(Addr object, Format format, Pool pool, * So called because it walks all formatted objects in an arena. */ static void ArenaFormattedObjectsWalk(Arena arena, FormattedObjectsStepMethod f, - void *p, Size s) + void *p, size_t s) { Seg seg; FormattedObjectsStepClosure c; @@ -186,7 +186,7 @@ static Bool rootsStepClosureCheck(rootsStepClosure rsc) static void rootsStepClosureInit(rootsStepClosure rsc, Globals arena, Trace trace, TraceFixMethod rootFix, - mps_roots_stepper_t f, void *p, Size s) + mps_roots_stepper_t f, void *p, size_t s) { ScanState ss; -- cgit v1.2.1 From ac6b3c9aeba79216a67eb6e1f8fc7c681c908b79 Mon Sep 17 00:00:00 2001 From: Richard Brooksby Date: Thu, 29 Mar 2012 14:52:45 +0100 Subject: Adding indirection between mps_word_t and unsigned long that will get more elaborate when we merge the w3i6mv port. Copied from Perforce Change: 177848 ServerID: perforce.ravenbrook.com --- mps/code/mps.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'mps/code') diff --git a/mps/code/mps.h b/mps/code/mps.h index 59884accae6..af718b7ce5d 100644 --- a/mps/code/mps.h +++ b/mps/code/mps.h @@ -16,6 +16,11 @@ #include +/* Platform Dependencies */ + +#define MPS_T_WORD unsigned long /* won't be true on W3I6MV */ + + /* Abstract Types */ typedef struct mps_arena_s *mps_arena_t; /* arena */ @@ -39,7 +44,7 @@ typedef struct mps_frame_s /* Concrete Types */ -typedef unsigned long mps_word_t; /* pointer-sized word */ +typedef MPS_T_WORD mps_word_t; /* pointer-sized word */ typedef int mps_bool_t; /* boolean (int) */ typedef int mps_res_t; /* result code (int) */ typedef unsigned mps_shift_t; /* shift amount (unsigned int) */ -- cgit v1.2.1 From 61890da12b3d0150f25b6edd783f320d957b223f Mon Sep 17 00:00:00 2001 From: Richard Brooksby Date: Mon, 23 Apr 2012 16:20:40 +0100 Subject: Fixing up occurences of "unsigned long" in the main mps and test code so that we no longer assume that "unsigned long" is large enough for a pointer or size, or that it's the longest available integer type, since these are not true on 64-bit windows. Copied from Perforce Change: 178021 ServerID: perforce.ravenbrook.com --- mps/code/amcss.c | 10 +++++----- mps/code/amcsshe.c | 6 +++--- mps/code/amcssth.c | 6 +++--- mps/code/amsss.c | 10 +++++----- mps/code/amssshe.c | 4 ++-- mps/code/btcv.c | 29 +++++++++++++++-------------- mps/code/bttest.c | 9 ++++++--- mps/code/cbs.c | 3 --- mps/code/cbstest.c | 2 +- mps/code/dumper.c | 19 +++++++++++++++---- mps/code/eventrep.c | 13 ++++++++++++- mps/code/exposet0.c | 6 +++--- mps/code/locbwcss.c | 4 ++-- mps/code/locusss.c | 4 ++-- mps/code/mpmtypes.h | 2 +- mps/code/mv2test.c | 6 ++++-- mps/code/poolamc.c | 6 +++--- mps/code/poolawl.c | 2 +- mps/code/poollo.c | 16 ++++++++-------- mps/code/poolsnc.c | 2 +- mps/code/qs.c | 4 ++-- mps/code/replay.c | 13 ++++++++++++- mps/code/segsmss.c | 16 ++++++++-------- mps/code/splay.c | 6 +++--- mps/code/steptest.c | 12 ++++++------ mps/code/testlib.h | 24 ++++++++++++++++++++++++ mps/code/zcoll.c | 26 +++++++++++++++----------- 27 files changed, 162 insertions(+), 98 deletions(-) (limited to 'mps/code') diff --git a/mps/code/amcss.c b/mps/code/amcss.c index 0590f81c0c7..7055bf94b70 100644 --- a/mps/code/amcss.c +++ b/mps/code/amcss.c @@ -86,7 +86,7 @@ static void report(mps_arena_t arena) nCollsStart += 1; printf("\n{\n Collection %d started. Because:\n", nCollsStart); printf(" %s\n", mps_message_gc_start_why(arena, message)); - printf(" clock: %lu\n", (unsigned long)mps_message_clock(arena, message)); + printf(" clock: %"PRIuLONGEST"\n", (ulongest_t)mps_message_clock(arena, message)); break; } case mps_message_type_gc(): { @@ -98,10 +98,10 @@ static void report(mps_arena_t arena) not_condemned = mps_message_gc_not_condemned_size(arena, message); printf("\n Collection %d finished:\n", nCollsDone); - printf(" live %lu\n", (unsigned long)live); - printf(" condemned %lu\n", (unsigned long)condemned); - printf(" not_condemned %lu\n", (unsigned long)not_condemned); - printf(" clock: %lu\n", (unsigned long)mps_message_clock(arena, message)); + printf(" live %"PRIuLONGEST"\n", (ulongest_t)live); + printf(" condemned %"PRIuLONGEST"\n", (ulongest_t)condemned); + printf(" not_condemned %"PRIuLONGEST"\n", (ulongest_t)not_condemned); + printf(" clock: %"PRIuLONGEST"\n", (ulongest_t)mps_message_clock(arena, message)); printf("}\n"); if(condemned > (gen1SIZE + gen2SIZE + (size_t)128) * 1024) { diff --git a/mps/code/amcsshe.c b/mps/code/amcsshe.c index 90013f32671..edc76a16deb 100644 --- a/mps/code/amcsshe.c +++ b/mps/code/amcsshe.c @@ -88,9 +88,9 @@ static void report(mps_arena_t arena) not_condemned = mps_message_gc_not_condemned_size(arena, message); printf("\nCollection %d finished:\n", ++nCollections); - printf("live %lu\n", (unsigned long)live); - printf("condemned %lu\n", (unsigned long)condemned); - printf("not_condemned %lu\n", (unsigned long)not_condemned); + printf("live %"PRIuLONGEST"\n", (ulongest_t)live); + printf("condemned %"PRIuLONGEST"\n", (ulongest_t)condemned); + printf("not_condemned %"PRIuLONGEST"\n", (ulongest_t)not_condemned); mps_message_discard(arena, message); diff --git a/mps/code/amcssth.c b/mps/code/amcssth.c index 76ef6800c58..e71849d72fa 100644 --- a/mps/code/amcssth.c +++ b/mps/code/amcssth.c @@ -67,9 +67,9 @@ static void report(mps_arena_t arena) not_condemned = mps_message_gc_not_condemned_size(arena, message); printf("\nCollection %d finished:\n", ++nCollections); - printf("live %lu\n", (unsigned long)live); - printf("condemned %lu\n", (unsigned long)condemned); - printf("not_condemned %lu\n", (unsigned long)not_condemned); + printf("live %"PRIuLONGEST"\n", (ulongest_t)live); + printf("condemned %"PRIuLONGEST"\n", (ulongest_t)condemned); + printf("not_condemned %"PRIuLONGEST"\n", (ulongest_t)not_condemned); mps_message_discard(arena, message); diff --git a/mps/code/amsss.c b/mps/code/amsss.c index 16b5fef3c91..efe8c173731 100644 --- a/mps/code/amsss.c +++ b/mps/code/amsss.c @@ -73,9 +73,9 @@ static void report(void) not_condemned = mps_message_gc_not_condemned_size(arena, message); printf("\nCollection complete %d:\n", ++nComplete); - printf("live %lu\n", (unsigned long)live); - printf("condemned %lu\n", (unsigned long)condemned); - printf("not_condemned %lu\n", (unsigned long)not_condemned); + printf("live %"PRIuLONGEST"\n", (ulongest_t)live); + printf("condemned %"PRIuLONGEST"\n", (ulongest_t)condemned); + printf("not_condemned %"PRIuLONGEST"\n", (ulongest_t)not_condemned); } break; default: @@ -153,8 +153,8 @@ static void *test(void *arg, size_t haveAmbigous) while(totalSize < totalSizeMAX) { if (totalSize > lastStep + totalSizeSTEP) { lastStep = totalSize; - printf("\nSize %lu bytes, %lu objects.\n", - (unsigned long)totalSize, objs); + printf("\nSize %"PRIuLONGEST" bytes, %lu objects.\n", + (ulongest_t)totalSize, objs); fflush(stdout); for(i = 0; i < exactRootsCOUNT; ++i) cdie(exactRoots[i] == objNULL || dylan_check(exactRoots[i]), diff --git a/mps/code/amssshe.c b/mps/code/amssshe.c index 256246e0696..a042a06d3ed 100644 --- a/mps/code/amssshe.c +++ b/mps/code/amssshe.c @@ -108,8 +108,8 @@ static void *test(void *arg, size_t s) while(totalSize < totalSizeMAX) { if(totalSize > lastStep + totalSizeSTEP) { lastStep = totalSize; - printf("\nSize %lu bytes, %lu objects.\n", - (unsigned long)totalSize, objs); + printf("\nSize %"PRIuLONGEST" bytes, %lu objects.\n", + (ulongest_t)totalSize, objs); fflush(stdout); for(i = 0; i < exactRootsCOUNT; ++i) cdie(exactRoots[i] == objNULL || dylan_check(exactRoots[i]), diff --git a/mps/code/btcv.c b/mps/code/btcv.c index efd9d14425b..fd411ee461b 100644 --- a/mps/code/btcv.c +++ b/mps/code/btcv.c @@ -61,7 +61,8 @@ static void btResRangeSymmetric(BT btlo, BT bthi, Count btSize, } -typedef Bool (*BTFinderFn)(Index *, Index *, BT, Index, Index, unsigned long); +typedef Bool (*BTFinderFn)(Index *foundBase_o, Index *foundLimit_o, + BT bt, Index base, Index limit, Count length); /* btTestSingleRange -- Test expectations for calls to BTFind*ResRange* @@ -70,7 +71,7 @@ typedef Bool (*BTFinderFn)(Index *, Index *, BT, Index, Index, unsigned long); static void btTestSingleRange(BTFinderFn finder, BT bt, Index base, Index limit, - unsigned long length, + Count length, Bool expect, Index expectBase, Index expectLimit) { @@ -94,7 +95,7 @@ static void btTestSingleRange(BTFinderFn finder, BT bt, static void btTestResRange(BT btlo, BT bthi, Count btSize, Index base, Index limit, - unsigned long length, + Count length, Bool expect, Index expectBase, Index expectLimit) { @@ -120,7 +121,7 @@ static void btTestResRange(BT btlo, BT bthi, Count btSize, static void btTestLongResRange(BT btlo, BT bthi, Count btSize, Index base, Index limit, - unsigned long length, + Count length, Bool expect, Index expectBase, Index expectLimit) { @@ -145,7 +146,7 @@ static void btTestLongResRange(BT btlo, BT bthi, Count btSize, static void btAllResTest(BT btlo, BT bthi, Count btSize, Index base, Index limit, - unsigned long length) + Count length) { btResRangeSymmetric(btlo, bthi, btSize, 0, btSize); btTestResRange(btlo, bthi, btSize, base, limit, length, @@ -164,7 +165,7 @@ static void btAllResTest(BT btlo, BT bthi, Count btSize, static void btNoResTest(BT btlo, BT bthi, Count btSize, Index base, Index limit, - unsigned long length) + Count length) { btResRangeSymmetric(btlo, bthi, btSize, 0, btSize); btSetRangeSymmetric(btlo, bthi, btSize, base, limit); @@ -185,7 +186,7 @@ static void btNoResTest(BT btlo, BT bthi, Count btSize, static void btResAndFindTest(BT btlo, BT bthi, Count btSize, Index base, Index limit, Index resBase, Index resLimit, - unsigned long length) + Count length) { btResRangeSymmetric(btlo, bthi, btSize, resBase, resLimit); if ((resLimit - resBase) < length) { @@ -210,9 +211,9 @@ static void btResAndFindTest(BT btlo, BT bthi, Count btSize, static void btSingleResTest(BT btlo, BT bthi, Count btSize, Index base, Index limit, - unsigned long length) + Count length) { - unsigned long resLen; + Count resLen; /* choose varying range lengths from too short to longer than needed */ for (resLen = length - 1; resLen <= length + 1; resLen++) { if ((resLen > 0) && (resLen < (limit - base -2))) { @@ -257,7 +258,7 @@ typedef unsigned Arrangement; /* Choose a limit for reset range 1 */ static Index btArrangeRes1(Arrangement arrange, Index base, Index res2Base, - unsigned long length) + Count length) { switch (arrange) { @@ -295,7 +296,7 @@ typedef unsigned Pattern; /* Choose a limit for reset range 1 */ static void btResetFirstRange(BT btlo, BT bthi, Count btSize, Index res1Limit, - unsigned long length, + Count length, Pattern pattern) { switch (pattern) { @@ -329,9 +330,9 @@ static void btResetFirstRange(BT btlo, BT bthi, Count btSize, static void btDoubleResTest(BT btlo, BT bthi, Count btSize, Index base, Index limit, - unsigned long length) + Count length) { - unsigned long res2Len; + Count res2Len; if (length < 2) return; /* no possibility of making the first range too small */ @@ -371,7 +372,7 @@ static void btDoubleResTest(BT btlo, BT bthi, Count btSize, static void btFindRangeTests(BT btlo, BT bthi, Count btSize, Index base, Index limit, - unsigned long length) + Count length) { btAllResTest(btlo, bthi, btSize, base, limit, length); btNoResTest(btlo, bthi, btSize, base, limit, length); diff --git a/mps/code/bttest.c b/mps/code/bttest.c index 3c5e44833c6..1b3514c839a 100644 --- a/mps/code/bttest.c +++ b/mps/code/bttest.c @@ -174,7 +174,8 @@ static void findShortResRange(void) Bool b = BTFindShortResRange(&base, &limit, bt, args[1], args[2], args[0]); if (b) - printf("%lu - %lu\n",base, limit); + printf("%"PRIuLONGEST" - %"PRIuLONGEST"\n", + (ulongest_t)base, (ulongest_t)limit); else printf("FALSE\n"); } @@ -192,7 +193,8 @@ static void findShortResRangeHigh(void) Bool b = BTFindShortResRangeHigh(&base, &limit, bt, args[1], args[2], args[0]); if (b) - printf("%lu - %lu\n",base, limit); + printf("%"PRIuLONGEST" - %"PRIuLONGEST"\n", + (ulongest_t)base, (ulongest_t)limit); else printf("FALSE\n"); } @@ -209,7 +211,8 @@ static void findLongResRange(void) Bool b = BTFindLongResRange(&base, &limit, bt, args[1], args[2], args[0]); if (b) - printf("%lu - %lu\n",base, limit); + printf("%"PRIuLONGEST" - %"PRIuLONGEST"\n", + (ulongest_t)base, (ulongest_t)limit); else printf("FALSE\n"); } diff --git a/mps/code/cbs.c b/mps/code/cbs.c index 6eff37a844e..e3f5204e03e 100644 --- a/mps/code/cbs.c +++ b/mps/code/cbs.c @@ -1380,7 +1380,6 @@ Bool CBSFindFirst(Addr *baseReturn, Addr *limitReturn, AVER(baseReturn != NULL); AVER(limitReturn != NULL); AVER(size > 0); - AVER(sizeof(unsigned long) >= sizeof(Size)); AVER(SizeIsAligned(size, cbs->alignment)); AVER(cbs->fastFind); AVERT(CBSFindDelete, findDelete); @@ -1463,7 +1462,6 @@ Bool CBSFindLast(Addr *baseReturn, Addr *limitReturn, AVER(baseReturn != NULL); AVER(limitReturn != NULL); AVER(size > 0); - AVER(sizeof(unsigned long) >= sizeof(Size)); AVER(SizeIsAligned(size, cbs->alignment)); AVER(cbs->fastFind); AVERT(CBSFindDelete, findDelete); @@ -1551,7 +1549,6 @@ Bool CBSFindLargest(Addr *baseReturn, Addr *limitReturn, AVER(baseReturn != NULL); AVER(limitReturn != NULL); - AVER(sizeof(unsigned long) >= sizeof(Size)); AVER(cbs->fastFind); AVERT(CBSFindDelete, findDelete); diff --git a/mps/code/cbstest.c b/mps/code/cbstest.c index 393a17c162d..0777a08732b 100644 --- a/mps/code/cbstest.c +++ b/mps/code/cbstest.c @@ -501,7 +501,7 @@ static void find(CBS cbs, void *block, BT alloc, Size size, Bool high, expected = (high ? BTFindLongResRangeHigh : BTFindLongResRange) (&expectedBase, &expectedLimit, alloc, - (Index)0, (Index)ArraySize, (unsigned long)size); + (Index)0, (Index)ArraySize, (Count)size); if (expected) { oldSize = (expectedLimit - expectedBase) * Alignment; diff --git a/mps/code/dumper.c b/mps/code/dumper.c index bb8889d6632..b2bc31de86c 100644 --- a/mps/code/dumper.c +++ b/mps/code/dumper.c @@ -20,12 +20,23 @@ #include "ossu.h" #endif -typedef unsigned long Word; +typedef MPS_T_WORD Word; typedef struct AddrStruct *Addr; #include "eventcom.h" +#ifdef MPS_PF_W3I6MV +#define PRIuLONGEST "llu" +#define PRIXPTR "016llX" +typedef unsigned long long ulongest_t; +#else +#define PRIuLONGEST "lu" +#define PRIXPTR "08lX" +typedef unsigned long ulongest_t; +#endif + + #define RELATION(type, code, always, kind, format) \ case Event ## type: \ readEvent(#type, #format, header[0], header[1], header[2]); \ @@ -72,10 +83,10 @@ static void readEvent(char *type, char *format, Word code, Word length, for(; *format != '\0'; format++) { switch(*format) { - PROCESS('A', Addr, sizeof(Addr), "0x%08lX", unsigned long) - PROCESS('P', void *, sizeof(void *), "0x%08lX", unsigned long) + PROCESS('A', Addr, sizeof(Addr), "0x%"PRIXPTR, ulongest_t) + PROCESS('P', void *, sizeof(void *), "0x%"PRIXPTR, ulongest_t) PROCESS('U', unsigned, sizeof(unsigned),"%u", unsigned) - PROCESS('W', Word, sizeof(Word),"%lu", Word) + PROCESS('W', Word, sizeof(Word), "%"PRIuLONGEST, ulongest_t) PROCESS('D', double, sizeof(double), "%f", double) case 'S': { size_t n; diff --git a/mps/code/eventrep.c b/mps/code/eventrep.c index 7d9f739bf6e..e0d8e2baa17 100644 --- a/mps/code/eventrep.c +++ b/mps/code/eventrep.c @@ -34,6 +34,17 @@ #endif +#ifdef MPS_PF_W3I6MV +#define PRIuLONGEST "llu" +#define PRIXPTR "016llX" +typedef unsigned long long ulongest_t; +#else +#define PRIuLONGEST "lu" +#define PRIXPTR "08lX" +typedef unsigned long ulongest_t; +#endif + + typedef unsigned long ulong; @@ -114,7 +125,7 @@ static void error(const char *format, ...) va_list args; fflush(stdout); /* sync */ - fprintf(stderr, "Failed @%lu ", (ulong)eventTime); + fprintf(stderr, "Failed @%"PRIuLONGEST" ", (ulongest_t)eventTime); va_start(args, format); vfprintf(stderr, format, args); fprintf(stderr, "\n"); diff --git a/mps/code/exposet0.c b/mps/code/exposet0.c index ac4fa9ff4c6..009347ec8bd 100644 --- a/mps/code/exposet0.c +++ b/mps/code/exposet0.c @@ -69,9 +69,9 @@ static void report(mps_arena_t arena) not_condemned = mps_message_gc_not_condemned_size(arena, message); printf("\nCollection %d finished:\n", ++nCollections); - printf("live %lu\n", (unsigned long)live); - printf("condemned %lu\n", (unsigned long)condemned); - printf("not_condemned %lu\n", (unsigned long)not_condemned); + printf("live %"PRIuLONGEST"\n", (ulongest_t)live); + printf("condemned %"PRIuLONGEST"\n", (ulongest_t)condemned); + printf("not_condemned %"PRIuLONGEST"\n", (ulongest_t)not_condemned); mps_message_discard(arena, message); diff --git a/mps/code/locbwcss.c b/mps/code/locbwcss.c index 3d85576b4fc..766b427ce30 100644 --- a/mps/code/locbwcss.c +++ b/mps/code/locbwcss.c @@ -133,8 +133,8 @@ static void reportResults(PoolStat stat, char *name) printf("\nResults for "); fputs(name, stdout); printf("\n"); - printf(" Allocated %lu objects\n", (unsigned long)stat->aCount); - printf(" Freed %lu objects\n", (unsigned long)stat->fCount); + printf(" Allocated %"PRIuLONGEST" objects\n", (ulongest_t)stat->aCount); + printf(" Freed %"PRIuLONGEST" objects\n", (ulongest_t)stat->fCount); printf(" There were %lu non-contiguous allocations\n", (unsigned long)stat->ncCount); printf(" Address range from %p to %p\n", diff --git a/mps/code/locusss.c b/mps/code/locusss.c index bd1ab6584a6..58689adea8a 100644 --- a/mps/code/locusss.c +++ b/mps/code/locusss.c @@ -137,8 +137,8 @@ static void reportResults(PoolStat stat, char *name) printf("\nResults for "); printf("%s", name); printf("\n"); - printf(" Allocated %lu objects\n", (unsigned long)stat->aCount); - printf(" Freed %lu objects\n", (unsigned long)stat->fCount); + printf(" Allocated %"PRIuLONGEST" objects\n", (ulongest_t)stat->aCount); + printf(" Freed %"PRIuLONGEST" objects\n", (ulongest_t)stat->fCount); printf(" There were %lu non-contiguous allocations\n", (unsigned long)stat->ncCount); printf(" Address range from %p to %p\n", stat->min, stat->max); diff --git a/mps/code/mpmtypes.h b/mps/code/mpmtypes.h index d1aaa1e4cf2..09a754e09e0 100644 --- a/mps/code/mpmtypes.h +++ b/mps/code/mpmtypes.h @@ -132,7 +132,7 @@ typedef Res (*TraceFixMethod)(ScanState ss, Ref *refIO); /* This type is used by the PoolClass method Walk */ typedef void (*FormattedObjectsStepMethod)(Addr obj, Format fmt, Pool pool, - void *v, unsigned long s); + void *v, size_t s); /* This type is used by the PoolClass method Walk */ typedef void (*FreeBlockStepMethod)(Addr base, Addr limit, Pool pool, void *p); diff --git a/mps/code/mv2test.c b/mps/code/mv2test.c index ee322f41c74..91e683d055e 100644 --- a/mps/code/mv2test.c +++ b/mps/code/mv2test.c @@ -236,7 +236,8 @@ static mps_res_t stress(mps_class_t class, mps_arena_t arena, if (verbose) { if(i && i%4==0) putchar('\n'); - printf("%8lX %6lX ", (unsigned long)ps[i], (unsigned long)ss[i]); + printf("%"PRIwLONGEST PRIXLONGEST" %6"PRIXLONGEST" ", + (ulongest_t)ps[i], (ulongest_t)ss[i]); } } if (verbose) { @@ -273,7 +274,8 @@ static mps_res_t stress(mps_class_t class, mps_arena_t arena, if (verbose) { if(i && i%4==0) putchar('\n'); - printf("%8lX %6lX ", (unsigned long)ps[i], (unsigned long)ss[i]); + printf("%"PRIwLONGEST PRIXLONGEST" %6"PRIXLONGEST" ", + (ulongest_t)ps[i], (ulongest_t)ss[i]); } } if (verbose) diff --git a/mps/code/poolamc.c b/mps/code/poolamc.c index 16dc4386c2b..fc33cbbe548 100644 --- a/mps/code/poolamc.c +++ b/mps/code/poolamc.c @@ -2251,7 +2251,7 @@ static void AMCTraceEnd(Pool pool, Trace trace) /* AMCWalk -- Apply function to (black) objects in segment */ static void AMCWalk(Pool pool, Seg seg, FormattedObjectsStepMethod f, - void *p, unsigned long s) + void *p, size_t s) { Addr object, nextObject, limit; AMC amc; @@ -2301,7 +2301,7 @@ static void AMCWalk(Pool pool, Seg seg, FormattedObjectsStepMethod f, /* amcWalkAll -- Apply a function to all (black) objects in a pool */ static void amcWalkAll(Pool pool, FormattedObjectsStepMethod f, - void *p, unsigned long s) + void *p, size_t s) { Arena arena; Ring ring, next, node; @@ -2466,7 +2466,7 @@ typedef struct mps_amc_apply_closure_s { } mps_amc_apply_closure_s; static void mps_amc_apply_iter(Addr addr, Format format, Pool pool, - void *p, unsigned long s) + void *p, size_t s) { mps_amc_apply_closure_s *closure = p; /* Can't check addr */ diff --git a/mps/code/poolawl.c b/mps/code/poolawl.c index f2c6a977c15..38673219495 100644 --- a/mps/code/poolawl.c +++ b/mps/code/poolawl.c @@ -1145,7 +1145,7 @@ static Res AWLAccess(Pool pool, Seg seg, Addr addr, /* AWLWalk -- walk all objects */ static void AWLWalk(Pool pool, Seg seg, FormattedObjectsStepMethod f, - void *p, unsigned long s) + void *p, size_t s) { AWL awl; AWLSeg awlseg; diff --git a/mps/code/poollo.c b/mps/code/poollo.c index 75f4bde67e9..c6f22a595cf 100644 --- a/mps/code/poollo.c +++ b/mps/code/poollo.c @@ -108,7 +108,7 @@ static Res loSegInit(Seg seg, Pool pool, Addr base, Size size, Size tablebytes; /* # bytes in each control array */ Arena arena; /* number of bits needed in each control array */ - unsigned long bits; + Count bits; void *p; AVERT(Seg, seg); @@ -165,7 +165,7 @@ static void loSegFinish(Seg seg) Pool pool; Arena arena; Size tablesize; - unsigned long bits; + Count bits; AVERT(Seg, seg); loseg = SegLOSeg(seg); @@ -236,7 +236,7 @@ static Bool loSegFindFree(Addr *bReturn, Addr *lReturn, Seg seg; Arena arena; Count agrains; - unsigned long tablesize; + Count bits; Addr segBase; AVER(bReturn != NULL); @@ -260,9 +260,9 @@ static Bool loSegFindFree(Addr *bReturn, Addr *lReturn, return FALSE; } - tablesize = SegSize(seg) >> lo->alignShift; + bits = SegSize(seg) >> lo->alignShift; if(!BTFindLongResRange(&baseIndex, &limitIndex, loseg->alloc, - 0, tablesize, agrains)) { + 0, bits, agrains)) { return FALSE; } @@ -408,7 +408,7 @@ static void loSegReclaim(LOSeg loseg, Trace trace) /* a leaf pool, so there can't be any dangling references */ static void LOWalk(Pool pool, Seg seg, FormattedObjectsStepMethod f, - void *p, unsigned long s) + void *p, size_t s) { Addr base; LO lo; @@ -491,7 +491,7 @@ static Res LOInit(Pool pool, va_list arg) pool->format = format; lo->poolStruct.alignment = format->alignment; lo->alignShift = - SizeLog2((unsigned long)PoolAlignment(&lo->poolStruct)); + SizeLog2((Size)PoolAlignment(&lo->poolStruct)); lo->gen = LOGen; /* may be modified in debugger */ res = ChainCreate(&lo->chain, arena, 1, &loGenParam); if (res != ResOK) @@ -669,7 +669,7 @@ static void LOBufferEmpty(Pool pool, Buffer buffer, Addr init, Addr limit) static Res LOWhiten(Pool pool, Trace trace, Seg seg) { LO lo; - unsigned long bits; + Count bits; AVERT(Pool, pool); lo = PoolPoolLO(pool); diff --git a/mps/code/poolsnc.c b/mps/code/poolsnc.c index d4a5d0652b1..74ba6d3cab0 100644 --- a/mps/code/poolsnc.c +++ b/mps/code/poolsnc.c @@ -615,7 +615,7 @@ static void SNCFramePopPending(Pool pool, Buffer buf, AllocFrame frame) static void SNCWalk(Pool pool, Seg seg, FormattedObjectsStepMethod f, - void *p, unsigned long s) + void *p, size_t s) { AVERT(Pool, pool); AVERT(Seg, seg); diff --git a/mps/code/qs.c b/mps/code/qs.c index e289da40f6d..ae07aea9e60 100644 --- a/mps/code/qs.c +++ b/mps/code/qs.c @@ -311,8 +311,8 @@ static void validate(void) cdie(((QSCell)reg[1])->tag == QSInt, "validate int"); if(((QSCell)reg[1])->value != list[i]) { fprintf(stdout, - "mps_res_t: Element %lu of the two lists do not match.\n", - (unsigned long)i); + "mps_res_t: Element %"PRIuLONGEST" of the two lists do not match.\n", + (ulongest_t)i); return; } reg[1] = (mps_word_t)((QSCell)reg[1])->tail; diff --git a/mps/code/replay.c b/mps/code/replay.c index e958cb555c8..00dee793b7c 100644 --- a/mps/code/replay.c +++ b/mps/code/replay.c @@ -24,6 +24,17 @@ #endif +#ifdef MPS_PF_W3I6MV +#define PRIuLONGEST "llu" +#define PRIXPTR "016llX" +typedef unsigned long long ulongest_t; +#else +#define PRIuLONGEST "lu" +#define PRIXPTR "08lX" +typedef unsigned long ulongest_t; +#endif + + typedef unsigned long ulong; @@ -46,7 +57,7 @@ static void error(const char *format, ...) va_list args; fflush(stdout); /* sync */ - fprintf(stderr, "%s: @%lu ", prog, (ulong)eventTime); + fprintf(stderr, "%s: @%"PRIuLONGEST" ", prog, (ulongest_t)eventTime); va_start(args, format); vfprintf(stderr, format, args); fprintf(stderr, "\n"); diff --git a/mps/code/segsmss.c b/mps/code/segsmss.c index 83d919b9995..71036b3edbb 100644 --- a/mps/code/segsmss.c +++ b/mps/code/segsmss.c @@ -376,13 +376,13 @@ static void AMSTFinish(Pool pool) AVERT(AMST, amst); printf("\nDestroying pool, having performed:\n"); - printf(" %lu splits (S)\n", (unsigned long)amst->splits); - printf(" %lu merges (M)\n", (unsigned long)amst->merges); - printf(" %lu aborted splits (B)\n", (unsigned long)amst->badSplits); - printf(" %lu aborted merges (D)\n", (unsigned long)amst->badMerges); + printf(" %"PRIuLONGEST" splits (S)\n", (ulongest_t)amst->splits); + printf(" %"PRIuLONGEST" merges (M)\n", (ulongest_t)amst->merges); + printf(" %"PRIuLONGEST" aborted splits (B)\n", (ulongest_t)amst->badSplits); + printf(" %"PRIuLONGEST" aborted merges (D)\n", (ulongest_t)amst->badMerges); printf(" which included:\n"); - printf(" %lu buffered splits (C)\n", (unsigned long)amst->bsplits); - printf(" %lu buffered merges (J)\n", (unsigned long)amst->bmerges); + printf(" %"PRIuLONGEST" buffered splits (C)\n", (ulongest_t)amst->bsplits); + printf(" %"PRIuLONGEST" buffered merges (J)\n", (ulongest_t)amst->bmerges); AMSFinish(pool); amst->sig = SigInvalid; @@ -799,8 +799,8 @@ static void *test(void *arg, size_t s) while(totalSize < totalSizeMAX) { if (totalSize > lastStep + totalSizeSTEP) { lastStep = totalSize; - printf("\nSize %lu bytes, %lu objects.\n", - (unsigned long)totalSize, objs); + printf("\nSize %"PRIuLONGEST" bytes, %"PRIuLONGEST" objects.\n", + (ulongest_t)totalSize, (ulongest_t)objs); printf("%s", indent); fflush(stdout); for(i = 0; i < exactRootsCOUNT; ++i) diff --git a/mps/code/splay.c b/mps/code/splay.c index 4668a23e48a..4042f2c0e07 100644 --- a/mps/code/splay.c +++ b/mps/code/splay.c @@ -801,7 +801,7 @@ typedef struct { SplayTestNodeMethod testNode; SplayTestTreeMethod testTree; void *p; - unsigned long s; + Size s; SplayTree tree; } SplayFindClosureStruct, *SplayFindClosure; @@ -809,7 +809,7 @@ static Compare SplayFindFirstCompare(void *key, SplayNode node) { SplayFindClosure closure; void *closureP; - unsigned long closureS; + Size closureS; SplayTestNodeMethod testNode; SplayTestTreeMethod testTree; SplayTree tree; @@ -840,7 +840,7 @@ static Compare SplayFindLastCompare(void *key, SplayNode node) { SplayFindClosure closure; void *closureP; - unsigned long closureS; + Size closureS; SplayTestNodeMethod testNode; SplayTestTreeMethod testTree; SplayTree tree; diff --git a/mps/code/steptest.c b/mps/code/steptest.c index a017da67e87..821a0d5c95a 100644 --- a/mps/code/steptest.c +++ b/mps/code/steptest.c @@ -50,11 +50,11 @@ static mps_gen_param_s testChain[genCOUNT] = { * during allocation. */ -static size_t step_frequencies[] = { +static unsigned long step_frequencies[] = { 1000, 5000, 10000, - 1000000000, + 1000000000, /* one billion */ }; #define TESTS (sizeof(step_frequencies) / sizeof(step_frequencies[0])) @@ -414,11 +414,11 @@ static void *test(void *arg, size_t s) total_mps_time = alloc_time + step_time + no_step_time; printf("Collection statistics:\n"); - printf(" %lu collections\n", (unsigned long)collections); - printf(" %lu bytes condemned.\n", (unsigned long)condemned); + printf(" %"PRIuLONGEST" collections\n", (ulongest_t)collections); + printf(" %"PRIuLONGEST" bytes condemned.\n", (ulongest_t)condemned); printf(" %lu bytes not condemned.\n", (unsigned long)not_condemned); - printf(" %lu bytes survived.\n", (unsigned long)live); + printf(" %"PRIuLONGEST" bytes survived.\n", (ulongest_t)live); if (condemned) { printf(" Mortality %5.2f%%.\n", (1.0 - ((double)live)/condemned) * 100.0); @@ -471,7 +471,7 @@ static void *test(void *arg, size_t s) print_time(" (adjusted for clock timing: ", total_clock_time, " spent reading the clock;\n"); - printf(" %lu clock reads; ", (unsigned long)clock_reads); + printf(" %"PRIuLONGEST" clock reads; ", (ulongest_t)clock_reads); print_time("", total_clock_time / clock_reads, " per read;"); print_time(" recently measured as ", clock_time, ").\n"); mps_ap_destroy(ap); diff --git a/mps/code/testlib.h b/mps/code/testlib.h index 2a70fa81f58..63d462a6658 100644 --- a/mps/code/testlib.h +++ b/mps/code/testlib.h @@ -75,6 +75,30 @@ #endif /* MPS_BUILD_MV */ +/* ulongest_t -- longest unsigned integer type + * + * Define a longest unsigned integer type for testing and printing. We'd + * like to use C99's uintmax_t and PRIuMAX here, but the MPS is in C89 + * and C99 isn't supported by Microsoft. + * + * We avoid using the ones defined in mpstd.h because we want the tests to + * root out any incompatible assumptions by breaking. + */ + +#ifdef MPS_PF_W3I6MV +#define PRIuLONGEST "llu" +#define PRIXLONGEST "llX" +#define PRIwLONGEST "16" +typedef unsigned long long ulongest_t; +#else +#define PRIuLONGEST "lu" +#define PRIXLONGEST "lX" +#define PRIwLONGEST "8" +typedef unsigned long ulongest_t; +#endif +#define PRIXPTR "0"PRIwLONGEST PRIXLONGEST + + /* testlib_unused -- declares that a variable is unused * * It should be used to prevent compiler warnings about unused diff --git a/mps/code/zcoll.c b/mps/code/zcoll.c index f9c868049f4..546e6b50def 100644 --- a/mps/code/zcoll.c +++ b/mps/code/zcoll.c @@ -92,13 +92,13 @@ static void *stack_start; static mps_thr_t stack_thr; -static unsigned long cols(size_t bytes) +static ulongest_t cols(size_t bytes) { double M; /* Mebibytes */ - unsigned long cM; /* hundredths of a Mebibyte */ + ulongest_t cM; /* hundredths of a Mebibyte */ M = (double)bytes / (1UL<<20); - cM = (unsigned long)(M * 100 + 0.5); /* round to nearest */ + cM = (ulongest_t)(M * 100.0 + 0.5); /* round to nearest */ return cM; } @@ -424,8 +424,8 @@ static void CatalogDo(mps_arena_t arena, mps_ap_t ap) static void* MakeThing(mps_arena_t arena, mps_ap_t ap, size_t size) { mps_word_t v; - unsigned long words; - unsigned long slots; + ulongest_t words; + ulongest_t slots; words = (size + (sizeof(mps_word_t) - 1) ) / sizeof(mps_word_t); if(words < 2) @@ -440,8 +440,8 @@ static void* MakeThing(mps_arena_t arena, mps_ap_t ap, size_t size) static void BigdropSmall(mps_arena_t arena, mps_ap_t ap, size_t big, char small_ref) { - static unsigned long keepCount = 0; - unsigned long i; + static unsigned keepCount = 0; + unsigned i; mps_arena_park(arena); for(i = 0; i < 100; i++) { @@ -474,7 +474,7 @@ static unsigned long df(unsigned randm, unsigned number) static void Make(mps_arena_t arena, mps_ap_t ap, unsigned randm, unsigned keep1in, unsigned keepTotal, unsigned keepRootspace, unsigned sizemethod) { unsigned keepCount = 0; - unsigned long objCount = 0; + unsigned objCount = 0; Insist(keepRootspace <= myrootExactCOUNT); @@ -523,7 +523,7 @@ static void Make(mps_arena_t arena, mps_ap_t ap, unsigned randm, unsigned keep1i } printf(" ...made and kept: %u objects, storing cyclically in " "first %u roots " - "(actually created %lu objects, in accord with " + "(actually created %u objects, in accord with " "keep-1-in %u).\n", keepCount, keepRootspace, objCount, keep1in); } @@ -531,7 +531,7 @@ static void Make(mps_arena_t arena, mps_ap_t ap, unsigned randm, unsigned keep1i static void Rootdrop(char rank_char) { - unsigned long i; + unsigned i; if(rank_char == 'A') { for(i = 0; i < myrootAmbigCOUNT; ++i) { @@ -553,6 +553,10 @@ static void stackwipe(void) unsigned iw; unsigned long aw[stackwipedepth]; + /* Do some pointless work that the compiler won't optimise away, so that + this function wipes over the stack by filling stuff into the "aw" + array. */ + /* http://xkcd.com/710/ */ /* I don't want my friends to stop calling; I just want the */ /* compiler to stop optimising away my code. */ @@ -808,7 +812,7 @@ static void testscriptA(const char *script) printf(" Create arena, size = %lu.\n", arenasize); /* arena */ - die(mps_arena_create(&arena, mps_arena_class_vm(), arenasize), + die(mps_arena_create(&arena, mps_arena_class_vm(), (size_t)arenasize), "arena_create"); /* thr: used to stop/restart multiple threads */ -- cgit v1.2.1 From dd4cefe55580a3268b64e901396fc46ff342fcab Mon Sep 17 00:00:00 2001 From: Richard Brooksby Date: Mon, 23 Apr 2012 17:13:41 +0100 Subject: Fixing unsigned longs in eventcnv but not column widths. Copied from Perforce Change: 178026 ServerID: perforce.ravenbrook.com --- mps/code/eventcnv.c | 99 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 56 insertions(+), 43 deletions(-) (limited to 'mps/code') diff --git a/mps/code/eventcnv.c b/mps/code/eventcnv.c index efc601c6507..a524fd56445 100644 --- a/mps/code/eventcnv.c +++ b/mps/code/eventcnv.c @@ -11,6 +11,7 @@ #include "eventcom.h" #include "eventpro.h" #include "mpmtypes.h" +#include "testlib.h" /* for ulongest_t and associated print formats */ #include /* for size_t */ #include /* for printf */ @@ -60,14 +61,14 @@ static Bool partialLog = FALSE; static Word bucketSize = 0; -/* error -- error signalling */ +/* everror -- error signalling */ -static void error(const char *format, ...) +static void everror(const char *format, ...) { va_list args; fflush(stdout); /* sync */ - fprintf(stderr, "%s: @%lu ", prog, (ulong)eventTime); + fprintf(stderr, "%s: @%"PRIuLONGEST" ", prog, (ulongest_t)eventTime); va_start(args, format); vfprintf(stderr, format, args); fprintf(stderr, "\n"); @@ -92,7 +93,7 @@ static void usage(void) static void usageError(void) { usage(); - error("Bad usage"); + everror("Bad usage"); } @@ -197,7 +198,7 @@ static void processEvent(EventProc proc, Event event, Word etime) res = EventRecord(proc, event, etime); if (res != ResOK) - error("Can't record event: error %d.", res); + everror("Can't record event: error %d.", res); switch(event->any.code) { default: break; @@ -239,11 +240,16 @@ static void printAddr(EventProc proc, Addr addr) putchar(' '); printStr(sym, (style == 'C')); } else { - printf((style == '\0') ? " sym%05lX" : " \"sym %lX\"", - (ulong)label); + printf((style == '\0') ? + " sym%05"PRIXLONGEST : + " \"sym %"PRIXLONGEST"\"", + (ulongest_t)label); } } else - printf((style != 'C') ? " %08lX" : " %lu", (ulong)addr); + printf(style != 'C' ? + " %0"PRIwLONGEST PRIXLONGEST : + " %"PRIuLONGEST, + (ulongest_t)addr); } @@ -289,13 +295,13 @@ static void reportBucketResults(Word bucketLimit) { switch (style) { case '\0': - printf("%8lu:", (ulong)bucketLimit); + printf("%8"PRIuLONGEST":", (ulongest_t)bucketLimit); break; case 'L': - printf("(%lX", (ulong)bucketLimit); + printf("(%"PRIXLONGEST, (ulongest_t)bucketLimit); break; case 'C': - printf("%lu", (ulong)bucketLimit); + printf("%"PRIuLONGEST, (ulongest_t)bucketLimit); break; } if (reportEvents) { @@ -333,16 +339,16 @@ static void printArg(EventProc proc, if (style == 'C') putchar(','); printAddr(proc, *(Addr *)arg); } else - printf(styleConv, (ulong)*(Addr *)arg); + printf(styleConv, (ulongest_t)*(Addr *)arg); } break; case 'P': { - printf(styleConv, (ulong)*(void **)arg); + printf(styleConv, (ulongest_t)*(void **)arg); } break; case 'U': { - printf(styleConv, (ulong)*(unsigned *)arg); + printf(styleConv, (ulongest_t)*(unsigned *)arg); } break; case 'W': { - printf(styleConv, (ulong)*(Word *)arg); + printf(styleConv, (ulongest_t)*(Word *)arg); } break; case 'D': { switch (style) { @@ -359,7 +365,7 @@ static void printArg(EventProc proc, putchar(' '); printStr((EventStringStruct *)arg, (style == 'C' || style == 'L')); } break; - default: error("Can't print format >%c<", argType); + default: everror("Can't print format >%c<", argType); } } @@ -396,13 +402,13 @@ static void readLog(EventProc proc) /* Init style. */ switch (style) { case '\0': - styleConv = " %8lX"; break; + styleConv = " %8"PRIXLONGEST; break; case 'C': - styleConv = ", %lu"; break; + styleConv = ", %"PRIuLONGEST; break; case 'L': - styleConv = " %lX"; break; + styleConv = " %"PRIXLONGEST; break; default: - error("Unknown style code '%c'", style); + everror("Unknown style code '%c'", style); } while (TRUE) { /* loop for each event */ @@ -415,7 +421,7 @@ static void readLog(EventProc proc) /* Read and parse event. */ res = EventRead(&event, proc); if (res == ResFAIL) break; /* eof */ - if (res != ResOK) error("Truncated log"); + if (res != ResOK) everror("Truncated log"); eventTime = event->any.clock; code = EventGetCode(event); @@ -451,11 +457,11 @@ static void readLog(EventProc proc) switch (style) { case '\0': - printf(" %8lu", (ulong)eventTime); break; + printf(" %8"PRIuLONGEST, (ulongest_t)eventTime); break; case 'C': - printf(", %lu", (ulong)eventTime); break; + printf(", %"PRIuLONGEST, (ulongest_t)eventTime); break; case 'L': - printf(" %lX", (ulong)eventTime); break; + printf(" %"PRIXLONGEST, (ulongest_t)eventTime); break; } switch (event->any.code) { @@ -463,17 +469,23 @@ static void readLog(EventProc proc) switch (style) { case '\0': case 'C': { EventString sym = LabelText(proc, event->aw.w1); - printf((style == '\0') ? " %08lX " : ", %lu, ", - (ulong)event->aw.a0); + printf(style == '\0' ? + " %08"PRIXLONGEST" " : + ", %"PRIuLONGEST", ", + (ulongest_t)event->aw.a0); if (sym != NULL) { printStr(sym, (style == 'C')); } else { - printf((style == '\0') ? "sym %05lX" : "sym %lX\"", - (ulong)event->aw.w1); + printf(style == '\0' ? + "sym %05"PRIXLONGEST : + "sym %"PRIXLONGEST"\"", + (ulongest_t)event->aw.w1); } } break; case 'L': { - printf(" %lX %lX", (ulong)event->aw.a0, (ulong)event->aw.w1); + printf(" %"PRIXLONGEST" %"PRIXLONGEST, + (ulongest_t)event->aw.a0, + (ulongest_t)event->aw.w1); } break; } } break; @@ -481,16 +493,16 @@ static void readLog(EventProc proc) switch (style) { case '\0': { if (event->pddwww.w3 == 0) { - printf(" %08lX 0 N/A N/A N/A N/A", - (ulong)event->pddwww.p0); + printf(" %08"PRIXLONGEST" 0 N/A N/A N/A N/A", + (ulongest_t)event->pddwww.p0); } else { double mean = event->pddwww.d1 / (double)event->pddwww.w3; /* .stddev: stddev = sqrt(meanSquared - mean^2), but see */ /* . */ double stddev = sqrt(fabs(event->pddwww.d2 - (mean * mean))); - printf(" %08lX %8u %8u %8u %#8.3g %#8.3g", - (ulong)event->pddwww.p0, (uint)event->pddwww.w3, + printf(" %08"PRIXLONGEST" %8u %8u %8u %#8.3g %#8.3g", + (ulongest_t)event->pddwww.p0, (uint)event->pddwww.w3, (uint)event->pddwww.w4, (uint)event->pddwww.w5, mean, stddev); } @@ -505,7 +517,8 @@ static void readLog(EventProc proc) (uint)event->pddwww.w5); } break; case 'L': { - printf(" %lX %#.10G %#.10G %X %X %X", (ulong)event->pddwww.p0, + printf(" %"PRIXLONGEST" %#.10G %#.10G %X %X %X", + (ulongest_t)event->pddwww.p0, event->pddwww.d1, event->pddwww.d2, (uint)event->pddwww.w3, (uint)event->pddwww.w4, (uint)event->pddwww.w5); @@ -513,14 +526,14 @@ static void readLog(EventProc proc) } } break; case EventPoolInit: { /* pool, arena, class */ - printf(styleConv, (ulong)event->ppp.p0); - printf(styleConv, (ulong)event->ppp.p1); + printf(styleConv, (ulongest_t)event->ppp.p0); + printf(styleConv, (ulongest_t)event->ppp.p1); /* class is a Pointer, but we label them, so call printAddr */ if (style != 'L') { if (style == 'C') putchar(','); printAddr(proc, (Addr)event->ppp.p2); } else - printf(styleConv, (ulong)event->ppp.p2); + printf(styleConv, (ulongest_t)event->ppp.p2); } break; default: for (i = 0; i < argCount; ++i) { @@ -565,7 +578,7 @@ static void readLog(EventProc proc) if (eventEnabled[c]) printf(" %04X %s\n", (unsigned)c, EventCode2Name(c)); if (bucketSize == 0) - printf("\nevent clock stopped at %lu\n", (ulong)eventTime); + printf("\nevent clock stopped at %"PRIuLONGEST"\n", (ulongest_t)eventTime); } } } @@ -602,9 +615,9 @@ int main(int argc, char *argv[]) /* GCC -ansi -pedantic -Werror on FreeBSD will fail here * with the warning "statement with no effect". */ - assert(CHECKCONV(ulong, Word)); - assert(CHECKCONV(ulong, Addr)); - assert(CHECKCONV(ulong, void *)); + assert(CHECKCONV(ulongest_t, Word)); + assert(CHECKCONV(ulongest_t, Addr)); + assert(CHECKCONV(ulongest_t, void *)); assert(CHECKCONV(unsigned, EventCode)); assert(CHECKCONV(Addr, void *)); /* for labelled pointers */ #endif @@ -616,12 +629,12 @@ int main(int argc, char *argv[]) else { input = fopen(filename, "rb"); if (input == NULL) - error("unable to open \"%s\"\n", filename); + everror("unable to open \"%s\"\n", filename); } res = EventProcCreate(&proc, partialLog, logReader, (void *)input); if (res != ResOK) - error("Can't init EventProc module: error %d.", res); + everror("Can't init EventProc module: error %d.", res); readLog(proc); -- cgit v1.2.1