diff options
| author | Nick Barnes | 2012-10-30 09:36:30 +0000 |
|---|---|---|
| committer | Nick Barnes | 2012-10-30 09:36:30 +0000 |
| commit | 1746c7583af93a392eb5ff566c41fc5a266f8ec2 (patch) | |
| tree | 58dcd7bcd3d3b4e5e187a744440dca7f026417b6 /mps/code | |
| parent | 271b4f6e0abd1a76bd9dc57781f076b7658cbce1 (diff) | |
| download | emacs-1746c7583af93a392eb5ff566c41fc5a266f8ec2.tar.gz emacs-1746c7583af93a392eb5ff566c41fc5a266f8ec2.zip | |
Make eventclocksync events, and output them once per buffer flush.
Copied from Perforce
Change: 180152
ServerID: perforce.ravenbrook.com
Diffstat (limited to 'mps/code')
| -rw-r--r-- | mps/code/event.c | 37 | ||||
| -rw-r--r-- | mps/code/eventdef.h | 9 |
2 files changed, 40 insertions, 6 deletions
diff --git a/mps/code/event.c b/mps/code/event.c index f88600df7e7..aeaeaba9c48 100644 --- a/mps/code/event.c +++ b/mps/code/event.c | |||
| @@ -46,6 +46,31 @@ char *EventLast[EventKindLIMIT]; | |||
| 46 | EventControlSet EventKindControl; /* Bit set used to control output. */ | 46 | EventControlSet EventKindControl; /* Bit set used to control output. */ |
| 47 | 47 | ||
| 48 | 48 | ||
| 49 | /* A single event structure output once per buffer flush. */ | ||
| 50 | EventEventClockSyncStruct eventClockSyncStruct; | ||
| 51 | |||
| 52 | |||
| 53 | /* eventClockSync -- Populate and write the clock sync event. */ | ||
| 54 | |||
| 55 | static Res eventClockSync(void) | ||
| 56 | { | ||
| 57 | Res res; | ||
| 58 | size_t size; | ||
| 59 | |||
| 60 | size= size_tAlignUp(sizeof(eventClockSyncStruct), MPS_PF_ALIGN); | ||
| 61 | eventClockSyncStruct.code = EventEventClockSyncCode; | ||
| 62 | eventClockSyncStruct.size = (EventSize)size; | ||
| 63 | EVENT_CLOCK(eventClockSyncStruct.clock); | ||
| 64 | eventClockSyncStruct.f0 = (Word)mps_clock(); | ||
| 65 | res = (Res)mps_io_write(eventIO, (void *)&eventClockSyncStruct, size); | ||
| 66 | if (res != ResOK) | ||
| 67 | goto failWrite; | ||
| 68 | |||
| 69 | res = ResOK; | ||
| 70 | failWrite: | ||
| 71 | return res; | ||
| 72 | } | ||
| 73 | |||
| 49 | /* EventFlush -- flush event buffer to the event stream */ | 74 | /* EventFlush -- flush event buffer to the event stream */ |
| 50 | 75 | ||
| 51 | Res EventFlush(EventKind kind) | 76 | Res EventFlush(EventKind kind) |
| @@ -78,7 +103,12 @@ Res EventFlush(EventKind kind) | |||
| 78 | goto failCreate; | 103 | goto failCreate; |
| 79 | eventIOInited = TRUE; | 104 | eventIOInited = TRUE; |
| 80 | } | 105 | } |
| 81 | 106 | ||
| 107 | /* Send an EventClockSync event */ | ||
| 108 | res = eventClockSync(); | ||
| 109 | if (res != ResOK) | ||
| 110 | goto failClockSync; | ||
| 111 | |||
| 82 | /* Writing might be faster if the size is aligned to a multiple of the | 112 | /* Writing might be faster if the size is aligned to a multiple of the |
| 83 | C library or kernel's buffer size. We could pad out the buffer with | 113 | C library or kernel's buffer size. We could pad out the buffer with |
| 84 | a marker for this purpose. */ | 114 | a marker for this purpose. */ |
| @@ -88,9 +118,8 @@ Res EventFlush(EventKind kind) | |||
| 88 | goto failWrite; | 118 | goto failWrite; |
| 89 | 119 | ||
| 90 | } | 120 | } |
| 91 | |||
| 92 | res = ResOK; | ||
| 93 | 121 | ||
| 122 | failClockSync: | ||
| 94 | failWrite: | 123 | failWrite: |
| 95 | failCreate: | 124 | failCreate: |
| 96 | 125 | ||
| @@ -180,6 +209,8 @@ void EventInit(void) | |||
| 180 | (void)EventInternString(MPSVersion()); /* emit version */ | 209 | (void)EventInternString(MPSVersion()); /* emit version */ |
| 181 | EVENT6(EventInit, EVENT_VERSION_MAJOR, EVENT_VERSION_MEDIAN, | 210 | EVENT6(EventInit, EVENT_VERSION_MAJOR, EVENT_VERSION_MEDIAN, |
| 182 | EVENT_VERSION_MINOR, EventCodeMAX, EventNameMAX, MPS_WORD_WIDTH); | 211 | EVENT_VERSION_MINOR, EventCodeMAX, EventNameMAX, MPS_WORD_WIDTH); |
| 212 | /* flush these initial events to get the first ClockSync out. */ | ||
| 213 | EventSync(); | ||
| 183 | } else { | 214 | } else { |
| 184 | ++eventUserCount; | 215 | ++eventUserCount; |
| 185 | } | 216 | } |
diff --git a/mps/code/eventdef.h b/mps/code/eventdef.h index 456d230d8f8..4e4fe899433 100644 --- a/mps/code/eventdef.h +++ b/mps/code/eventdef.h | |||
| @@ -38,7 +38,7 @@ | |||
| 38 | 38 | ||
| 39 | #define EVENT_VERSION_MAJOR ((unsigned)1) | 39 | #define EVENT_VERSION_MAJOR ((unsigned)1) |
| 40 | #define EVENT_VERSION_MEDIAN ((unsigned)0) | 40 | #define EVENT_VERSION_MEDIAN ((unsigned)0) |
| 41 | #define EVENT_VERSION_MINOR ((unsigned)1) | 41 | #define EVENT_VERSION_MINOR ((unsigned)2) |
| 42 | 42 | ||
| 43 | 43 | ||
| 44 | /* EVENT_LIST -- list of event types and general properties | 44 | /* EVENT_LIST -- list of event types and general properties |
| @@ -68,7 +68,7 @@ | |||
| 68 | */ | 68 | */ |
| 69 | 69 | ||
| 70 | #define EventNameMAX ((size_t)19) | 70 | #define EventNameMAX ((size_t)19) |
| 71 | #define EventCodeMAX ((EventCode)0x0074) | 71 | #define EventCodeMAX ((EventCode)0x0075) |
| 72 | 72 | ||
| 73 | #define EVENT_LIST(EVENT, X) \ | 73 | #define EVENT_LIST(EVENT, X) \ |
| 74 | /* 0123456789012345678 <- don't exceed without changing EventNameMAX */ \ | 74 | /* 0123456789012345678 <- don't exceed without changing EventNameMAX */ \ |
| @@ -180,7 +180,8 @@ | |||
| 180 | EVENT(X, TraceBandAdvance , 0x0071, TRUE, Trace) \ | 180 | EVENT(X, TraceBandAdvance , 0x0071, TRUE, Trace) \ |
| 181 | EVENT(X, AWLDeclineTotal , 0x0072, TRUE, Trace) \ | 181 | EVENT(X, AWLDeclineTotal , 0x0072, TRUE, Trace) \ |
| 182 | EVENT(X, AWLDeclineSeg , 0x0073, TRUE, Trace) \ | 182 | EVENT(X, AWLDeclineSeg , 0x0073, TRUE, Trace) \ |
| 183 | EVENT(X, EventInit , 0x0074, TRUE, Arena) | 183 | EVENT(X, EventInit , 0x0074, TRUE, Arena) \ |
| 184 | EVENT(X, EventClockSync , 0x0075, TRUE, Arena) | ||
| 184 | 185 | ||
| 185 | 186 | ||
| 186 | /* Remember to update EventNameMAX and EventCodeMAX in eventcom.h! | 187 | /* Remember to update EventNameMAX and EventCodeMAX in eventcom.h! |
| @@ -629,6 +630,8 @@ | |||
| 629 | PARAM(X, 4, U, maxNameLen) /* EventNameMAX */ \ | 630 | PARAM(X, 4, U, maxNameLen) /* EventNameMAX */ \ |
| 630 | PARAM(X, 5, U, wordWidth) /* MPS_WORD_WIDTH */ | 631 | PARAM(X, 5, U, wordWidth) /* MPS_WORD_WIDTH */ |
| 631 | 632 | ||
| 633 | #define EVENT_EventClockSync_PARAMS(PARAM, X) \ | ||
| 634 | PARAM(X, 0, W, clock) /* mps_clock() value */ | ||
| 632 | 635 | ||
| 633 | #endif /* eventdef_h */ | 636 | #endif /* eventdef_h */ |
| 634 | 637 | ||