aboutsummaryrefslogtreecommitdiffstats
path: root/mps/code
diff options
context:
space:
mode:
authorRichard Brooksby2012-05-01 16:27:19 +0100
committerRichard Brooksby2012-05-01 16:27:19 +0100
commitcf80843764eb1c7b7a6eb8153ef23613112fc0bb (patch)
tree23accba599c4ca2c52d767b5bf56caf36a40367f /mps/code
parentc3966f7c057ac921ff694a97cb924240e3acbad8 (diff)
parent1c2174afa75e0779e674910b3df187027802ab8d (diff)
downloademacs-cf80843764eb1c7b7a6eb8153ef23613112fc0bb.tar.gz
emacs-cf80843764eb1c7b7a6eb8153ef23613112fc0bb.zip
Merging branch/2012-03-27/longest back to master, removing the assumption that "unsigned long" is the longest integer type, or that it is large enough to hold a pointer.
Copied from Perforce Change: 178072 ServerID: perforce.ravenbrook.com
Diffstat (limited to 'mps/code')
-rw-r--r--mps/code/amcss.c10
-rw-r--r--mps/code/amcsshe.c6
-rw-r--r--mps/code/amcssth.c6
-rw-r--r--mps/code/amsss.c10
-rw-r--r--mps/code/amssshe.c4
-rw-r--r--mps/code/bt.c16
-rw-r--r--mps/code/bt.h10
-rw-r--r--mps/code/btcv.c29
-rw-r--r--mps/code/bttest.c9
-rw-r--r--mps/code/cbs.c21
-rw-r--r--mps/code/cbstest.c2
-rw-r--r--mps/code/dumper.c19
-rw-r--r--mps/code/eventcnv.c99
-rw-r--r--mps/code/eventrep.c13
-rw-r--r--mps/code/exposet0.c6
-rw-r--r--mps/code/locbwcss.c4
-rw-r--r--mps/code/locusss.c4
-rw-r--r--mps/code/mpm.c30
-rw-r--r--mps/code/mpm.h4
-rw-r--r--mps/code/mpmtypes.h9
-rw-r--r--mps/code/mps.h7
-rw-r--r--mps/code/mpstd.h20
-rw-r--r--mps/code/mv2test.c6
-rw-r--r--mps/code/pool.c2
-rw-r--r--mps/code/poolabs.c2
-rw-r--r--mps/code/poolamc.c6
-rw-r--r--mps/code/poolawl.c2
-rw-r--r--mps/code/poollo.c16
-rw-r--r--mps/code/poolsnc.c2
-rw-r--r--mps/code/qs.c4
-rw-r--r--mps/code/replay.c13
-rw-r--r--mps/code/segsmss.c16
-rw-r--r--mps/code/splay.c10
-rw-r--r--mps/code/splay.h8
-rw-r--r--mps/code/steptest.c12
-rw-r--r--mps/code/testlib.h24
-rw-r--r--mps/code/walk.c6
-rw-r--r--mps/code/zcoll.c26
38 files changed, 296 insertions, 197 deletions
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)
86 nCollsStart += 1; 86 nCollsStart += 1;
87 printf("\n{\n Collection %d started. Because:\n", nCollsStart); 87 printf("\n{\n Collection %d started. Because:\n", nCollsStart);
88 printf(" %s\n", mps_message_gc_start_why(arena, message)); 88 printf(" %s\n", mps_message_gc_start_why(arena, message));
89 printf(" clock: %lu\n", (unsigned long)mps_message_clock(arena, message)); 89 printf(" clock: %"PRIuLONGEST"\n", (ulongest_t)mps_message_clock(arena, message));
90 break; 90 break;
91 } 91 }
92 case mps_message_type_gc(): { 92 case mps_message_type_gc(): {
@@ -98,10 +98,10 @@ static void report(mps_arena_t arena)
98 not_condemned = mps_message_gc_not_condemned_size(arena, message); 98 not_condemned = mps_message_gc_not_condemned_size(arena, message);
99 99
100 printf("\n Collection %d finished:\n", nCollsDone); 100 printf("\n Collection %d finished:\n", nCollsDone);
101 printf(" live %lu\n", (unsigned long)live); 101 printf(" live %"PRIuLONGEST"\n", (ulongest_t)live);
102 printf(" condemned %lu\n", (unsigned long)condemned); 102 printf(" condemned %"PRIuLONGEST"\n", (ulongest_t)condemned);
103 printf(" not_condemned %lu\n", (unsigned long)not_condemned); 103 printf(" not_condemned %"PRIuLONGEST"\n", (ulongest_t)not_condemned);
104 printf(" clock: %lu\n", (unsigned long)mps_message_clock(arena, message)); 104 printf(" clock: %"PRIuLONGEST"\n", (ulongest_t)mps_message_clock(arena, message));
105 printf("}\n"); 105 printf("}\n");
106 106
107 if(condemned > (gen1SIZE + gen2SIZE + (size_t)128) * 1024) { 107 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)
88 not_condemned = mps_message_gc_not_condemned_size(arena, message); 88 not_condemned = mps_message_gc_not_condemned_size(arena, message);
89 89
90 printf("\nCollection %d finished:\n", ++nCollections); 90 printf("\nCollection %d finished:\n", ++nCollections);
91 printf("live %lu\n", (unsigned long)live); 91 printf("live %"PRIuLONGEST"\n", (ulongest_t)live);
92 printf("condemned %lu\n", (unsigned long)condemned); 92 printf("condemned %"PRIuLONGEST"\n", (ulongest_t)condemned);
93 printf("not_condemned %lu\n", (unsigned long)not_condemned); 93 printf("not_condemned %"PRIuLONGEST"\n", (ulongest_t)not_condemned);
94 94
95 mps_message_discard(arena, message); 95 mps_message_discard(arena, message);
96 96
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)
67 not_condemned = mps_message_gc_not_condemned_size(arena, message); 67 not_condemned = mps_message_gc_not_condemned_size(arena, message);
68 68
69 printf("\nCollection %d finished:\n", ++nCollections); 69 printf("\nCollection %d finished:\n", ++nCollections);
70 printf("live %lu\n", (unsigned long)live); 70 printf("live %"PRIuLONGEST"\n", (ulongest_t)live);
71 printf("condemned %lu\n", (unsigned long)condemned); 71 printf("condemned %"PRIuLONGEST"\n", (ulongest_t)condemned);
72 printf("not_condemned %lu\n", (unsigned long)not_condemned); 72 printf("not_condemned %"PRIuLONGEST"\n", (ulongest_t)not_condemned);
73 73
74 mps_message_discard(arena, message); 74 mps_message_discard(arena, message);
75 75
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)
73 not_condemned = mps_message_gc_not_condemned_size(arena, message); 73 not_condemned = mps_message_gc_not_condemned_size(arena, message);
74 74
75 printf("\nCollection complete %d:\n", ++nComplete); 75 printf("\nCollection complete %d:\n", ++nComplete);
76 printf("live %lu\n", (unsigned long)live); 76 printf("live %"PRIuLONGEST"\n", (ulongest_t)live);
77 printf("condemned %lu\n", (unsigned long)condemned); 77 printf("condemned %"PRIuLONGEST"\n", (ulongest_t)condemned);
78 printf("not_condemned %lu\n", (unsigned long)not_condemned); 78 printf("not_condemned %"PRIuLONGEST"\n", (ulongest_t)not_condemned);
79 } 79 }
80 break; 80 break;
81 default: 81 default:
@@ -153,8 +153,8 @@ static void *test(void *arg, size_t haveAmbigous)
153 while(totalSize < totalSizeMAX) { 153 while(totalSize < totalSizeMAX) {
154 if (totalSize > lastStep + totalSizeSTEP) { 154 if (totalSize > lastStep + totalSizeSTEP) {
155 lastStep = totalSize; 155 lastStep = totalSize;
156 printf("\nSize %lu bytes, %lu objects.\n", 156 printf("\nSize %"PRIuLONGEST" bytes, %lu objects.\n",
157 (unsigned long)totalSize, objs); 157 (ulongest_t)totalSize, objs);
158 fflush(stdout); 158 fflush(stdout);
159 for(i = 0; i < exactRootsCOUNT; ++i) 159 for(i = 0; i < exactRootsCOUNT; ++i)
160 cdie(exactRoots[i] == objNULL || dylan_check(exactRoots[i]), 160 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)
108 while(totalSize < totalSizeMAX) { 108 while(totalSize < totalSizeMAX) {
109 if(totalSize > lastStep + totalSizeSTEP) { 109 if(totalSize > lastStep + totalSizeSTEP) {
110 lastStep = totalSize; 110 lastStep = totalSize;
111 printf("\nSize %lu bytes, %lu objects.\n", 111 printf("\nSize %"PRIuLONGEST" bytes, %lu objects.\n",
112 (unsigned long)totalSize, objs); 112 (ulongest_t)totalSize, objs);
113 fflush(stdout); 113 fflush(stdout);
114 for(i = 0; i < exactRootsCOUNT; ++i) 114 for(i = 0; i < exactRootsCOUNT; ++i)
115 cdie(exactRoots[i] == objNULL || dylan_check(exactRoots[i]), 115 cdie(exactRoots[i] == objNULL || dylan_check(exactRoots[i]),
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)
228 * See <design/bt/#fun.size> 228 * See <design/bt/#fun.size>
229 */ 229 */
230 230
231size_t (BTSize)(unsigned long n) 231Size (BTSize)(Count n)
232{ 232{
233 /* check that the expression used in rounding up doesn't overflow */ 233 /* check that the expression used in rounding up doesn't overflow */
234 AVER(n+MPS_WORD_WIDTH-1 > n); 234 AVER(n+MPS_WORD_WIDTH-1 > n);
@@ -617,7 +617,7 @@ btFindResHighLabel:; \
617static Bool BTFindResRange(Index *baseReturn, Index *limitReturn, 617static Bool BTFindResRange(Index *baseReturn, Index *limitReturn,
618 BT bt, 618 BT bt,
619 Index searchBase, Index searchLimit, 619 Index searchBase, Index searchLimit,
620 unsigned long minLength, unsigned long maxLength) 620 Count minLength, Count maxLength)
621{ 621{
622 Bool foundRes; /* true if a reset bit is found */ 622 Bool foundRes; /* true if a reset bit is found */
623 Index resBase; /* base of a candidate reset range */ 623 Index resBase; /* base of a candidate reset range */
@@ -704,8 +704,8 @@ static Bool BTFindResRange(Index *baseReturn, Index *limitReturn,
704static Bool BTFindResRangeHigh(Index *baseReturn, Index *limitReturn, 704static Bool BTFindResRangeHigh(Index *baseReturn, Index *limitReturn,
705 BT bt, 705 BT bt,
706 Index searchBase, Index searchLimit, 706 Index searchBase, Index searchLimit,
707 unsigned long minLength, 707 Count minLength,
708 unsigned long maxLength) 708 Count maxLength)
709{ 709{
710 Bool foundRes; /* true if a reset bit is found */ 710 Bool foundRes; /* true if a reset bit is found */
711 Index resLimit; /* limit of a candidate reset range */ 711 Index resLimit; /* limit of a candidate reset range */
@@ -797,7 +797,7 @@ static Bool BTFindResRangeHigh(Index *baseReturn, Index *limitReturn,
797Bool BTFindLongResRange(Index *baseReturn, Index *limitReturn, 797Bool BTFindLongResRange(Index *baseReturn, Index *limitReturn,
798 BT bt, 798 BT bt,
799 Index searchBase, Index searchLimit, 799 Index searchBase, Index searchLimit,
800 unsigned long length) 800 Count length)
801{ 801{
802 /* All parameters are checked by BTFindResRange. */ 802 /* All parameters are checked by BTFindResRange. */
803 return BTFindResRange(baseReturn, limitReturn, 803 return BTFindResRange(baseReturn, limitReturn,
@@ -815,7 +815,7 @@ Bool BTFindLongResRange(Index *baseReturn, Index *limitReturn,
815Bool BTFindLongResRangeHigh(Index *baseReturn, Index *limitReturn, 815Bool BTFindLongResRangeHigh(Index *baseReturn, Index *limitReturn,
816 BT bt, 816 BT bt,
817 Index searchBase, Index searchLimit, 817 Index searchBase, Index searchLimit,
818 unsigned long length) 818 Count length)
819{ 819{
820 /* All parameters are checked by BTFindResRangeHigh. */ 820 /* All parameters are checked by BTFindResRangeHigh. */
821 return BTFindResRangeHigh(baseReturn, limitReturn, 821 return BTFindResRangeHigh(baseReturn, limitReturn,
@@ -833,7 +833,7 @@ Bool BTFindLongResRangeHigh(Index *baseReturn, Index *limitReturn,
833Bool BTFindShortResRange(Index *baseReturn, Index *limitReturn, 833Bool BTFindShortResRange(Index *baseReturn, Index *limitReturn,
834 BT bt, 834 BT bt,
835 Index searchBase, Index searchLimit, 835 Index searchBase, Index searchLimit,
836 unsigned long length) 836 Count length)
837{ 837{
838 /* All parameters are checked by BTFindResRange. */ 838 /* All parameters are checked by BTFindResRange. */
839 return BTFindResRange(baseReturn, limitReturn, 839 return BTFindResRange(baseReturn, limitReturn,
@@ -852,7 +852,7 @@ Bool BTFindShortResRange(Index *baseReturn, Index *limitReturn,
852Bool BTFindShortResRangeHigh(Index *baseReturn, Index *limitReturn, 852Bool BTFindShortResRangeHigh(Index *baseReturn, Index *limitReturn,
853 BT bt, 853 BT bt,
854 Index searchBase, Index searchLimit, 854 Index searchBase, Index searchLimit,
855 unsigned long length) 855 Count length)
856{ 856{
857 /* All parameters are checked by BTFindResRangeHigh. */ 857 /* All parameters are checked by BTFindResRangeHigh. */
858 return BTFindResRangeHigh(baseReturn, limitReturn, 858 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 @@
13 13
14 14
15/* <design/bt#if.size> */ 15/* <design/bt#if.size> */
16extern size_t (BTSize)(unsigned long length); 16extern Size (BTSize)(Count length);
17#define BTSize(n) (((n) + MPS_WORD_WIDTH-1) / MPS_WORD_WIDTH * sizeof(Word)) 17#define BTSize(n) (((n) + MPS_WORD_WIDTH-1) / MPS_WORD_WIDTH * sizeof(Word))
18 18
19/* <design/bt/#if.get> */ 19/* <design/bt/#if.get> */
@@ -49,16 +49,16 @@ extern Bool BTIsResRange(BT bt, Index base, Index limit);
49 49
50extern Bool BTFindShortResRange(Index *baseReturn, Index *limitReturn, 50extern Bool BTFindShortResRange(Index *baseReturn, Index *limitReturn,
51 BT bt, Index searchBase, Index searchLimit, 51 BT bt, Index searchBase, Index searchLimit,
52 unsigned long length); 52 Count length);
53extern Bool BTFindShortResRangeHigh(Index *baseReturn, Index *limitReturn, 53extern Bool BTFindShortResRangeHigh(Index *baseReturn, Index *limitReturn,
54 BT bt, Index searchBase, Index searchLimit, 54 BT bt, Index searchBase, Index searchLimit,
55 unsigned long length); 55 Count length);
56extern Bool BTFindLongResRange(Index *baseReturn, Index *limitReturn, 56extern Bool BTFindLongResRange(Index *baseReturn, Index *limitReturn,
57 BT bt, Index searchBase, Index searchLimit, 57 BT bt, Index searchBase, Index searchLimit,
58 unsigned long length); 58 Count length);
59extern Bool BTFindLongResRangeHigh(Index *baseReturn, Index *limitReturn, 59extern Bool BTFindLongResRangeHigh(Index *baseReturn, Index *limitReturn,
60 BT bt, Index searchBase, Index searchLimit, 60 BT bt, Index searchBase, Index searchLimit,
61 unsigned long length); 61 Count length);
62 62
63extern Bool BTRangesSame(BT BTx, BT BTy, Index base, Index limit); 63extern Bool BTRangesSame(BT BTx, BT BTy, Index base, Index limit);
64 64
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,
61} 61}
62 62
63 63
64typedef Bool (*BTFinderFn)(Index *, Index *, BT, Index, Index, unsigned long); 64typedef Bool (*BTFinderFn)(Index *foundBase_o, Index *foundLimit_o,
65 BT bt, Index base, Index limit, Count length);
65 66
66 67
67/* btTestSingleRange -- Test expectations for calls to BTFind*ResRange* 68/* btTestSingleRange -- Test expectations for calls to BTFind*ResRange*
@@ -70,7 +71,7 @@ typedef Bool (*BTFinderFn)(Index *, Index *, BT, Index, Index, unsigned long);
70 71
71static void btTestSingleRange(BTFinderFn finder, BT bt, 72static void btTestSingleRange(BTFinderFn finder, BT bt,
72 Index base, Index limit, 73 Index base, Index limit,
73 unsigned long length, 74 Count length,
74 Bool expect, 75 Bool expect,
75 Index expectBase, Index expectLimit) 76 Index expectBase, Index expectLimit)
76{ 77{
@@ -94,7 +95,7 @@ static void btTestSingleRange(BTFinderFn finder, BT bt,
94 95
95static void btTestResRange(BT btlo, BT bthi, Count btSize, 96static void btTestResRange(BT btlo, BT bthi, Count btSize,
96 Index base, Index limit, 97 Index base, Index limit,
97 unsigned long length, 98 Count length,
98 Bool expect, 99 Bool expect,
99 Index expectBase, Index expectLimit) 100 Index expectBase, Index expectLimit)
100{ 101{
@@ -120,7 +121,7 @@ static void btTestResRange(BT btlo, BT bthi, Count btSize,
120 121
121static void btTestLongResRange(BT btlo, BT bthi, Count btSize, 122static void btTestLongResRange(BT btlo, BT bthi, Count btSize,
122 Index base, Index limit, 123 Index base, Index limit,
123 unsigned long length, 124 Count length,
124 Bool expect, 125 Bool expect,
125 Index expectBase, Index expectLimit) 126 Index expectBase, Index expectLimit)
126{ 127{
@@ -145,7 +146,7 @@ static void btTestLongResRange(BT btlo, BT bthi, Count btSize,
145 146
146static void btAllResTest(BT btlo, BT bthi, Count btSize, 147static void btAllResTest(BT btlo, BT bthi, Count btSize,
147 Index base, Index limit, 148 Index base, Index limit,
148 unsigned long length) 149 Count length)
149{ 150{
150 btResRangeSymmetric(btlo, bthi, btSize, 0, btSize); 151 btResRangeSymmetric(btlo, bthi, btSize, 0, btSize);
151 btTestResRange(btlo, bthi, btSize, base, limit, length, 152 btTestResRange(btlo, bthi, btSize, base, limit, length,
@@ -164,7 +165,7 @@ static void btAllResTest(BT btlo, BT bthi, Count btSize,
164 165
165static void btNoResTest(BT btlo, BT bthi, Count btSize, 166static void btNoResTest(BT btlo, BT bthi, Count btSize,
166 Index base, Index limit, 167 Index base, Index limit,
167 unsigned long length) 168 Count length)
168{ 169{
169 btResRangeSymmetric(btlo, bthi, btSize, 0, btSize); 170 btResRangeSymmetric(btlo, bthi, btSize, 0, btSize);
170 btSetRangeSymmetric(btlo, bthi, btSize, base, limit); 171 btSetRangeSymmetric(btlo, bthi, btSize, base, limit);
@@ -185,7 +186,7 @@ static void btNoResTest(BT btlo, BT bthi, Count btSize,
185static void btResAndFindTest(BT btlo, BT bthi, Count btSize, 186static void btResAndFindTest(BT btlo, BT bthi, Count btSize,
186 Index base, Index limit, 187 Index base, Index limit,
187 Index resBase, Index resLimit, 188 Index resBase, Index resLimit,
188 unsigned long length) 189 Count length)
189{ 190{
190 btResRangeSymmetric(btlo, bthi, btSize, resBase, resLimit); 191 btResRangeSymmetric(btlo, bthi, btSize, resBase, resLimit);
191 if ((resLimit - resBase) < length) { 192 if ((resLimit - resBase) < length) {
@@ -210,9 +211,9 @@ static void btResAndFindTest(BT btlo, BT bthi, Count btSize,
210 211
211static void btSingleResTest(BT btlo, BT bthi, Count btSize, 212static void btSingleResTest(BT btlo, BT bthi, Count btSize,
212 Index base, Index limit, 213 Index base, Index limit,
213 unsigned long length) 214 Count length)
214{ 215{
215 unsigned long resLen; 216 Count resLen;
216 /* choose varying range lengths from too short to longer than needed */ 217 /* choose varying range lengths from too short to longer than needed */
217 for (resLen = length - 1; resLen <= length + 1; resLen++) { 218 for (resLen = length - 1; resLen <= length + 1; resLen++) {
218 if ((resLen > 0) && (resLen < (limit - base -2))) { 219 if ((resLen > 0) && (resLen < (limit - base -2))) {
@@ -257,7 +258,7 @@ typedef unsigned Arrangement;
257/* Choose a limit for reset range 1 */ 258/* Choose a limit for reset range 1 */
258static Index btArrangeRes1(Arrangement arrange, 259static Index btArrangeRes1(Arrangement arrange,
259 Index base, Index res2Base, 260 Index base, Index res2Base,
260 unsigned long length) 261 Count length)
261{ 262{
262 switch (arrange) { 263 switch (arrange) {
263 264
@@ -295,7 +296,7 @@ typedef unsigned Pattern;
295/* Choose a limit for reset range 1 */ 296/* Choose a limit for reset range 1 */
296static void btResetFirstRange(BT btlo, BT bthi, Count btSize, 297static void btResetFirstRange(BT btlo, BT bthi, Count btSize,
297 Index res1Limit, 298 Index res1Limit,
298 unsigned long length, 299 Count length,
299 Pattern pattern) 300 Pattern pattern)
300{ 301{
301 switch (pattern) { 302 switch (pattern) {
@@ -329,9 +330,9 @@ static void btResetFirstRange(BT btlo, BT bthi, Count btSize,
329 330
330static void btDoubleResTest(BT btlo, BT bthi, Count btSize, 331static void btDoubleResTest(BT btlo, BT bthi, Count btSize,
331 Index base, Index limit, 332 Index base, Index limit,
332 unsigned long length) 333 Count length)
333{ 334{
334 unsigned long res2Len; 335 Count res2Len;
335 336
336 if (length < 2) 337 if (length < 2)
337 return; /* no possibility of making the first range too small */ 338 return; /* no possibility of making the first range too small */
@@ -371,7 +372,7 @@ static void btDoubleResTest(BT btlo, BT bthi, Count btSize,
371 372
372static void btFindRangeTests(BT btlo, BT bthi, Count btSize, 373static void btFindRangeTests(BT btlo, BT bthi, Count btSize,
373 Index base, Index limit, 374 Index base, Index limit,
374 unsigned long length) 375 Count length)
375{ 376{
376 btAllResTest(btlo, bthi, btSize, base, limit, length); 377 btAllResTest(btlo, bthi, btSize, base, limit, length);
377 btNoResTest(btlo, bthi, btSize, base, limit, length); 378 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)
174 Bool b = BTFindShortResRange(&base, &limit, bt, 174 Bool b = BTFindShortResRange(&base, &limit, bt,
175 args[1], args[2], args[0]); 175 args[1], args[2], args[0]);
176 if (b) 176 if (b)
177 printf("%lu - %lu\n",base, limit); 177 printf("%"PRIuLONGEST" - %"PRIuLONGEST"\n",
178 (ulongest_t)base, (ulongest_t)limit);
178 else 179 else
179 printf("FALSE\n"); 180 printf("FALSE\n");
180 } 181 }
@@ -192,7 +193,8 @@ static void findShortResRangeHigh(void)
192 Bool b = BTFindShortResRangeHigh(&base, &limit, bt, 193 Bool b = BTFindShortResRangeHigh(&base, &limit, bt,
193 args[1], args[2], args[0]); 194 args[1], args[2], args[0]);
194 if (b) 195 if (b)
195 printf("%lu - %lu\n",base, limit); 196 printf("%"PRIuLONGEST" - %"PRIuLONGEST"\n",
197 (ulongest_t)base, (ulongest_t)limit);
196 else 198 else
197 printf("FALSE\n"); 199 printf("FALSE\n");
198 } 200 }
@@ -209,7 +211,8 @@ static void findLongResRange(void)
209 Bool b = BTFindLongResRange(&base, &limit, bt, 211 Bool b = BTFindLongResRange(&base, &limit, bt,
210 args[1], args[2], args[0]); 212 args[1], args[2], args[0]);
211 if (b) 213 if (b)
212 printf("%lu - %lu\n",base, limit); 214 printf("%"PRIuLONGEST" - %"PRIuLONGEST"\n",
215 (ulongest_t)base, (ulongest_t)limit);
213 else 216 else
214 printf("FALSE\n"); 217 printf("FALSE\n");
215 } 218 }
diff --git a/mps/code/cbs.c b/mps/code/cbs.c
index 73474a02de9..e3f5204e03e 100644
--- a/mps/code/cbs.c
+++ b/mps/code/cbs.c
@@ -194,36 +194,32 @@ static Compare cbsSplayCompare(void *key, SplayNode node)
194/* cbsTestNode, cbsTestTree -- test for nodes larger than the S parameter */ 194/* cbsTestNode, cbsTestTree -- test for nodes larger than the S parameter */
195 195
196static Bool cbsTestNode(SplayTree tree, SplayNode node, 196static Bool cbsTestNode(SplayTree tree, SplayNode node,
197 void *closureP, unsigned long closureS) 197 void *closureP, Size size)
198{ 198{
199 Size size;
200 CBSBlock block; 199 CBSBlock block;
201 200
202 AVERT(SplayTree, tree); 201 AVERT(SplayTree, tree);
203 AVERT(SplayNode, node); 202 AVERT(SplayNode, node);
204 AVER(closureP == NULL); 203 AVER(closureP == NULL);
205 AVER(closureS > 0); 204 AVER(size > 0);
206 AVER(cbsOfSplayTree(tree)->fastFind); 205 AVER(cbsOfSplayTree(tree)->fastFind);
207 206
208 size = (Size)closureS;
209 block = cbsBlockOfSplayNode(node); 207 block = cbsBlockOfSplayNode(node);
210 208
211 return CBSBlockSize(block) >= size; 209 return CBSBlockSize(block) >= size;
212} 210}
213 211
214static Bool cbsTestTree(SplayTree tree, SplayNode node, 212static Bool cbsTestTree(SplayTree tree, SplayNode node,
215 void *closureP, unsigned long closureS) 213 void *closureP, Size size)
216{ 214{
217 Size size;
218 CBSBlock block; 215 CBSBlock block;
219 216
220 AVERT(SplayTree, tree); 217 AVERT(SplayTree, tree);
221 AVERT(SplayNode, node); 218 AVERT(SplayNode, node);
222 AVER(closureP == NULL); 219 AVER(closureP == NULL);
223 AVER(closureS > 0); 220 AVER(size > 0);
224 AVER(cbsOfSplayTree(tree)->fastFind); 221 AVER(cbsOfSplayTree(tree)->fastFind);
225 222
226 size = (Size)closureS;
227 block = cbsBlockOfSplayNode(node); 223 block = cbsBlockOfSplayNode(node);
228 224
229 return block->maxSize >= size; 225 return block->maxSize >= size;
@@ -1384,7 +1380,6 @@ Bool CBSFindFirst(Addr *baseReturn, Addr *limitReturn,
1384 AVER(baseReturn != NULL); 1380 AVER(baseReturn != NULL);
1385 AVER(limitReturn != NULL); 1381 AVER(limitReturn != NULL);
1386 AVER(size > 0); 1382 AVER(size > 0);
1387 AVER(sizeof(unsigned long) >= sizeof(Size));
1388 AVER(SizeIsAligned(size, cbs->alignment)); 1383 AVER(SizeIsAligned(size, cbs->alignment));
1389 AVER(cbs->fastFind); 1384 AVER(cbs->fastFind);
1390 AVERT(CBSFindDelete, findDelete); 1385 AVERT(CBSFindDelete, findDelete);
@@ -1396,7 +1391,7 @@ Bool CBSFindFirst(Addr *baseReturn, Addr *limitReturn,
1396 1391
1397 METER_ACC(cbs->splaySearch, cbs->splayTreeSize); 1392 METER_ACC(cbs->splaySearch, cbs->splayTreeSize);
1398 found = SplayFindFirst(&node, splayTreeOfCBS(cbs), &cbsTestNode, 1393 found = SplayFindFirst(&node, splayTreeOfCBS(cbs), &cbsTestNode,
1399 &cbsTestTree, NULL, (unsigned long)size); 1394 &cbsTestTree, NULL, size);
1400 1395
1401 if (found) { 1396 if (found) {
1402 CBSBlock block; 1397 CBSBlock block;
@@ -1467,7 +1462,6 @@ Bool CBSFindLast(Addr *baseReturn, Addr *limitReturn,
1467 AVER(baseReturn != NULL); 1462 AVER(baseReturn != NULL);
1468 AVER(limitReturn != NULL); 1463 AVER(limitReturn != NULL);
1469 AVER(size > 0); 1464 AVER(size > 0);
1470 AVER(sizeof(unsigned long) >= sizeof(Size));
1471 AVER(SizeIsAligned(size, cbs->alignment)); 1465 AVER(SizeIsAligned(size, cbs->alignment));
1472 AVER(cbs->fastFind); 1466 AVER(cbs->fastFind);
1473 AVERT(CBSFindDelete, findDelete); 1467 AVERT(CBSFindDelete, findDelete);
@@ -1479,7 +1473,7 @@ Bool CBSFindLast(Addr *baseReturn, Addr *limitReturn,
1479 1473
1480 METER_ACC(cbs->splaySearch, cbs->splayTreeSize); 1474 METER_ACC(cbs->splaySearch, cbs->splayTreeSize);
1481 found = SplayFindLast(&node, splayTreeOfCBS(cbs), &cbsTestNode, 1475 found = SplayFindLast(&node, splayTreeOfCBS(cbs), &cbsTestNode,
1482 &cbsTestTree, NULL, (unsigned long)size); 1476 &cbsTestTree, NULL, size);
1483 if (found) { 1477 if (found) {
1484 CBSBlock block; 1478 CBSBlock block;
1485 1479
@@ -1555,7 +1549,6 @@ Bool CBSFindLargest(Addr *baseReturn, Addr *limitReturn,
1555 1549
1556 AVER(baseReturn != NULL); 1550 AVER(baseReturn != NULL);
1557 AVER(limitReturn != NULL); 1551 AVER(limitReturn != NULL);
1558 AVER(sizeof(unsigned long) >= sizeof(Size));
1559 AVER(cbs->fastFind); 1552 AVER(cbs->fastFind);
1560 AVERT(CBSFindDelete, findDelete); 1553 AVERT(CBSFindDelete, findDelete);
1561 1554
@@ -1573,7 +1566,7 @@ Bool CBSFindLargest(Addr *baseReturn, Addr *limitReturn,
1573 size = cbsBlockOfSplayNode(root)->maxSize; 1566 size = cbsBlockOfSplayNode(root)->maxSize;
1574 METER_ACC(cbs->splaySearch, cbs->splayTreeSize); 1567 METER_ACC(cbs->splaySearch, cbs->splayTreeSize);
1575 found = SplayFindFirst(&node, splayTreeOfCBS(cbs), &cbsTestNode, 1568 found = SplayFindFirst(&node, splayTreeOfCBS(cbs), &cbsTestNode,
1576 &cbsTestTree, NULL, (unsigned long)size); 1569 &cbsTestTree, NULL, size);
1577 AVER(found); /* maxSize is exact, so we will find it. */ 1570 AVER(found); /* maxSize is exact, so we will find it. */
1578 block = cbsBlockOfSplayNode(node); 1571 block = cbsBlockOfSplayNode(node);
1579 AVER(CBSBlockSize(block) >= size); 1572 AVER(CBSBlockSize(block) >= size);
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,
501 501
502 expected = (high ? BTFindLongResRangeHigh : BTFindLongResRange) 502 expected = (high ? BTFindLongResRangeHigh : BTFindLongResRange)
503 (&expectedBase, &expectedLimit, alloc, 503 (&expectedBase, &expectedLimit, alloc,
504 (Index)0, (Index)ArraySize, (unsigned long)size); 504 (Index)0, (Index)ArraySize, (Count)size);
505 505
506 if (expected) { 506 if (expected) {
507 oldSize = (expectedLimit - expectedBase) * Alignment; 507 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 @@
20#include "ossu.h" 20#include "ossu.h"
21#endif 21#endif
22 22
23typedef unsigned long Word; 23typedef MPS_T_WORD Word;
24typedef struct AddrStruct *Addr; 24typedef struct AddrStruct *Addr;
25 25
26#include "eventcom.h" 26#include "eventcom.h"
27 27
28 28
29#ifdef MPS_PF_W3I6MV
30#define PRIuLONGEST "llu"
31#define PRIXPTR "016llX"
32typedef unsigned long long ulongest_t;
33#else
34#define PRIuLONGEST "lu"
35#define PRIXPTR "08lX"
36typedef unsigned long ulongest_t;
37#endif
38
39
29#define RELATION(type, code, always, kind, format) \ 40#define RELATION(type, code, always, kind, format) \
30 case Event ## type: \ 41 case Event ## type: \
31 readEvent(#type, #format, header[0], header[1], header[2]); \ 42 readEvent(#type, #format, header[0], header[1], header[2]); \
@@ -72,10 +83,10 @@ static void readEvent(char *type, char *format, Word code, Word length,
72 83
73 for(; *format != '\0'; format++) { 84 for(; *format != '\0'; format++) {
74 switch(*format) { 85 switch(*format) {
75 PROCESS('A', Addr, sizeof(Addr), "0x%08lX", unsigned long) 86 PROCESS('A', Addr, sizeof(Addr), "0x%"PRIXPTR, ulongest_t)
76 PROCESS('P', void *, sizeof(void *), "0x%08lX", unsigned long) 87 PROCESS('P', void *, sizeof(void *), "0x%"PRIXPTR, ulongest_t)
77 PROCESS('U', unsigned, sizeof(unsigned),"%u", unsigned) 88 PROCESS('U', unsigned, sizeof(unsigned),"%u", unsigned)
78 PROCESS('W', Word, sizeof(Word),"%lu", Word) 89 PROCESS('W', Word, sizeof(Word), "%"PRIuLONGEST, ulongest_t)
79 PROCESS('D', double, sizeof(double), "%f", double) 90 PROCESS('D', double, sizeof(double), "%f", double)
80 case 'S': { 91 case 'S': {
81 size_t n; 92 size_t n;
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 @@
11#include "eventcom.h" 11#include "eventcom.h"
12#include "eventpro.h" 12#include "eventpro.h"
13#include "mpmtypes.h" 13#include "mpmtypes.h"
14#include "testlib.h" /* for ulongest_t and associated print formats */
14 15
15#include <stddef.h> /* for size_t */ 16#include <stddef.h> /* for size_t */
16#include <stdio.h> /* for printf */ 17#include <stdio.h> /* for printf */
@@ -60,14 +61,14 @@ static Bool partialLog = FALSE;
60static Word bucketSize = 0; 61static Word bucketSize = 0;
61 62
62 63
63/* error -- error signalling */ 64/* everror -- error signalling */
64 65
65static void error(const char *format, ...) 66static void everror(const char *format, ...)
66{ 67{
67 va_list args; 68 va_list args;
68 69
69 fflush(stdout); /* sync */ 70 fflush(stdout); /* sync */
70 fprintf(stderr, "%s: @%lu ", prog, (ulong)eventTime); 71 fprintf(stderr, "%s: @%"PRIuLONGEST" ", prog, (ulongest_t)eventTime);
71 va_start(args, format); 72 va_start(args, format);
72 vfprintf(stderr, format, args); 73 vfprintf(stderr, format, args);
73 fprintf(stderr, "\n"); 74 fprintf(stderr, "\n");
@@ -92,7 +93,7 @@ static void usage(void)
92static void usageError(void) 93static void usageError(void)
93{ 94{
94 usage(); 95 usage();
95 error("Bad usage"); 96 everror("Bad usage");
96} 97}
97 98
98 99
@@ -197,7 +198,7 @@ static void processEvent(EventProc proc, Event event, Word etime)
197 198
198 res = EventRecord(proc, event, etime); 199 res = EventRecord(proc, event, etime);
199 if (res != ResOK) 200 if (res != ResOK)
200 error("Can't record event: error %d.", res); 201 everror("Can't record event: error %d.", res);
201 switch(event->any.code) { 202 switch(event->any.code) {
202 default: 203 default:
203 break; 204 break;
@@ -239,11 +240,16 @@ static void printAddr(EventProc proc, Addr addr)
239 putchar(' '); 240 putchar(' ');
240 printStr(sym, (style == 'C')); 241 printStr(sym, (style == 'C'));
241 } else { 242 } else {
242 printf((style == '\0') ? " sym%05lX" : " \"sym %lX\"", 243 printf((style == '\0') ?
243 (ulong)label); 244 " sym%05"PRIXLONGEST :
245 " \"sym %"PRIXLONGEST"\"",
246 (ulongest_t)label);
244 } 247 }
245 } else 248 } else
246 printf((style != 'C') ? " %08lX" : " %lu", (ulong)addr); 249 printf(style != 'C' ?
250 " %0"PRIwLONGEST PRIXLONGEST :
251 " %"PRIuLONGEST,
252 (ulongest_t)addr);
247} 253}
248 254
249 255
@@ -289,13 +295,13 @@ static void reportBucketResults(Word bucketLimit)
289{ 295{
290 switch (style) { 296 switch (style) {
291 case '\0': 297 case '\0':
292 printf("%8lu:", (ulong)bucketLimit); 298 printf("%8"PRIuLONGEST":", (ulongest_t)bucketLimit);
293 break; 299 break;
294 case 'L': 300 case 'L':
295 printf("(%lX", (ulong)bucketLimit); 301 printf("(%"PRIXLONGEST, (ulongest_t)bucketLimit);
296 break; 302 break;
297 case 'C': 303 case 'C':
298 printf("%lu", (ulong)bucketLimit); 304 printf("%"PRIuLONGEST, (ulongest_t)bucketLimit);
299 break; 305 break;
300 } 306 }
301 if (reportEvents) { 307 if (reportEvents) {
@@ -333,16 +339,16 @@ static void printArg(EventProc proc,
333 if (style == 'C') putchar(','); 339 if (style == 'C') putchar(',');
334 printAddr(proc, *(Addr *)arg); 340 printAddr(proc, *(Addr *)arg);
335 } else 341 } else
336 printf(styleConv, (ulong)*(Addr *)arg); 342 printf(styleConv, (ulongest_t)*(Addr *)arg);
337 } break; 343 } break;
338 case 'P': { 344 case 'P': {
339 printf(styleConv, (ulong)*(void **)arg); 345 printf(styleConv, (ulongest_t)*(void **)arg);
340 } break; 346 } break;
341 case 'U': { 347 case 'U': {
342 printf(styleConv, (ulong)*(unsigned *)arg); 348 printf(styleConv, (ulongest_t)*(unsigned *)arg);
343 } break; 349 } break;
344 case 'W': { 350 case 'W': {
345 printf(styleConv, (ulong)*(Word *)arg); 351 printf(styleConv, (ulongest_t)*(Word *)arg);
346 } break; 352 } break;
347 case 'D': { 353 case 'D': {
348 switch (style) { 354 switch (style) {
@@ -359,7 +365,7 @@ static void printArg(EventProc proc,
359 putchar(' '); 365 putchar(' ');
360 printStr((EventStringStruct *)arg, (style == 'C' || style == 'L')); 366 printStr((EventStringStruct *)arg, (style == 'C' || style == 'L'));
361 } break; 367 } break;
362 default: error("Can't print format >%c<", argType); 368 default: everror("Can't print format >%c<", argType);
363 } 369 }
364} 370}
365 371
@@ -396,13 +402,13 @@ static void readLog(EventProc proc)
396 /* Init style. */ 402 /* Init style. */
397 switch (style) { 403 switch (style) {
398 case '\0': 404 case '\0':
399 styleConv = " %8lX"; break; 405 styleConv = " %8"PRIXLONGEST; break;
400 case 'C': 406 case 'C':
401 styleConv = ", %lu"; break; 407 styleConv = ", %"PRIuLONGEST; break;
402 case 'L': 408 case 'L':
403 styleConv = " %lX"; break; 409 styleConv = " %"PRIXLONGEST; break;
404 default: 410 default:
405 error("Unknown style code '%c'", style); 411 everror("Unknown style code '%c'", style);
406 } 412 }
407 413
408 while (TRUE) { /* loop for each event */ 414 while (TRUE) { /* loop for each event */
@@ -415,7 +421,7 @@ static void readLog(EventProc proc)
415 /* Read and parse event. */ 421 /* Read and parse event. */
416 res = EventRead(&event, proc); 422 res = EventRead(&event, proc);
417 if (res == ResFAIL) break; /* eof */ 423 if (res == ResFAIL) break; /* eof */
418 if (res != ResOK) error("Truncated log"); 424 if (res != ResOK) everror("Truncated log");
419 eventTime = event->any.clock; 425 eventTime = event->any.clock;
420 code = EventGetCode(event); 426 code = EventGetCode(event);
421 427
@@ -451,11 +457,11 @@ static void readLog(EventProc proc)
451 457
452 switch (style) { 458 switch (style) {
453 case '\0': 459 case '\0':
454 printf(" %8lu", (ulong)eventTime); break; 460 printf(" %8"PRIuLONGEST, (ulongest_t)eventTime); break;
455 case 'C': 461 case 'C':
456 printf(", %lu", (ulong)eventTime); break; 462 printf(", %"PRIuLONGEST, (ulongest_t)eventTime); break;
457 case 'L': 463 case 'L':
458 printf(" %lX", (ulong)eventTime); break; 464 printf(" %"PRIXLONGEST, (ulongest_t)eventTime); break;
459 } 465 }
460 466
461 switch (event->any.code) { 467 switch (event->any.code) {
@@ -463,17 +469,23 @@ static void readLog(EventProc proc)
463 switch (style) { 469 switch (style) {
464 case '\0': case 'C': { 470 case '\0': case 'C': {
465 EventString sym = LabelText(proc, event->aw.w1); 471 EventString sym = LabelText(proc, event->aw.w1);
466 printf((style == '\0') ? " %08lX " : ", %lu, ", 472 printf(style == '\0' ?
467 (ulong)event->aw.a0); 473 " %08"PRIXLONGEST" " :
474 ", %"PRIuLONGEST", ",
475 (ulongest_t)event->aw.a0);
468 if (sym != NULL) { 476 if (sym != NULL) {
469 printStr(sym, (style == 'C')); 477 printStr(sym, (style == 'C'));
470 } else { 478 } else {
471 printf((style == '\0') ? "sym %05lX" : "sym %lX\"", 479 printf(style == '\0' ?
472 (ulong)event->aw.w1); 480 "sym %05"PRIXLONGEST :
481 "sym %"PRIXLONGEST"\"",
482 (ulongest_t)event->aw.w1);
473 } 483 }
474 } break; 484 } break;
475 case 'L': { 485 case 'L': {
476 printf(" %lX %lX", (ulong)event->aw.a0, (ulong)event->aw.w1); 486 printf(" %"PRIXLONGEST" %"PRIXLONGEST,
487 (ulongest_t)event->aw.a0,
488 (ulongest_t)event->aw.w1);
477 } break; 489 } break;
478 } 490 }
479 } break; 491 } break;
@@ -481,16 +493,16 @@ static void readLog(EventProc proc)
481 switch (style) { 493 switch (style) {
482 case '\0': { 494 case '\0': {
483 if (event->pddwww.w3 == 0) { 495 if (event->pddwww.w3 == 0) {
484 printf(" %08lX 0 N/A N/A N/A N/A", 496 printf(" %08"PRIXLONGEST" 0 N/A N/A N/A N/A",
485 (ulong)event->pddwww.p0); 497 (ulongest_t)event->pddwww.p0);
486 } else { 498 } else {
487 double mean = event->pddwww.d1 / (double)event->pddwww.w3; 499 double mean = event->pddwww.d1 / (double)event->pddwww.w3;
488 /* .stddev: stddev = sqrt(meanSquared - mean^2), but see */ 500 /* .stddev: stddev = sqrt(meanSquared - mean^2), but see */
489 /* <code/meter.c#limitation.variance>. */ 501 /* <code/meter.c#limitation.variance>. */
490 double stddev = sqrt(fabs(event->pddwww.d2 502 double stddev = sqrt(fabs(event->pddwww.d2
491 - (mean * mean))); 503 - (mean * mean)));
492 printf(" %08lX %8u %8u %8u %#8.3g %#8.3g", 504 printf(" %08"PRIXLONGEST" %8u %8u %8u %#8.3g %#8.3g",
493 (ulong)event->pddwww.p0, (uint)event->pddwww.w3, 505 (ulongest_t)event->pddwww.p0, (uint)event->pddwww.w3,
494 (uint)event->pddwww.w4, (uint)event->pddwww.w5, 506 (uint)event->pddwww.w4, (uint)event->pddwww.w5,
495 mean, stddev); 507 mean, stddev);
496 } 508 }
@@ -505,7 +517,8 @@ static void readLog(EventProc proc)
505 (uint)event->pddwww.w5); 517 (uint)event->pddwww.w5);
506 } break; 518 } break;
507 case 'L': { 519 case 'L': {
508 printf(" %lX %#.10G %#.10G %X %X %X", (ulong)event->pddwww.p0, 520 printf(" %"PRIXLONGEST" %#.10G %#.10G %X %X %X",
521 (ulongest_t)event->pddwww.p0,
509 event->pddwww.d1, event->pddwww.d2, 522 event->pddwww.d1, event->pddwww.d2,
510 (uint)event->pddwww.w3, (uint)event->pddwww.w4, 523 (uint)event->pddwww.w3, (uint)event->pddwww.w4,
511 (uint)event->pddwww.w5); 524 (uint)event->pddwww.w5);
@@ -513,14 +526,14 @@ static void readLog(EventProc proc)
513 } 526 }
514 } break; 527 } break;
515 case EventPoolInit: { /* pool, arena, class */ 528 case EventPoolInit: { /* pool, arena, class */
516 printf(styleConv, (ulong)event->ppp.p0); 529 printf(styleConv, (ulongest_t)event->ppp.p0);
517 printf(styleConv, (ulong)event->ppp.p1); 530 printf(styleConv, (ulongest_t)event->ppp.p1);
518 /* class is a Pointer, but we label them, so call printAddr */ 531 /* class is a Pointer, but we label them, so call printAddr */
519 if (style != 'L') { 532 if (style != 'L') {
520 if (style == 'C') putchar(','); 533 if (style == 'C') putchar(',');
521 printAddr(proc, (Addr)event->ppp.p2); 534 printAddr(proc, (Addr)event->ppp.p2);
522 } else 535 } else
523 printf(styleConv, (ulong)event->ppp.p2); 536 printf(styleConv, (ulongest_t)event->ppp.p2);
524 } break; 537 } break;
525 default: 538 default:
526 for (i = 0; i < argCount; ++i) { 539 for (i = 0; i < argCount; ++i) {
@@ -565,7 +578,7 @@ static void readLog(EventProc proc)
565 if (eventEnabled[c]) 578 if (eventEnabled[c])
566 printf(" %04X %s\n", (unsigned)c, EventCode2Name(c)); 579 printf(" %04X %s\n", (unsigned)c, EventCode2Name(c));
567 if (bucketSize == 0) 580 if (bucketSize == 0)
568 printf("\nevent clock stopped at %lu\n", (ulong)eventTime); 581 printf("\nevent clock stopped at %"PRIuLONGEST"\n", (ulongest_t)eventTime);
569 } 582 }
570 } 583 }
571} 584}
@@ -602,9 +615,9 @@ int main(int argc, char *argv[])
602 /* GCC -ansi -pedantic -Werror on FreeBSD will fail here 615 /* GCC -ansi -pedantic -Werror on FreeBSD will fail here
603 * with the warning "statement with no effect". */ 616 * with the warning "statement with no effect". */
604 617
605 assert(CHECKCONV(ulong, Word)); 618 assert(CHECKCONV(ulongest_t, Word));
606 assert(CHECKCONV(ulong, Addr)); 619 assert(CHECKCONV(ulongest_t, Addr));
607 assert(CHECKCONV(ulong, void *)); 620 assert(CHECKCONV(ulongest_t, void *));
608 assert(CHECKCONV(unsigned, EventCode)); 621 assert(CHECKCONV(unsigned, EventCode));
609 assert(CHECKCONV(Addr, void *)); /* for labelled pointers */ 622 assert(CHECKCONV(Addr, void *)); /* for labelled pointers */
610#endif 623#endif
@@ -616,12 +629,12 @@ int main(int argc, char *argv[])
616 else { 629 else {
617 input = fopen(filename, "rb"); 630 input = fopen(filename, "rb");
618 if (input == NULL) 631 if (input == NULL)
619 error("unable to open \"%s\"\n", filename); 632 everror("unable to open \"%s\"\n", filename);
620 } 633 }
621 634
622 res = EventProcCreate(&proc, partialLog, logReader, (void *)input); 635 res = EventProcCreate(&proc, partialLog, logReader, (void *)input);
623 if (res != ResOK) 636 if (res != ResOK)
624 error("Can't init EventProc module: error %d.", res); 637 everror("Can't init EventProc module: error %d.", res);
625 638
626 readLog(proc); 639 readLog(proc);
627 640
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 @@
34#endif 34#endif
35 35
36 36
37#ifdef MPS_PF_W3I6MV
38#define PRIuLONGEST "llu"
39#define PRIXPTR "016llX"
40typedef unsigned long long ulongest_t;
41#else
42#define PRIuLONGEST "lu"
43#define PRIXPTR "08lX"
44typedef unsigned long ulongest_t;
45#endif
46
47
37typedef unsigned long ulong; 48typedef unsigned long ulong;
38 49
39 50
@@ -114,7 +125,7 @@ static void error(const char *format, ...)
114 va_list args; 125 va_list args;
115 126
116 fflush(stdout); /* sync */ 127 fflush(stdout); /* sync */
117 fprintf(stderr, "Failed @%lu ", (ulong)eventTime); 128 fprintf(stderr, "Failed @%"PRIuLONGEST" ", (ulongest_t)eventTime);
118 va_start(args, format); 129 va_start(args, format);
119 vfprintf(stderr, format, args); 130 vfprintf(stderr, format, args);
120 fprintf(stderr, "\n"); 131 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)
69 not_condemned = mps_message_gc_not_condemned_size(arena, message); 69 not_condemned = mps_message_gc_not_condemned_size(arena, message);
70 70
71 printf("\nCollection %d finished:\n", ++nCollections); 71 printf("\nCollection %d finished:\n", ++nCollections);
72 printf("live %lu\n", (unsigned long)live); 72 printf("live %"PRIuLONGEST"\n", (ulongest_t)live);
73 printf("condemned %lu\n", (unsigned long)condemned); 73 printf("condemned %"PRIuLONGEST"\n", (ulongest_t)condemned);
74 printf("not_condemned %lu\n", (unsigned long)not_condemned); 74 printf("not_condemned %"PRIuLONGEST"\n", (ulongest_t)not_condemned);
75 75
76 mps_message_discard(arena, message); 76 mps_message_discard(arena, message);
77 77
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)
133 printf("\nResults for "); 133 printf("\nResults for ");
134 fputs(name, stdout); 134 fputs(name, stdout);
135 printf("\n"); 135 printf("\n");
136 printf(" Allocated %lu objects\n", (unsigned long)stat->aCount); 136 printf(" Allocated %"PRIuLONGEST" objects\n", (ulongest_t)stat->aCount);
137 printf(" Freed %lu objects\n", (unsigned long)stat->fCount); 137 printf(" Freed %"PRIuLONGEST" objects\n", (ulongest_t)stat->fCount);
138 printf(" There were %lu non-contiguous allocations\n", 138 printf(" There were %lu non-contiguous allocations\n",
139 (unsigned long)stat->ncCount); 139 (unsigned long)stat->ncCount);
140 printf(" Address range from %p to %p\n", 140 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)
137 printf("\nResults for "); 137 printf("\nResults for ");
138 printf("%s", name); 138 printf("%s", name);
139 printf("\n"); 139 printf("\n");
140 printf(" Allocated %lu objects\n", (unsigned long)stat->aCount); 140 printf(" Allocated %"PRIuLONGEST" objects\n", (ulongest_t)stat->aCount);
141 printf(" Freed %lu objects\n", (unsigned long)stat->fCount); 141 printf(" Freed %"PRIuLONGEST" objects\n", (ulongest_t)stat->fCount);
142 printf(" There were %lu non-contiguous allocations\n", 142 printf(" There were %lu non-contiguous allocations\n",
143 (unsigned long)stat->ncCount); 143 (unsigned long)stat->ncCount);
144 printf(" Address range from %p to %p\n", stat->min, stat->max); 144 printf(" Address range from %p to %p\n", stat->min, stat->max);
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)
218} 218}
219 219
220 220
221/* WriteWord -- output a textual representation of a word to a stream 221/* WriteULongest -- output a textual representation of an integer to a stream
222 * 222 *
223 * Output as an unsigned value in the given base (2-16), padded to the 223 * Output as an unsigned value in the given base (2-16), padded to the
224 * given width. */ 224 * given width. */
225 225
226static Res WriteWord(mps_lib_FILE *stream, Word w, unsigned base, 226static Res WriteULongest(mps_lib_FILE *stream, ULongest w, unsigned base,
227 unsigned width) 227 unsigned width)
228{ 228{
229 static const char digit[16 + 1] = "0123456789ABCDEF"; 229 static const char digit[16 + 1] = "0123456789ABCDEF";
230 /* + 1 for terminator: unused, but prevents compiler warning */ 230 /* + 1 for terminator: unused, but prevents compiler warning */
@@ -412,7 +412,7 @@ static Res WriteDouble(mps_lib_FILE *stream, double d)
412 * .writef.des: See <design/writef/>, also <design/lib/> 412 * .writef.des: See <design/writef/>, also <design/lib/>
413 * 413 *
414 * .writef.p: There is an assumption that void * fits in Word in 414 * .writef.p: There is an assumption that void * fits in Word in
415 * the case of $P, and unsigned long for $U and $B. This is checked in 415 * the case of $P, and ULongest for $U and $B. This is checked in
416 * MPMCheck. 416 * MPMCheck.
417 * 417 *
418 * .writef.div: Although MPS_WORD_WIDTH/4 appears three times, there 418 * .writef.div: Although MPS_WORD_WIDTH/4 appears three times, there
@@ -469,15 +469,15 @@ Res WriteF_firstformat_v(mps_lib_FILE *stream,
469 switch(*format) { 469 switch(*format) {
470 case 'A': { /* address */ 470 case 'A': { /* address */
471 WriteFA addr = va_arg(args, WriteFA); 471 WriteFA addr = va_arg(args, WriteFA);
472 res = WriteWord(stream, (Word)addr, 16, 472 res = WriteULongest(stream, (ULongest)addr, 16,
473 (sizeof(WriteFA) * CHAR_BIT + 3) / 4); 473 (sizeof(WriteFA) * CHAR_BIT + 3) / 4);
474 if (res != ResOK) return res; 474 if (res != ResOK) return res;
475 } break; 475 } break;
476 476
477 case 'P': { /* pointer, see .writef.p */ 477 case 'P': { /* pointer, see .writef.p */
478 WriteFP p = va_arg(args, WriteFP); 478 WriteFP p = va_arg(args, WriteFP);
479 res = WriteWord(stream, (Word)p, 16, 479 res = WriteULongest(stream, (ULongest)p, 16,
480 (sizeof(WriteFP) * CHAR_BIT + 3)/ 4); 480 (sizeof(WriteFP) * CHAR_BIT + 3)/ 4);
481 if (res != ResOK) return res; 481 if (res != ResOK) return res;
482 } break; 482 } break;
483 483
@@ -486,8 +486,8 @@ Res WriteF_firstformat_v(mps_lib_FILE *stream,
486 WriteFF *fp = &f; /* dodge to placate splint */ 486 WriteFF *fp = &f; /* dodge to placate splint */
487 Byte *b = *((Byte **)&fp); 487 Byte *b = *((Byte **)&fp);
488 for(i=0; i < sizeof(WriteFF); i++) { 488 for(i=0; i < sizeof(WriteFF); i++) {
489 res = WriteWord(stream, (Word)(b[i]), 16, 489 res = WriteULongest(stream, (ULongest)(b[i]), 16,
490 (CHAR_BIT + 3) / 4); 490 (CHAR_BIT + 3) / 4);
491 if (res != ResOK) return res; 491 if (res != ResOK) return res;
492 } 492 }
493 } break; 493 } break;
@@ -506,26 +506,26 @@ Res WriteF_firstformat_v(mps_lib_FILE *stream,
506 506
507 case 'W': { /* word */ 507 case 'W': { /* word */
508 WriteFW w = va_arg(args, WriteFW); 508 WriteFW w = va_arg(args, WriteFW);
509 res = WriteWord(stream, (Word)w, 16, 509 res = WriteULongest(stream, (ULongest)w, 16,
510 (sizeof(WriteFW) * CHAR_BIT + 3) / 4); 510 (sizeof(WriteFW) * CHAR_BIT + 3) / 4);
511 if (res != ResOK) return res; 511 if (res != ResOK) return res;
512 } break; 512 } break;
513 513
514 case 'U': { /* decimal, see .writef.p */ 514 case 'U': { /* decimal, see .writef.p */
515 WriteFU u = va_arg(args, WriteFU); 515 WriteFU u = va_arg(args, WriteFU);
516 res = WriteWord(stream, (Word)u, 10, 0); 516 res = WriteULongest(stream, (ULongest)u, 10, 0);
517 if (res != ResOK) return res; 517 if (res != ResOK) return res;
518 } break; 518 } break;
519 519
520 case '3': { /* decimal for thousandths */ 520 case '3': { /* decimal for thousandths */
521 WriteFU u = va_arg(args, WriteFU); 521 WriteFU u = va_arg(args, WriteFU);
522 res = WriteWord(stream, (Word)u, 10, 3); 522 res = WriteULongest(stream, (ULongest)u, 10, 3);
523 if (res != ResOK) return res; 523 if (res != ResOK) return res;
524 } break; 524 } break;
525 525
526 case 'B': { /* binary, see .writef.p */ 526 case 'B': { /* binary, see .writef.p */
527 WriteFB b = va_arg(args, WriteFB); 527 WriteFB b = va_arg(args, WriteFB);
528 res = WriteWord(stream, (Word)b, 2, sizeof(WriteFB) * CHAR_BIT); 528 res = WriteULongest(stream, (ULongest)b, 2, sizeof(WriteFB) * CHAR_BIT);
529 if (res != ResOK) return res; 529 if (res != ResOK) return res;
530 } break; 530 } break;
531 531
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);
213extern void PoolReclaim(Pool pool, Trace trace, Seg seg); 213extern void PoolReclaim(Pool pool, Trace trace, Seg seg);
214extern void PoolTraceEnd(Pool pool, Trace trace); 214extern void PoolTraceEnd(Pool pool, Trace trace);
215extern void PoolWalk(Pool pool, Seg seg, FormattedObjectsStepMethod f, 215extern void PoolWalk(Pool pool, Seg seg, FormattedObjectsStepMethod f,
216 void *v, unsigned long s); 216 void *v, size_t s);
217extern void PoolFreeWalk(Pool pool, FreeBlockStepMethod f, void *p); 217extern void PoolFreeWalk(Pool pool, FreeBlockStepMethod f, void *p);
218extern Res PoolTrivInit(Pool pool, va_list arg); 218extern Res PoolTrivInit(Pool pool, va_list arg);
219extern void PoolTrivFinish(Pool pool); 219extern void PoolTrivFinish(Pool pool);
@@ -262,7 +262,7 @@ extern Res PoolNoFramePop(Pool pool, Buffer buf, AllocFrame frame);
262extern Res PoolTrivFramePop(Pool pool, Buffer buf, AllocFrame frame); 262extern Res PoolTrivFramePop(Pool pool, Buffer buf, AllocFrame frame);
263extern void PoolNoFramePopPending(Pool pool, Buffer buf, AllocFrame frame); 263extern void PoolNoFramePopPending(Pool pool, Buffer buf, AllocFrame frame);
264extern void PoolNoWalk(Pool pool, Seg seg, FormattedObjectsStepMethod step, 264extern void PoolNoWalk(Pool pool, Seg seg, FormattedObjectsStepMethod step,
265 void *p, unsigned long s); 265 void *p, size_t s);
266extern void PoolNoFreeWalk(Pool pool, FreeBlockStepMethod f, void *p); 266extern void PoolNoFreeWalk(Pool pool, FreeBlockStepMethod f, void *p);
267extern PoolDebugMixin PoolNoDebugMixin(Pool pool); 267extern PoolDebugMixin PoolNoDebugMixin(Pool pool);
268extern BufferClass PoolNoBufferClass(void); 268extern BufferClass PoolNoBufferClass(void);
diff --git a/mps/code/mpmtypes.h b/mps/code/mpmtypes.h
index 056ac0d2ec9..09a754e09e0 100644
--- a/mps/code/mpmtypes.h
+++ b/mps/code/mpmtypes.h
@@ -41,6 +41,7 @@ typedef unsigned Serial; /* <design/type/#serial> */
41typedef Addr Ref; /* <design/type/#ref> */ 41typedef Addr Ref; /* <design/type/#ref> */
42typedef void *Pointer; /* <design/type/#pointer> */ 42typedef void *Pointer; /* <design/type/#pointer> */
43typedef unsigned long Clock; /* processor time */ 43typedef unsigned long Clock; /* processor time */
44typedef MPS_T_ULONGEST ULongest; /* <design/type/#ulongest> */
44 45
45typedef Word RefSet; /* design.mps.refset */ 46typedef Word RefSet; /* design.mps.refset */
46typedef Word ZoneSet; /* design.mps.refset */ 47typedef Word ZoneSet; /* design.mps.refset */
@@ -131,7 +132,7 @@ typedef Res (*TraceFixMethod)(ScanState ss, Ref *refIO);
131 132
132/* This type is used by the PoolClass method Walk */ 133/* This type is used by the PoolClass method Walk */
133typedef void (*FormattedObjectsStepMethod)(Addr obj, Format fmt, Pool pool, 134typedef void (*FormattedObjectsStepMethod)(Addr obj, Format fmt, Pool pool,
134 void *v, unsigned long s); 135 void *v, size_t s);
135 136
136/* This type is used by the PoolClass method Walk */ 137/* This type is used by the PoolClass method Walk */
137typedef void (*FreeBlockStepMethod)(Addr base, Addr limit, Pool pool, void *p); 138typedef void (*FreeBlockStepMethod)(Addr base, Addr limit, Pool pool, void *p);
@@ -210,7 +211,7 @@ typedef void (*PoolFramePopPendingMethod)(Pool pool, Buffer buf,
210 AllocFrame frame); 211 AllocFrame frame);
211typedef void (*PoolWalkMethod)(Pool pool, Seg seg, 212typedef void (*PoolWalkMethod)(Pool pool, Seg seg,
212 FormattedObjectsStepMethod f, 213 FormattedObjectsStepMethod f,
213 void *v, unsigned long s); 214 void *v, size_t s);
214typedef void (*PoolFreeWalkMethod)(Pool pool, FreeBlockStepMethod f, void *p); 215typedef void (*PoolFreeWalkMethod)(Pool pool, FreeBlockStepMethod f, void *p);
215typedef BufferClass (*PoolBufferClassMethod)(void); 216typedef BufferClass (*PoolBufferClassMethod)(void);
216typedef Res (*PoolDescribeMethod)(Pool pool, mps_lib_FILE *stream); 217typedef Res (*PoolDescribeMethod)(Pool pool, mps_lib_FILE *stream);
@@ -441,8 +442,8 @@ typedef Addr WriteFA;
441typedef Pointer WriteFP; 442typedef Pointer WriteFP;
442typedef const char *WriteFS; 443typedef const char *WriteFS;
443typedef Word WriteFW; 444typedef Word WriteFW;
444typedef unsigned long WriteFU; 445typedef ULongest WriteFU;
445typedef unsigned long WriteFB; 446typedef ULongest WriteFB;
446typedef void *(*WriteFF)(void); 447typedef void *(*WriteFF)(void);
447typedef int WriteFC; /* Promoted */ 448typedef int WriteFC; /* Promoted */
448typedef double WriteFD; 449typedef double WriteFD;
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 @@
16#include <limits.h> 16#include <limits.h>
17 17
18 18
19/* Platform Dependencies */
20
21#define MPS_T_WORD unsigned long /* won't be true on W3I6MV */
22
23
19/* Abstract Types */ 24/* Abstract Types */
20 25
21typedef struct mps_arena_s *mps_arena_t; /* arena */ 26typedef struct mps_arena_s *mps_arena_t; /* arena */
@@ -39,7 +44,7 @@ typedef struct mps_frame_s
39 44
40/* Concrete Types */ 45/* Concrete Types */
41 46
42typedef unsigned long mps_word_t; /* pointer-sized word */ 47typedef MPS_T_WORD mps_word_t; /* pointer-sized word */
43typedef int mps_bool_t; /* boolean (int) */ 48typedef int mps_bool_t; /* boolean (int) */
44typedef int mps_res_t; /* result code (int) */ 49typedef int mps_res_t; /* result code (int) */
45typedef unsigned mps_shift_t; /* shift amount (unsigned int) */ 50typedef unsigned mps_shift_t; /* shift amount (unsigned int) */
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 @@
74#define MPS_ARCH_M2 74#define MPS_ARCH_M2
75#define MPS_BUILD_CC 75#define MPS_BUILD_CC
76#define MPS_T_WORD unsigned long 76#define MPS_T_WORD unsigned long
77#define MPS_T_ULONGEST unsigned long
77#define MPS_WORD_WIDTH 32 78#define MPS_WORD_WIDTH 32
78#define MPS_WORD_SHIFT 5 79#define MPS_WORD_SHIFT 5
79#define MPS_PF_ALIGN 8 80#define MPS_PF_ALIGN 8
@@ -91,6 +92,7 @@
91#define MPS_ARCH_M4 92#define MPS_ARCH_M4
92#define MPS_BUILD_CC 93#define MPS_BUILD_CC
93#define MPS_T_WORD unsigned long 94#define MPS_T_WORD unsigned long
95#define MPS_T_ULONGEST unsigned long
94#define MPS_WORD_WIDTH 32 96#define MPS_WORD_WIDTH 32
95#define MPS_WORD_SHIFT 5 97#define MPS_WORD_SHIFT 5
96#define MPS_PF_ALIGN 8 98#define MPS_PF_ALIGN 8
@@ -107,6 +109,7 @@
107#define MPS_ARCH_AL 109#define MPS_ARCH_AL
108#define MPS_BUILD_MV 110#define MPS_BUILD_MV
109#define MPS_T_WORD unsigned long 111#define MPS_T_WORD unsigned long
112#define MPS_T_ULONGEST unsigned long
110#define MPS_WORD_WIDTH 32 113#define MPS_WORD_WIDTH 32
111#define MPS_WORD_SHIFT 5 114#define MPS_WORD_SHIFT 5
112#define MPS_PF_ALIGN 4 115#define MPS_PF_ALIGN 4
@@ -123,6 +126,7 @@
123#define MPS_ARCH_PP 126#define MPS_ARCH_PP
124#define MPS_BUILD_MV 127#define MPS_BUILD_MV
125#define MPS_T_WORD unsigned long 128#define MPS_T_WORD unsigned long
129#define MPS_T_ULONGEST unsigned long
126#define MPS_WORD_WIDTH 32 130#define MPS_WORD_WIDTH 32
127#define MPS_WORD_SHIFT 5 131#define MPS_WORD_SHIFT 5
128#define MPS_PF_ALIGN 4 132#define MPS_PF_ALIGN 4
@@ -145,6 +149,7 @@
145#define MPS_ARCH_I3 149#define MPS_ARCH_I3
146#define MPS_BUILD_MV 150#define MPS_BUILD_MV
147#define MPS_T_WORD unsigned long 151#define MPS_T_WORD unsigned long
152#define MPS_T_ULONGEST unsigned long
148#define MPS_WORD_WIDTH 32 153#define MPS_WORD_WIDTH 32
149#define MPS_WORD_SHIFT 5 154#define MPS_WORD_SHIFT 5
150#define MPS_PF_ALIGN 8 155#define MPS_PF_ALIGN 8
@@ -163,6 +168,7 @@
163#define MPS_ARCH_60 168#define MPS_ARCH_60
164#define MPS_BUILD_MW 169#define MPS_BUILD_MW
165#define MPS_T_WORD unsigned long 170#define MPS_T_WORD unsigned long
171#define MPS_T_ULONGEST unsigned long
166#define MPS_WORD_WIDTH 32 172#define MPS_WORD_WIDTH 32
167#define MPS_WORD_SHIFT 5 173#define MPS_WORD_SHIFT 5
168#define MPS_PF_ALIGN 1 174#define MPS_PF_ALIGN 1
@@ -181,6 +187,7 @@
181#define MPS_ARCH_PP 187#define MPS_ARCH_PP
182#define MPS_BUILD_MW 188#define MPS_BUILD_MW
183#define MPS_T_WORD unsigned long 189#define MPS_T_WORD unsigned long
190#define MPS_T_ULONGEST unsigned long
184#define MPS_WORD_WIDTH 32 191#define MPS_WORD_WIDTH 32
185#define MPS_WORD_SHIFT 5 192#define MPS_WORD_SHIFT 5
186#define MPS_PF_ALIGN 8 /* .macos.ppc.align */ 193#define MPS_PF_ALIGN 8 /* .macos.ppc.align */
@@ -201,6 +208,7 @@
201#define MPS_ARCH_60 208#define MPS_ARCH_60
202#define MPS_BUILD_AC 209#define MPS_BUILD_AC
203#define MPS_T_WORD unsigned long 210#define MPS_T_WORD unsigned long
211#define MPS_T_ULONGEST unsigned long
204#define MPS_WORD_WIDTH 32 212#define MPS_WORD_WIDTH 32
205#define MPS_WORD_SHIFT 5 213#define MPS_WORD_SHIFT 5
206#define MPS_PF_ALIGN 1 214#define MPS_PF_ALIGN 1
@@ -221,6 +229,7 @@
221#define MPS_ARCH_PP 229#define MPS_ARCH_PP
222#define MPS_BUILD_AC 230#define MPS_BUILD_AC
223#define MPS_T_WORD unsigned long 231#define MPS_T_WORD unsigned long
232#define MPS_T_ULONGEST unsigned long
224#define MPS_WORD_WIDTH 32 233#define MPS_WORD_WIDTH 32
225#define MPS_WORD_SHIFT 5 234#define MPS_WORD_SHIFT 5
226#define MPS_PF_ALIGN 8 /* .macos.ppc.align */ 235#define MPS_PF_ALIGN 8 /* .macos.ppc.align */
@@ -241,6 +250,7 @@
241#define MPS_ARCH_PP 250#define MPS_ARCH_PP
242#define MPS_BUILD_GC 251#define MPS_BUILD_GC
243#define MPS_T_WORD unsigned long 252#define MPS_T_WORD unsigned long
253#define MPS_T_ULONGEST unsigned long
244#define MPS_WORD_WIDTH 32 254#define MPS_WORD_WIDTH 32
245#define MPS_WORD_SHIFT 5 255#define MPS_WORD_SHIFT 5
246#define MPS_PF_ALIGN 8 /* .macos.ppc.align */ 256#define MPS_PF_ALIGN 8 /* .macos.ppc.align */
@@ -261,6 +271,7 @@
261#define MPS_ARCH_I3 271#define MPS_ARCH_I3
262#define MPS_BUILD_GC 272#define MPS_BUILD_GC
263#define MPS_T_WORD unsigned long 273#define MPS_T_WORD unsigned long
274#define MPS_T_ULONGEST unsigned long
264#define MPS_WORD_WIDTH 32 275#define MPS_WORD_WIDTH 32
265#define MPS_WORD_SHIFT 5 276#define MPS_WORD_SHIFT 5
266#define MPS_PF_ALIGN 4 /* I'm just guessing. */ 277#define MPS_PF_ALIGN 4 /* I'm just guessing. */
@@ -278,6 +289,7 @@
278#define MPS_ARCH_S8 289#define MPS_ARCH_S8
279#define MPS_BUILD_GC 290#define MPS_BUILD_GC
280#define MPS_T_WORD unsigned long 291#define MPS_T_WORD unsigned long
292#define MPS_T_ULONGEST unsigned long
281#define MPS_WORD_WIDTH 32 293#define MPS_WORD_WIDTH 32
282#define MPS_WORD_SHIFT 5 294#define MPS_WORD_SHIFT 5
283#define MPS_PF_ALIGN 8 295#define MPS_PF_ALIGN 8
@@ -295,6 +307,7 @@
295#define MPS_ARCH_S8 307#define MPS_ARCH_S8
296#define MPS_BUILD_LC 308#define MPS_BUILD_LC
297#define MPS_T_WORD unsigned long 309#define MPS_T_WORD unsigned long
310#define MPS_T_ULONGEST unsigned long
298#define MPS_WORD_WIDTH 32 311#define MPS_WORD_WIDTH 32
299#define MPS_WORD_SHIFT 5 312#define MPS_WORD_SHIFT 5
300#define MPS_PF_ALIGN 8 313#define MPS_PF_ALIGN 8
@@ -312,6 +325,7 @@
312#define MPS_ARCH_S8 325#define MPS_ARCH_S8
313#define MPS_BUILD_GC 326#define MPS_BUILD_GC
314#define MPS_T_WORD unsigned long 327#define MPS_T_WORD unsigned long
328#define MPS_T_ULONGEST unsigned long
315#define MPS_WORD_WIDTH 32 329#define MPS_WORD_WIDTH 32
316#define MPS_WORD_SHIFT 5 330#define MPS_WORD_SHIFT 5
317#define MPS_PF_ALIGN 8 331#define MPS_PF_ALIGN 8
@@ -332,6 +346,7 @@
332#define MPS_ARCH_S9 346#define MPS_ARCH_S9
333#define MPS_BUILD_SC 347#define MPS_BUILD_SC
334#define MPS_T_WORD unsigned long 348#define MPS_T_WORD unsigned long
349#define MPS_T_ULONGEST unsigned long
335#define MPS_WORD_WIDTH 32 350#define MPS_WORD_WIDTH 32
336#define MPS_WORD_SHIFT 5 351#define MPS_WORD_SHIFT 5
337#define MPS_PF_ALIGN 8 352#define MPS_PF_ALIGN 8
@@ -348,6 +363,7 @@
348#define MPS_ARCH_AL 363#define MPS_ARCH_AL
349#define MPS_BUILD_GC 364#define MPS_BUILD_GC
350#define MPS_T_WORD unsigned long 365#define MPS_T_WORD unsigned long
366#define MPS_T_ULONGEST unsigned long
351#define MPS_WORD_WIDTH 64 367#define MPS_WORD_WIDTH 64
352#define MPS_WORD_SHIFT 6 368#define MPS_WORD_SHIFT 6
353#define MPS_PF_ALIGN 8 369#define MPS_PF_ALIGN 8
@@ -364,6 +380,7 @@
364#define MPS_ARCH_AL 380#define MPS_ARCH_AL
365#define MPS_BUILD_CC 381#define MPS_BUILD_CC
366#define MPS_T_WORD unsigned long 382#define MPS_T_WORD unsigned long
383#define MPS_T_ULONGEST unsigned long
367#define MPS_WORD_WIDTH 64 384#define MPS_WORD_WIDTH 64
368#define MPS_WORD_SHIFT 6 385#define MPS_WORD_SHIFT 6
369#define MPS_PF_ALIGN 8 386#define MPS_PF_ALIGN 8
@@ -383,6 +400,7 @@
383#define MPS_ARCH_I4 400#define MPS_ARCH_I4
384#define MPS_BUILD_GC 401#define MPS_BUILD_GC
385#define MPS_T_WORD unsigned long 402#define MPS_T_WORD unsigned long
403#define MPS_T_ULONGEST unsigned long
386#define MPS_WORD_WIDTH 32 404#define MPS_WORD_WIDTH 32
387#define MPS_WORD_SHIFT 5 405#define MPS_WORD_SHIFT 5
388#define MPS_PF_ALIGN 4 406#define MPS_PF_ALIGN 4
@@ -399,6 +417,7 @@
399#define MPS_ARCH_PP 417#define MPS_ARCH_PP
400#define MPS_BUILD_GC 418#define MPS_BUILD_GC
401#define MPS_T_WORD unsigned long 419#define MPS_T_WORD unsigned long
420#define MPS_T_ULONGEST unsigned long
402#define MPS_WORD_WIDTH 32 421#define MPS_WORD_WIDTH 32
403#define MPS_WORD_SHIFT 5 422#define MPS_WORD_SHIFT 5
404#define MPS_PF_ALIGN 8 /* @@@@ not tested */ 423#define MPS_PF_ALIGN 8 /* @@@@ not tested */
@@ -416,6 +435,7 @@
416#define MPS_ARCH_I4 435#define MPS_ARCH_I4
417#define MPS_BUILD_GC 436#define MPS_BUILD_GC
418#define MPS_T_WORD unsigned long 437#define MPS_T_WORD unsigned long
438#define MPS_T_ULONGEST unsigned long
419#define MPS_WORD_WIDTH 32 439#define MPS_WORD_WIDTH 32
420#define MPS_WORD_SHIFT 5 440#define MPS_WORD_SHIFT 5
421#define MPS_PF_ALIGN 4 441#define MPS_PF_ALIGN 4
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,
236 236
237 if (verbose) { 237 if (verbose) {
238 if(i && i%4==0) putchar('\n'); 238 if(i && i%4==0) putchar('\n');
239 printf("%8lX %6lX ", (unsigned long)ps[i], (unsigned long)ss[i]); 239 printf("%"PRIwLONGEST PRIXLONGEST" %6"PRIXLONGEST" ",
240 (ulongest_t)ps[i], (ulongest_t)ss[i]);
240 } 241 }
241 } 242 }
242 if (verbose) { 243 if (verbose) {
@@ -273,7 +274,8 @@ static mps_res_t stress(mps_class_t class, mps_arena_t arena,
273 274
274 if (verbose) { 275 if (verbose) {
275 if(i && i%4==0) putchar('\n'); 276 if(i && i%4==0) putchar('\n');
276 printf("%8lX %6lX ", (unsigned long)ps[i], (unsigned long)ss[i]); 277 printf("%"PRIwLONGEST PRIXLONGEST" %6"PRIXLONGEST" ",
278 (ulongest_t)ps[i], (ulongest_t)ss[i]);
277 } 279 }
278 } 280 }
279 if (verbose) 281 if (verbose)
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)
482/* PoolWalk -- walk objects in this segment */ 482/* PoolWalk -- walk objects in this segment */
483 483
484void PoolWalk(Pool pool, Seg seg, FormattedObjectsStepMethod f, 484void PoolWalk(Pool pool, Seg seg, FormattedObjectsStepMethod f,
485 void *p, Size s) 485 void *p, size_t s)
486{ 486{
487 AVERT(Pool, pool); 487 AVERT(Pool, pool);
488 AVERT(Seg, seg); 488 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)
621 621
622 622
623void PoolNoWalk(Pool pool, Seg seg, 623void PoolNoWalk(Pool pool, Seg seg,
624 FormattedObjectsStepMethod f, void *p, Size s) 624 FormattedObjectsStepMethod f, void *p, size_t s)
625{ 625{
626 AVERT(Pool, pool); 626 AVERT(Pool, pool);
627 AVERT(Seg, seg); 627 AVERT(Seg, seg);
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)
2251/* AMCWalk -- Apply function to (black) objects in segment */ 2251/* AMCWalk -- Apply function to (black) objects in segment */
2252 2252
2253static void AMCWalk(Pool pool, Seg seg, FormattedObjectsStepMethod f, 2253static void AMCWalk(Pool pool, Seg seg, FormattedObjectsStepMethod f,
2254 void *p, unsigned long s) 2254 void *p, size_t s)
2255{ 2255{
2256 Addr object, nextObject, limit; 2256 Addr object, nextObject, limit;
2257 AMC amc; 2257 AMC amc;
@@ -2301,7 +2301,7 @@ static void AMCWalk(Pool pool, Seg seg, FormattedObjectsStepMethod f,
2301/* amcWalkAll -- Apply a function to all (black) objects in a pool */ 2301/* amcWalkAll -- Apply a function to all (black) objects in a pool */
2302 2302
2303static void amcWalkAll(Pool pool, FormattedObjectsStepMethod f, 2303static void amcWalkAll(Pool pool, FormattedObjectsStepMethod f,
2304 void *p, unsigned long s) 2304 void *p, size_t s)
2305{ 2305{
2306 Arena arena; 2306 Arena arena;
2307 Ring ring, next, node; 2307 Ring ring, next, node;
@@ -2466,7 +2466,7 @@ typedef struct mps_amc_apply_closure_s {
2466} mps_amc_apply_closure_s; 2466} mps_amc_apply_closure_s;
2467 2467
2468static void mps_amc_apply_iter(Addr addr, Format format, Pool pool, 2468static void mps_amc_apply_iter(Addr addr, Format format, Pool pool,
2469 void *p, unsigned long s) 2469 void *p, size_t s)
2470{ 2470{
2471 mps_amc_apply_closure_s *closure = p; 2471 mps_amc_apply_closure_s *closure = p;
2472 /* Can't check addr */ 2472 /* 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,
1145/* AWLWalk -- walk all objects */ 1145/* AWLWalk -- walk all objects */
1146 1146
1147static void AWLWalk(Pool pool, Seg seg, FormattedObjectsStepMethod f, 1147static void AWLWalk(Pool pool, Seg seg, FormattedObjectsStepMethod f,
1148 void *p, unsigned long s) 1148 void *p, size_t s)
1149{ 1149{
1150 AWL awl; 1150 AWL awl;
1151 AWLSeg awlseg; 1151 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,
108 Size tablebytes; /* # bytes in each control array */ 108 Size tablebytes; /* # bytes in each control array */
109 Arena arena; 109 Arena arena;
110 /* number of bits needed in each control array */ 110 /* number of bits needed in each control array */
111 unsigned long bits; 111 Count bits;
112 void *p; 112 void *p;
113 113
114 AVERT(Seg, seg); 114 AVERT(Seg, seg);
@@ -165,7 +165,7 @@ static void loSegFinish(Seg seg)
165 Pool pool; 165 Pool pool;
166 Arena arena; 166 Arena arena;
167 Size tablesize; 167 Size tablesize;
168 unsigned long bits; 168 Count bits;
169 169
170 AVERT(Seg, seg); 170 AVERT(Seg, seg);
171 loseg = SegLOSeg(seg); 171 loseg = SegLOSeg(seg);
@@ -236,7 +236,7 @@ static Bool loSegFindFree(Addr *bReturn, Addr *lReturn,
236 Seg seg; 236 Seg seg;
237 Arena arena; 237 Arena arena;
238 Count agrains; 238 Count agrains;
239 unsigned long tablesize; 239 Count bits;
240 Addr segBase; 240 Addr segBase;
241 241
242 AVER(bReturn != NULL); 242 AVER(bReturn != NULL);
@@ -260,9 +260,9 @@ static Bool loSegFindFree(Addr *bReturn, Addr *lReturn,
260 return FALSE; 260 return FALSE;
261 } 261 }
262 262
263 tablesize = SegSize(seg) >> lo->alignShift; 263 bits = SegSize(seg) >> lo->alignShift;
264 if(!BTFindLongResRange(&baseIndex, &limitIndex, loseg->alloc, 264 if(!BTFindLongResRange(&baseIndex, &limitIndex, loseg->alloc,
265 0, tablesize, agrains)) { 265 0, bits, agrains)) {
266 return FALSE; 266 return FALSE;
267 } 267 }
268 268
@@ -408,7 +408,7 @@ static void loSegReclaim(LOSeg loseg, Trace trace)
408/* a leaf pool, so there can't be any dangling references */ 408/* a leaf pool, so there can't be any dangling references */
409static void LOWalk(Pool pool, Seg seg, 409static void LOWalk(Pool pool, Seg seg,
410 FormattedObjectsStepMethod f, 410 FormattedObjectsStepMethod f,
411 void *p, unsigned long s) 411 void *p, size_t s)
412{ 412{
413 Addr base; 413 Addr base;
414 LO lo; 414 LO lo;
@@ -491,7 +491,7 @@ static Res LOInit(Pool pool, va_list arg)
491 pool->format = format; 491 pool->format = format;
492 lo->poolStruct.alignment = format->alignment; 492 lo->poolStruct.alignment = format->alignment;
493 lo->alignShift = 493 lo->alignShift =
494 SizeLog2((unsigned long)PoolAlignment(&lo->poolStruct)); 494 SizeLog2((Size)PoolAlignment(&lo->poolStruct));
495 lo->gen = LOGen; /* may be modified in debugger */ 495 lo->gen = LOGen; /* may be modified in debugger */
496 res = ChainCreate(&lo->chain, arena, 1, &loGenParam); 496 res = ChainCreate(&lo->chain, arena, 1, &loGenParam);
497 if (res != ResOK) 497 if (res != ResOK)
@@ -669,7 +669,7 @@ static void LOBufferEmpty(Pool pool, Buffer buffer, Addr init, Addr limit)
669static Res LOWhiten(Pool pool, Trace trace, Seg seg) 669static Res LOWhiten(Pool pool, Trace trace, Seg seg)
670{ 670{
671 LO lo; 671 LO lo;
672 unsigned long bits; 672 Count bits;
673 673
674 AVERT(Pool, pool); 674 AVERT(Pool, pool);
675 lo = PoolPoolLO(pool); 675 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)
615 615
616 616
617static void SNCWalk(Pool pool, Seg seg, FormattedObjectsStepMethod f, 617static void SNCWalk(Pool pool, Seg seg, FormattedObjectsStepMethod f,
618 void *p, unsigned long s) 618 void *p, size_t s)
619{ 619{
620 AVERT(Pool, pool); 620 AVERT(Pool, pool);
621 AVERT(Seg, seg); 621 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)
311 cdie(((QSCell)reg[1])->tag == QSInt, "validate int"); 311 cdie(((QSCell)reg[1])->tag == QSInt, "validate int");
312 if(((QSCell)reg[1])->value != list[i]) { 312 if(((QSCell)reg[1])->value != list[i]) {
313 fprintf(stdout, 313 fprintf(stdout,
314 "mps_res_t: Element %lu of the two lists do not match.\n", 314 "mps_res_t: Element %"PRIuLONGEST" of the two lists do not match.\n",
315 (unsigned long)i); 315 (ulongest_t)i);
316 return; 316 return;
317 } 317 }
318 reg[1] = (mps_word_t)((QSCell)reg[1])->tail; 318 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 @@
24#endif 24#endif
25 25
26 26
27#ifdef MPS_PF_W3I6MV
28#define PRIuLONGEST "llu"
29#define PRIXPTR "016llX"
30typedef unsigned long long ulongest_t;
31#else
32#define PRIuLONGEST "lu"
33#define PRIXPTR "08lX"
34typedef unsigned long ulongest_t;
35#endif
36
37
27typedef unsigned long ulong; 38typedef unsigned long ulong;
28 39
29 40
@@ -46,7 +57,7 @@ static void error(const char *format, ...)
46 va_list args; 57 va_list args;
47 58
48 fflush(stdout); /* sync */ 59 fflush(stdout); /* sync */
49 fprintf(stderr, "%s: @%lu ", prog, (ulong)eventTime); 60 fprintf(stderr, "%s: @%"PRIuLONGEST" ", prog, (ulongest_t)eventTime);
50 va_start(args, format); 61 va_start(args, format);
51 vfprintf(stderr, format, args); 62 vfprintf(stderr, format, args);
52 fprintf(stderr, "\n"); 63 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)
376 AVERT(AMST, amst); 376 AVERT(AMST, amst);
377 377
378 printf("\nDestroying pool, having performed:\n"); 378 printf("\nDestroying pool, having performed:\n");
379 printf(" %lu splits (S)\n", (unsigned long)amst->splits); 379 printf(" %"PRIuLONGEST" splits (S)\n", (ulongest_t)amst->splits);
380 printf(" %lu merges (M)\n", (unsigned long)amst->merges); 380 printf(" %"PRIuLONGEST" merges (M)\n", (ulongest_t)amst->merges);
381 printf(" %lu aborted splits (B)\n", (unsigned long)amst->badSplits); 381 printf(" %"PRIuLONGEST" aborted splits (B)\n", (ulongest_t)amst->badSplits);
382 printf(" %lu aborted merges (D)\n", (unsigned long)amst->badMerges); 382 printf(" %"PRIuLONGEST" aborted merges (D)\n", (ulongest_t)amst->badMerges);
383 printf(" which included:\n"); 383 printf(" which included:\n");
384 printf(" %lu buffered splits (C)\n", (unsigned long)amst->bsplits); 384 printf(" %"PRIuLONGEST" buffered splits (C)\n", (ulongest_t)amst->bsplits);
385 printf(" %lu buffered merges (J)\n", (unsigned long)amst->bmerges); 385 printf(" %"PRIuLONGEST" buffered merges (J)\n", (ulongest_t)amst->bmerges);
386 386
387 AMSFinish(pool); 387 AMSFinish(pool);
388 amst->sig = SigInvalid; 388 amst->sig = SigInvalid;
@@ -799,8 +799,8 @@ static void *test(void *arg, size_t s)
799 while(totalSize < totalSizeMAX) { 799 while(totalSize < totalSizeMAX) {
800 if (totalSize > lastStep + totalSizeSTEP) { 800 if (totalSize > lastStep + totalSizeSTEP) {
801 lastStep = totalSize; 801 lastStep = totalSize;
802 printf("\nSize %lu bytes, %lu objects.\n", 802 printf("\nSize %"PRIuLONGEST" bytes, %"PRIuLONGEST" objects.\n",
803 (unsigned long)totalSize, objs); 803 (ulongest_t)totalSize, (ulongest_t)objs);
804 printf("%s", indent); 804 printf("%s", indent);
805 fflush(stdout); 805 fflush(stdout);
806 for(i = 0; i < exactRootsCOUNT; ++i) 806 for(i = 0; i < exactRootsCOUNT; ++i)
diff --git a/mps/code/splay.c b/mps/code/splay.c
index 7979af342c4..4042f2c0e07 100644
--- a/mps/code/splay.c
+++ b/mps/code/splay.c
@@ -801,7 +801,7 @@ typedef struct {
801 SplayTestNodeMethod testNode; 801 SplayTestNodeMethod testNode;
802 SplayTestTreeMethod testTree; 802 SplayTestTreeMethod testTree;
803 void *p; 803 void *p;
804 unsigned long s; 804 Size s;
805 SplayTree tree; 805 SplayTree tree;
806} SplayFindClosureStruct, *SplayFindClosure; 806} SplayFindClosureStruct, *SplayFindClosure;
807 807
@@ -809,7 +809,7 @@ static Compare SplayFindFirstCompare(void *key, SplayNode node)
809{ 809{
810 SplayFindClosure closure; 810 SplayFindClosure closure;
811 void *closureP; 811 void *closureP;
812 unsigned long closureS; 812 Size closureS;
813 SplayTestNodeMethod testNode; 813 SplayTestNodeMethod testNode;
814 SplayTestTreeMethod testTree; 814 SplayTestTreeMethod testTree;
815 SplayTree tree; 815 SplayTree tree;
@@ -840,7 +840,7 @@ static Compare SplayFindLastCompare(void *key, SplayNode node)
840{ 840{
841 SplayFindClosure closure; 841 SplayFindClosure closure;
842 void *closureP; 842 void *closureP;
843 unsigned long closureS; 843 Size closureS;
844 SplayTestNodeMethod testNode; 844 SplayTestNodeMethod testNode;
845 SplayTestTreeMethod testTree; 845 SplayTestTreeMethod testTree;
846 SplayTree tree; 846 SplayTree tree;
@@ -883,7 +883,7 @@ static Compare SplayFindLastCompare(void *key, SplayNode node)
883Bool SplayFindFirst(SplayNode *nodeReturn, SplayTree tree, 883Bool SplayFindFirst(SplayNode *nodeReturn, SplayTree tree,
884 SplayTestNodeMethod testNode, 884 SplayTestNodeMethod testNode,
885 SplayTestTreeMethod testTree, 885 SplayTestTreeMethod testTree,
886 void *closureP, unsigned long closureS) 886 void *closureP, Size closureS)
887{ 887{
888 SplayNode node; 888 SplayNode node;
889 SplayFindClosureStruct closureStruct; 889 SplayFindClosureStruct closureStruct;
@@ -919,7 +919,7 @@ Bool SplayFindFirst(SplayNode *nodeReturn, SplayTree tree,
919Bool SplayFindLast(SplayNode *nodeReturn, SplayTree tree, 919Bool SplayFindLast(SplayNode *nodeReturn, SplayTree tree,
920 SplayTestNodeMethod testNode, 920 SplayTestNodeMethod testNode,
921 SplayTestTreeMethod testTree, 921 SplayTestTreeMethod testTree,
922 void *closureP, unsigned long closureS) 922 void *closureP, Size closureS)
923{ 923{
924 SplayNode node; 924 SplayNode node;
925 SplayFindClosureStruct closureStruct; 925 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;
17typedef unsigned Compare; 17typedef unsigned Compare;
18typedef Compare (*SplayCompareMethod)(void *key, SplayNode node); 18typedef Compare (*SplayCompareMethod)(void *key, SplayNode node);
19typedef Bool (*SplayTestNodeMethod)(SplayTree tree, SplayNode node, 19typedef Bool (*SplayTestNodeMethod)(SplayTree tree, SplayNode node,
20 void *closureP, unsigned long closureS); 20 void *closureP, Size closureS);
21typedef Bool (*SplayTestTreeMethod)(SplayTree tree, SplayNode node, 21typedef Bool (*SplayTestTreeMethod)(SplayTree tree, SplayNode node,
22 void *closureP, unsigned long closureS); 22 void *closureP, Size closureS);
23typedef void (*SplayUpdateNodeMethod)(SplayTree tree, SplayNode node, 23typedef void (*SplayUpdateNodeMethod)(SplayTree tree, SplayNode node,
24 SplayNode leftChild, 24 SplayNode leftChild,
25 SplayNode rightChild); 25 SplayNode rightChild);
@@ -67,11 +67,11 @@ extern SplayNode SplayTreeNext(SplayTree tree, SplayNode oldNode,
67extern Bool SplayFindFirst(SplayNode *nodeReturn, SplayTree tree, 67extern Bool SplayFindFirst(SplayNode *nodeReturn, SplayTree tree,
68 SplayTestNodeMethod testNode, 68 SplayTestNodeMethod testNode,
69 SplayTestTreeMethod testTree, 69 SplayTestTreeMethod testTree,
70 void *closureP, unsigned long closureS); 70 void *closureP, Size closureS);
71extern Bool SplayFindLast(SplayNode *nodeReturn, SplayTree tree, 71extern Bool SplayFindLast(SplayNode *nodeReturn, SplayTree tree,
72 SplayTestNodeMethod testNode, 72 SplayTestNodeMethod testNode,
73 SplayTestTreeMethod testTree, 73 SplayTestTreeMethod testTree,
74 void *closureP, unsigned long closureS); 74 void *closureP, Size closureS);
75 75
76extern void SplayNodeRefresh(SplayTree tree, SplayNode node, void *key); 76extern void SplayNodeRefresh(SplayTree tree, SplayNode node, void *key);
77 77
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] = {
50 * during allocation. 50 * during allocation.
51 */ 51 */
52 52
53static size_t step_frequencies[] = { 53static unsigned long step_frequencies[] = {
54 1000, 54 1000,
55 5000, 55 5000,
56 10000, 56 10000,
57 1000000000, 57 1000000000, /* one billion */
58}; 58};
59 59
60#define TESTS (sizeof(step_frequencies) / sizeof(step_frequencies[0])) 60#define TESTS (sizeof(step_frequencies) / sizeof(step_frequencies[0]))
@@ -414,11 +414,11 @@ static void *test(void *arg, size_t s)
414 414
415 total_mps_time = alloc_time + step_time + no_step_time; 415 total_mps_time = alloc_time + step_time + no_step_time;
416 printf("Collection statistics:\n"); 416 printf("Collection statistics:\n");
417 printf(" %lu collections\n", (unsigned long)collections); 417 printf(" %"PRIuLONGEST" collections\n", (ulongest_t)collections);
418 printf(" %lu bytes condemned.\n", (unsigned long)condemned); 418 printf(" %"PRIuLONGEST" bytes condemned.\n", (ulongest_t)condemned);
419 printf(" %lu bytes not condemned.\n", 419 printf(" %lu bytes not condemned.\n",
420 (unsigned long)not_condemned); 420 (unsigned long)not_condemned);
421 printf(" %lu bytes survived.\n", (unsigned long)live); 421 printf(" %"PRIuLONGEST" bytes survived.\n", (ulongest_t)live);
422 if (condemned) { 422 if (condemned) {
423 printf(" Mortality %5.2f%%.\n", 423 printf(" Mortality %5.2f%%.\n",
424 (1.0 - ((double)live)/condemned) * 100.0); 424 (1.0 - ((double)live)/condemned) * 100.0);
@@ -471,7 +471,7 @@ static void *test(void *arg, size_t s)
471 print_time(" (adjusted for clock timing: ", 471 print_time(" (adjusted for clock timing: ",
472 total_clock_time, 472 total_clock_time,
473 " spent reading the clock;\n"); 473 " spent reading the clock;\n");
474 printf(" %lu clock reads; ", (unsigned long)clock_reads); 474 printf(" %"PRIuLONGEST" clock reads; ", (ulongest_t)clock_reads);
475 print_time("", total_clock_time / clock_reads, " per read;"); 475 print_time("", total_clock_time / clock_reads, " per read;");
476 print_time(" recently measured as ", clock_time, ").\n"); 476 print_time(" recently measured as ", clock_time, ").\n");
477 mps_ap_destroy(ap); 477 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 @@
75#endif /* MPS_BUILD_MV */ 75#endif /* MPS_BUILD_MV */
76 76
77 77
78/* ulongest_t -- longest unsigned integer type
79 *
80 * Define a longest unsigned integer type for testing and printing. We'd
81 * like to use C99's uintmax_t and PRIuMAX here, but the MPS is in C89
82 * and C99 isn't supported by Microsoft.
83 *
84 * We avoid using the ones defined in mpstd.h because we want the tests to
85 * root out any incompatible assumptions by breaking.
86 */
87
88#ifdef MPS_PF_W3I6MV
89#define PRIuLONGEST "llu"
90#define PRIXLONGEST "llX"
91#define PRIwLONGEST "16"
92typedef unsigned long long ulongest_t;
93#else
94#define PRIuLONGEST "lu"
95#define PRIXLONGEST "lX"
96#define PRIwLONGEST "8"
97typedef unsigned long ulongest_t;
98#endif
99#define PRIXPTR "0"PRIwLONGEST PRIXLONGEST
100
101
78/* testlib_unused -- declares that a variable is unused 102/* testlib_unused -- declares that a variable is unused
79 * 103 *
80 * It should be used to prevent compiler warnings about unused 104 * It should be used to prevent compiler warnings about unused
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)
36 36
37 37
38static void ArenaFormattedObjectsStep(Addr object, Format format, Pool pool, 38static void ArenaFormattedObjectsStep(Addr object, Format format, Pool pool,
39 void *p, Size s) 39 void *p, size_t s)
40{ 40{
41 FormattedObjectsStepClosure c; 41 FormattedObjectsStepClosure c;
42 /* Can't check object */ 42 /* Can't check object */
@@ -56,7 +56,7 @@ static void ArenaFormattedObjectsStep(Addr object, Format format, Pool pool,
56 * So called because it walks all formatted objects in an arena. */ 56 * So called because it walks all formatted objects in an arena. */
57 57
58static void ArenaFormattedObjectsWalk(Arena arena, FormattedObjectsStepMethod f, 58static void ArenaFormattedObjectsWalk(Arena arena, FormattedObjectsStepMethod f,
59 void *p, Size s) 59 void *p, size_t s)
60{ 60{
61 Seg seg; 61 Seg seg;
62 FormattedObjectsStepClosure c; 62 FormattedObjectsStepClosure c;
@@ -186,7 +186,7 @@ static Bool rootsStepClosureCheck(rootsStepClosure rsc)
186static void rootsStepClosureInit(rootsStepClosure rsc, 186static void rootsStepClosureInit(rootsStepClosure rsc,
187 Globals arena, Trace trace, 187 Globals arena, Trace trace,
188 TraceFixMethod rootFix, 188 TraceFixMethod rootFix,
189 mps_roots_stepper_t f, void *p, Size s) 189 mps_roots_stepper_t f, void *p, size_t s)
190{ 190{
191 ScanState ss; 191 ScanState ss;
192 192
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;
92static mps_thr_t stack_thr; 92static mps_thr_t stack_thr;
93 93
94 94
95static unsigned long cols(size_t bytes) 95static ulongest_t cols(size_t bytes)
96{ 96{
97 double M; /* Mebibytes */ 97 double M; /* Mebibytes */
98 unsigned long cM; /* hundredths of a Mebibyte */ 98 ulongest_t cM; /* hundredths of a Mebibyte */
99 99
100 M = (double)bytes / (1UL<<20); 100 M = (double)bytes / (1UL<<20);
101 cM = (unsigned long)(M * 100 + 0.5); /* round to nearest */ 101 cM = (ulongest_t)(M * 100.0 + 0.5); /* round to nearest */
102 return cM; 102 return cM;
103} 103}
104 104
@@ -424,8 +424,8 @@ static void CatalogDo(mps_arena_t arena, mps_ap_t ap)
424static void* MakeThing(mps_arena_t arena, mps_ap_t ap, size_t size) 424static void* MakeThing(mps_arena_t arena, mps_ap_t ap, size_t size)
425{ 425{
426 mps_word_t v; 426 mps_word_t v;
427 unsigned long words; 427 ulongest_t words;
428 unsigned long slots; 428 ulongest_t slots;
429 429
430 words = (size + (sizeof(mps_word_t) - 1) ) / sizeof(mps_word_t); 430 words = (size + (sizeof(mps_word_t) - 1) ) / sizeof(mps_word_t);
431 if(words < 2) 431 if(words < 2)
@@ -440,8 +440,8 @@ static void* MakeThing(mps_arena_t arena, mps_ap_t ap, size_t size)
440 440
441static void BigdropSmall(mps_arena_t arena, mps_ap_t ap, size_t big, char small_ref) 441static void BigdropSmall(mps_arena_t arena, mps_ap_t ap, size_t big, char small_ref)
442{ 442{
443 static unsigned long keepCount = 0; 443 static unsigned keepCount = 0;
444 unsigned long i; 444 unsigned i;
445 445
446 mps_arena_park(arena); 446 mps_arena_park(arena);
447 for(i = 0; i < 100; i++) { 447 for(i = 0; i < 100; i++) {
@@ -474,7 +474,7 @@ static unsigned long df(unsigned randm, unsigned number)
474static void Make(mps_arena_t arena, mps_ap_t ap, unsigned randm, unsigned keep1in, unsigned keepTotal, unsigned keepRootspace, unsigned sizemethod) 474static void Make(mps_arena_t arena, mps_ap_t ap, unsigned randm, unsigned keep1in, unsigned keepTotal, unsigned keepRootspace, unsigned sizemethod)
475{ 475{
476 unsigned keepCount = 0; 476 unsigned keepCount = 0;
477 unsigned long objCount = 0; 477 unsigned objCount = 0;
478 478
479 Insist(keepRootspace <= myrootExactCOUNT); 479 Insist(keepRootspace <= myrootExactCOUNT);
480 480
@@ -523,7 +523,7 @@ static void Make(mps_arena_t arena, mps_ap_t ap, unsigned randm, unsigned keep1i
523 } 523 }
524 printf(" ...made and kept: %u objects, storing cyclically in " 524 printf(" ...made and kept: %u objects, storing cyclically in "
525 "first %u roots " 525 "first %u roots "
526 "(actually created %lu objects, in accord with " 526 "(actually created %u objects, in accord with "
527 "keep-1-in %u).\n", 527 "keep-1-in %u).\n",
528 keepCount, keepRootspace, objCount, keep1in); 528 keepCount, keepRootspace, objCount, keep1in);
529} 529}
@@ -531,7 +531,7 @@ static void Make(mps_arena_t arena, mps_ap_t ap, unsigned randm, unsigned keep1i
531 531
532static void Rootdrop(char rank_char) 532static void Rootdrop(char rank_char)
533{ 533{
534 unsigned long i; 534 unsigned i;
535 535
536 if(rank_char == 'A') { 536 if(rank_char == 'A') {
537 for(i = 0; i < myrootAmbigCOUNT; ++i) { 537 for(i = 0; i < myrootAmbigCOUNT; ++i) {
@@ -553,6 +553,10 @@ static void stackwipe(void)
553 unsigned iw; 553 unsigned iw;
554 unsigned long aw[stackwipedepth]; 554 unsigned long aw[stackwipedepth];
555 555
556 /* Do some pointless work that the compiler won't optimise away, so that
557 this function wipes over the stack by filling stuff into the "aw"
558 array. */
559
556 /* http://xkcd.com/710/ */ 560 /* http://xkcd.com/710/ */
557 /* I don't want my friends to stop calling; I just want the */ 561 /* I don't want my friends to stop calling; I just want the */
558 /* compiler to stop optimising away my code. */ 562 /* compiler to stop optimising away my code. */
@@ -808,7 +812,7 @@ static void testscriptA(const char *script)
808 printf(" Create arena, size = %lu.\n", arenasize); 812 printf(" Create arena, size = %lu.\n", arenasize);
809 813
810 /* arena */ 814 /* arena */
811 die(mps_arena_create(&arena, mps_arena_class_vm(), arenasize), 815 die(mps_arena_create(&arena, mps_arena_class_vm(), (size_t)arenasize),
812 "arena_create"); 816 "arena_create");
813 817
814 /* thr: used to stop/restart multiple threads */ 818 /* thr: used to stop/restart multiple threads */