aboutsummaryrefslogtreecommitdiffstats
path: root/mps/code
diff options
context:
space:
mode:
authorRichard Brooksby2012-08-31 05:17:20 +0100
committerRichard Brooksby2012-08-31 05:17:20 +0100
commit4e8ff21a10b5aaf2edf7eec5c1a338f60231d97c (patch)
tree404cc4c2ddfc96ab3db32f31f6ea968202da4e41 /mps/code
parent2208e93639e739b74992aa3d772f82b486e085c6 (diff)
downloademacs-4e8ff21a10b5aaf2edf7eec5c1a338f60231d97c.tar.gz
emacs-4e8ff21a10b5aaf2edf7eec5c1a338f60231d97c.zip
Adding packed boolean event parameter type, partly to suppress warnings.
Copied from Perforce Change: 179124 ServerID: perforce.ravenbrook.com
Diffstat (limited to 'mps/code')
-rw-r--r--mps/code/eventcnv.c158
-rw-r--r--mps/code/eventcom.h23
-rw-r--r--mps/code/eventdef.h14
-rw-r--r--mps/code/eventpro.c19
-rw-r--r--mps/code/eventpro.h1
5 files changed, 117 insertions, 98 deletions
diff --git a/mps/code/eventcnv.c b/mps/code/eventcnv.c
index 10241135ceb..c5a436d1df9 100644
--- a/mps/code/eventcnv.c
+++ b/mps/code/eventcnv.c
@@ -328,45 +328,61 @@ static void clearBucket(void)
328 * some event types that are handled specially. 328 * some event types that are handled specially.
329 */ 329 */
330 330
331static void printArg(EventProc proc, 331static void printParamA(EventProc proc, char *styleConv, Addr addr)
332 void *arg, char argType, char *styleConv)
333{ 332{
334 switch (argType) { 333 if (style != 'L') {
335 case 'A': {
336 if (style != 'L') {
337 if (style == 'C') putchar(',');
338 printAddr(proc, *(Addr *)arg);
339 } else
340 printf(styleConv, (ulongest_t)*(Addr *)arg);
341 } break;
342 case 'P': {
343 printf(styleConv, (ulongest_t)*(void **)arg);
344 } break;
345 case 'U': {
346 printf(styleConv, (ulongest_t)*(unsigned *)arg);
347 } break;
348 case 'W': {
349 printf(styleConv, (ulongest_t)*(Word *)arg);
350 } break;
351 case 'D': {
352 switch (style) {
353 case '\0':
354 printf(" %#8.3g", *(double *)arg); break;
355 case 'C':
356 printf(", %.10G", *(double *)arg); break;
357 case 'L':
358 printf(" %#.10G", *(double *)arg); break;
359 }
360 } break;
361 case 'S': {
362 if (style == 'C') putchar(','); 334 if (style == 'C') putchar(',');
363 putchar(' '); 335 printAddr(proc, addr);
364 printStr((EventStringStruct *)arg, (style == 'C' || style == 'L')); 336 } else
365 } break; 337 printf(styleConv, (ulongest_t)addr);
366 default: everror("Can't print format >%c<", argType); 338}
339
340static void printParamP(EventProc proc, char *styleConv, void *p)
341{
342 UNUSED(proc);
343 printf(styleConv, (ulongest_t)p);
344}
345
346static void printParamU(EventProc proc, char *styleConv, unsigned u)
347{
348 UNUSED(proc);
349 printf(styleConv, (ulongest_t)u);
350}
351
352static void printParamW(EventProc proc, char *styleConv, Word w)
353{
354 UNUSED(proc);
355 printf(styleConv, (ulongest_t)w);
356}
357
358static void printParamD(EventProc proc, char *styleConv, double d)
359{
360 UNUSED(proc);
361 switch (style) {
362 case '\0':
363 printf(" %#8.3g", d); break;
364 case 'C':
365 printf(", %.10G", d); break;
366 case 'L':
367 printf(" %#.10G", d); break;
367 } 368 }
368} 369}
369 370
371static void printParamS(EventProc proc, char *styleConv, EventStringStruct s)
372{
373 UNUSED(proc);
374 if (style == 'C') putchar(',');
375 putchar(' ');
376 printStr(&s, (style == 'C' || style == 'L'));
377}
378
379static void printParamB(EventProc proc, char *styleConv, Bool b)
380{
381 UNUSED(proc);
382 UNUSED(proc);
383 printf(styleConv, (ulongest_t)b);
384}
385
370 386
371static void readLog(EventProc proc) 387static void readLog(EventProc proc)
372{ 388{
@@ -456,33 +472,37 @@ static void readLog(EventProc proc)
456 } 472 }
457 473
458 switch (event->any.code) { 474 switch (event->any.code) {
459 case EventLabelCode: { 475
476 case EventLabelCode:
460 switch (style) { 477 switch (style) {
461 case '\0': case 'C': { 478 case '\0': case 'C':
462 EventString sym = LabelText(proc, event->Label.f1); 479 {
463 printf(style == '\0' ? 480 EventString sym = LabelText(proc, event->Label.f1);
464 " %08"PRIXLONGEST" " :
465 ", %"PRIuLONGEST", ",
466 (ulongest_t)event->Label.f0);
467 if (sym != NULL) {
468 printStr(sym, (style == 'C'));
469 } else {
470 printf(style == '\0' ? 481 printf(style == '\0' ?
471 "sym %05"PRIXLONGEST : 482 " %08"PRIXLONGEST" " :
472 "sym %"PRIXLONGEST"\"", 483 ", %"PRIuLONGEST", ",
473 (ulongest_t)event->Label.f1); 484 (ulongest_t)event->Label.f0);
485 if (sym != NULL) {
486 printStr(sym, (style == 'C'));
487 } else {
488 printf(style == '\0' ?
489 "sym %05"PRIXLONGEST :
490 "sym %"PRIXLONGEST"\"",
491 (ulongest_t)event->Label.f1);
492 }
474 } 493 }
475 } break; 494 break;
476 case 'L': { 495 case 'L':
477 printf(" %"PRIXLONGEST" %"PRIXLONGEST, 496 printf(" %"PRIXLONGEST" %"PRIXLONGEST,
478 (ulongest_t)event->Label.f0, 497 (ulongest_t)event->Label.f0,
479 (ulongest_t)event->Label.f1); 498 (ulongest_t)event->Label.f1);
480 } break; 499 break;
481 } 500 }
482 } break; 501 break;
483 case EventMeterValuesCode: { 502
503 case EventMeterValuesCode:
484 switch (style) { 504 switch (style) {
485 case '\0': { 505 case '\0':
486 if (event->MeterValues.f3 == 0) { 506 if (event->MeterValues.f3 == 0) {
487 printf(" %08"PRIXLONGEST" 0 N/A N/A N/A N/A", 507 printf(" %08"PRIXLONGEST" 0 N/A N/A N/A N/A",
488 (ulongest_t)event->MeterValues.f0); 508 (ulongest_t)event->MeterValues.f0);
@@ -498,25 +518,28 @@ static void readLog(EventProc proc)
498 mean, stddev); 518 mean, stddev);
499 } 519 }
500 printAddr(proc, (Addr)event->MeterValues.f0); 520 printAddr(proc, (Addr)event->MeterValues.f0);
501 } break; 521 break;
502 case 'C': { 522
523 case 'C':
503 putchar(','); 524 putchar(',');
504 printAddr(proc, (Addr)event->MeterValues.f0); 525 printAddr(proc, (Addr)event->MeterValues.f0);
505 printf(", %.10G, %.10G, %u, %u, %u", 526 printf(", %.10G, %.10G, %u, %u, %u",
506 event->MeterValues.f1, event->MeterValues.f2, 527 event->MeterValues.f1, event->MeterValues.f2,
507 (uint)event->MeterValues.f3, (uint)event->MeterValues.f4, 528 (uint)event->MeterValues.f3, (uint)event->MeterValues.f4,
508 (uint)event->MeterValues.f5); 529 (uint)event->MeterValues.f5);
509 } break; 530 break;
510 case 'L': { 531
532 case 'L':
511 printf(" %"PRIXLONGEST" %#.10G %#.10G %X %X %X", 533 printf(" %"PRIXLONGEST" %#.10G %#.10G %X %X %X",
512 (ulongest_t)event->MeterValues.f0, 534 (ulongest_t)event->MeterValues.f0,
513 event->MeterValues.f1, event->MeterValues.f2, 535 event->MeterValues.f1, event->MeterValues.f2,
514 (uint)event->MeterValues.f3, (uint)event->MeterValues.f4, 536 (uint)event->MeterValues.f3, (uint)event->MeterValues.f4,
515 (uint)event->MeterValues.f5); 537 (uint)event->MeterValues.f5);
516 } break; 538 break;
517 } 539 }
518 } break; 540 break;
519 case EventPoolInitCode: { /* pool, arena, class */ 541
542 case EventPoolInitCode: /* pool, arena, class */
520 printf(styleConv, (ulongest_t)event->PoolInit.f0); 543 printf(styleConv, (ulongest_t)event->PoolInit.f0);
521 printf(styleConv, (ulongest_t)event->PoolInit.f1); 544 printf(styleConv, (ulongest_t)event->PoolInit.f1);
522 /* class is a Pointer, but we label them, so call printAddr */ 545 /* class is a Pointer, but we label them, so call printAddr */
@@ -525,13 +548,16 @@ static void readLog(EventProc proc)
525 printAddr(proc, (Addr)event->PoolInit.f2); 548 printAddr(proc, (Addr)event->PoolInit.f2);
526 } else 549 } else
527 printf(styleConv, (ulongest_t)event->PoolInit.f2); 550 printf(styleConv, (ulongest_t)event->PoolInit.f2);
528 } break; 551 break;
552
529 default: 553 default:
530 { 554#define EVENT_PARAM_PRINT(name, index, sort, ident) \
531 unsigned i; 555 printParam##sort(proc, styleConv, event->name.f##index);
532 for (i = 0; i < argCount; ++i) 556#define EVENT_PRINT(X, name, code, always, kind) \
533 printArg(proc, EventField(event, i), eventFormat[i], styleConv); 557 case code: \
534 } 558 EVENT_##name##_PARAMS(EVENT_PARAM_PRINT, name) \
559 break;
560 switch (event->any.code) { EVENT_LIST(EVENT_PRINT, X) }
535 } 561 }
536 562
537 if (style == 'L') putchar(')'); 563 if (style == 'L') putchar(')');
diff --git a/mps/code/eventcom.h b/mps/code/eventcom.h
index fbd9d0df212..c42dbeb4c61 100644
--- a/mps/code/eventcom.h
+++ b/mps/code/eventcom.h
@@ -150,12 +150,21 @@ EVENT_LIST(EVENT_ENUM, X)
150 */ 150 */
151 151
152/* Event field types -- similar to WriteF* */ 152/* Event field types -- similar to WriteF* */
153typedef void *EventFP; 153typedef void *EventFP; /* pointer to C object */
154typedef Addr EventFA; 154typedef Addr EventFA; /* address on the heap */
155typedef Word EventFW; 155typedef Word EventFW; /* word */
156typedef unsigned EventFU; 156typedef unsigned EventFU; /* unsigned integer */
157typedef EventStringStruct EventFS; 157typedef EventStringStruct EventFS; /* string */
158typedef double EventFD; 158typedef double EventFD; /* double */
159typedef int EventFB; /* boolean */
160
161#define EventFP_BITFIELD
162#define EventFA_BITFIELD
163#define EventFW_BITFIELD
164#define EventFU_BITFIELD
165#define EventFS_BITFIELD
166#define EventFD_BITFIELD
167#define EventFB_BITFIELD : 1
159 168
160/* Common prefix for all event structures. The size field allows an event 169/* Common prefix for all event structures. The size field allows an event
161 reader to skip over events whose codes it does not recognise. */ 170 reader to skip over events whose codes it does not recognise. */
@@ -166,7 +175,7 @@ typedef struct EventAnyStruct {
166} EventAnyStruct; 175} EventAnyStruct;
167 176
168#define EVENT_STRUCT_FIELD(X, index, sort, ident) \ 177#define EVENT_STRUCT_FIELD(X, index, sort, ident) \
169 EventF##sort f##index; 178 EventF##sort f##index EventF##sort##_BITFIELD;
170 179
171#define EVENT_STRUCT(X, name, _code, always, kind) \ 180#define EVENT_STRUCT(X, name, _code, always, kind) \
172 typedef struct Event##name##Struct { \ 181 typedef struct Event##name##Struct { \
diff --git a/mps/code/eventdef.h b/mps/code/eventdef.h
index fee64b8fce1..a0569bb4a16 100644
--- a/mps/code/eventdef.h
+++ b/mps/code/eventdef.h
@@ -365,7 +365,7 @@
365#define EVENT_BufferInit_PARAMS(PARAM, X) \ 365#define EVENT_BufferInit_PARAMS(PARAM, X) \
366 PARAM(X, 0, P, buffer) \ 366 PARAM(X, 0, P, buffer) \
367 PARAM(X, 1, P, pool) \ 367 PARAM(X, 1, P, pool) \
368 PARAM(X, 2, U, isMutator) 368 PARAM(X, 2, B, isMutator)
369 369
370#define EVENT_BufferFinish_PARAMS(PARAM, X) \ 370#define EVENT_BufferFinish_PARAMS(PARAM, X) \
371 PARAM(X, 0, P, buffer) 371 PARAM(X, 0, P, buffer)
@@ -444,9 +444,9 @@
444 PARAM(X, 2, W, extendBy) \ 444 PARAM(X, 2, W, extendBy) \
445 PARAM(X, 3, W, avgSize) \ 445 PARAM(X, 3, W, avgSize) \
446 PARAM(X, 4, W, align) \ 446 PARAM(X, 4, W, align) \
447 PARAM(X, 5, U, slotHigh) \ 447 PARAM(X, 5, B, slotHigh) \
448 PARAM(X, 6, U, arenaHigh) \ 448 PARAM(X, 6, B, arenaHigh) \
449 PARAM(X, 7, U, firstFit) 449 PARAM(X, 7, B, firstFit)
450 450
451#define EVENT_PoolInitMV_PARAMS(PARAM, X) \ 451#define EVENT_PoolInitMV_PARAMS(PARAM, X) \
452 PARAM(X, 0, P, pool) \ 452 PARAM(X, 0, P, pool) \
@@ -497,12 +497,12 @@
497#define EVENT_BufferInitSeg_PARAMS(PARAM, X) \ 497#define EVENT_BufferInitSeg_PARAMS(PARAM, X) \
498 PARAM(X, 0, P, buffer) \ 498 PARAM(X, 0, P, buffer) \
499 PARAM(X, 1, P, pool) \ 499 PARAM(X, 1, P, pool) \
500 PARAM(X, 2, U, isMutator) 500 PARAM(X, 2, B, isMutator)
501 501
502#define EVENT_BufferInitRank_PARAMS(PARAM, X) \ 502#define EVENT_BufferInitRank_PARAMS(PARAM, X) \
503 PARAM(X, 0, P, buffer) \ 503 PARAM(X, 0, P, buffer) \
504 PARAM(X, 1, P, pool) \ 504 PARAM(X, 1, P, pool) \
505 PARAM(X, 2, U, isMutator) \ 505 PARAM(X, 2, B, isMutator) \
506 PARAM(X, 3, U, rank) 506 PARAM(X, 3, U, rank)
507 507
508#define EVENT_ReservoirLimitSet_PARAMS(PARAM, X) \ 508#define EVENT_ReservoirLimitSet_PARAMS(PARAM, X) \
@@ -538,7 +538,7 @@
538#define EVENT_SegMerge_PARAMS(PARAM, X) \ 538#define EVENT_SegMerge_PARAMS(PARAM, X) \
539 PARAM(X, 0, P, segLo) \ 539 PARAM(X, 0, P, segLo) \
540 PARAM(X, 1, P, segHi) \ 540 PARAM(X, 1, P, segHi) \
541 PARAM(X, 2, U, withReservoirPermit) 541 PARAM(X, 2, B, withReservoirPermit)
542 542
543#define EVENT_SegSplit_PARAMS(PARAM, X) \ 543#define EVENT_SegSplit_PARAMS(PARAM, X) \
544 PARAM(X, 0, P, seg) \ 544 PARAM(X, 0, P, seg) \
diff --git a/mps/code/eventpro.c b/mps/code/eventpro.c
index 768d21adac6..f23fc189113 100644
--- a/mps/code/eventpro.c
+++ b/mps/code/eventpro.c
@@ -75,7 +75,6 @@ typedef struct {
75 size_t size; /* event record size, rounded up from structure */ 75 size_t size; /* event record size, rounded up from structure */
76 Count count; /* Parameter count */ 76 Count count; /* Parameter count */
77 char *format; /* string format, e.g. "PPW" */ 77 char *format; /* string format, e.g. "PPW" */
78 EventSize offsets[15]; /* FIXME: literal constant */
79} eventRecord; 78} eventRecord;
80 79
81#define EVENT_COUNT_PARAM(X, index, sort, ident) + 1 80#define EVENT_COUNT_PARAM(X, index, sort, ident) + 1
@@ -90,11 +89,10 @@ typedef struct {
90 code, \ 89 code, \
91 EventSizeAlign(sizeof(Event##name##Struct)), \ 90 EventSizeAlign(sizeof(Event##name##Struct)), \
92 0 EVENT_##name##_PARAMS(EVENT_COUNT_PARAM, X), \ 91 0 EVENT_##name##_PARAMS(EVENT_COUNT_PARAM, X), \
93 "" EVENT_##name##_PARAMS(EVENT_FORMAT_PARAM, X), \ 92 "" EVENT_##name##_PARAMS(EVENT_FORMAT_PARAM, X)},
94 { EVENT_##name##_PARAMS(EVENT_OFFSETS_PARAM, name) 0 }},
95 93
96static eventRecord eventTypes[] = { 94static eventRecord eventTypes[] = {
97 {"(unused)", 0, 0, 0, "", {0}}, 95 {"(unused)", 0, 0, 0, ""},
98 EVENT_LIST(EVENT_INIT, X) 96 EVENT_LIST(EVENT_INIT, X)
99}; 97};
100 98
@@ -148,19 +146,6 @@ char *EventCode2Format(EventCode code)
148} 146}
149 147
150 148
151/* EventCode2Field -- find pointer to a field within an event */
152
153void *EventField(Event event, unsigned i)
154{
155 Index j = eventCode2Index(event->any.code, TRUE);
156 ptrdiff_t offset;
157 if (i >= eventTypes[j].count)
158 error("Event field %u out of bounds", i);
159 offset = eventTypes[j].offsets[i];
160 return (void *)((char *)event + offset);
161}
162
163
164Bool EventCodeIsValid(EventCode code) 149Bool EventCodeIsValid(EventCode code)
165{ 150{
166 return (eventCode2Index(code, FALSE) != 0); 151 return (eventCode2Index(code, FALSE) != 0);
diff --git a/mps/code/eventpro.h b/mps/code/eventpro.h
index 608b0a36bae..bd6cbebfc76 100644
--- a/mps/code/eventpro.h
+++ b/mps/code/eventpro.h
@@ -22,7 +22,6 @@ typedef Res (*EventProcReader)(void *, void *, size_t);
22extern EventCode EventName2Code(char *name); 22extern EventCode EventName2Code(char *name);
23extern char *EventCode2Name(EventCode code); 23extern char *EventCode2Name(EventCode code);
24extern char *EventCode2Format(EventCode code); 24extern char *EventCode2Format(EventCode code);
25extern void *EventField(Event event, unsigned i);
26extern Bool EventCodeIsValid(EventCode code); 25extern Bool EventCodeIsValid(EventCode code);
27 26
28extern Word AddrLabel(EventProc proc, Addr addr); 27extern Word AddrLabel(EventProc proc, Addr addr);