diff options
Diffstat (limited to 'mps/code')
| -rw-r--r-- | mps/code/event.c | 50 | ||||
| -rw-r--r-- | mps/code/event.h | 27 |
2 files changed, 38 insertions, 39 deletions
diff --git a/mps/code/event.c b/mps/code/event.c index ca50a4ea32f..b97714f62b4 100644 --- a/mps/code/event.c +++ b/mps/code/event.c | |||
| @@ -38,7 +38,7 @@ static Count eventUserCount; | |||
| 38 | static Serial EventInternSerial; | 38 | static Serial EventInternSerial; |
| 39 | 39 | ||
| 40 | char *EventNext, *EventLimit; /* Used by macros in <code/event.h> */ | 40 | char *EventNext, *EventLimit; /* Used by macros in <code/event.h> */ |
| 41 | Word EventKindControl; /* Bit set used to control output. */ | 41 | EventControlSet EventKindControl; /* Bit set used to control output. */ |
| 42 | 42 | ||
| 43 | 43 | ||
| 44 | /* EventFlush -- flush event buffer to the event stream */ | 44 | /* EventFlush -- flush event buffer to the event stream */ |
| @@ -162,11 +162,14 @@ void EventFinish(void) | |||
| 162 | * Reset(M) EventControl(M,0) | 162 | * Reset(M) EventControl(M,0) |
| 163 | * Flip(M) EventControl(0,M) | 163 | * Flip(M) EventControl(0,M) |
| 164 | * Read() EventControl(0,0) | 164 | * Read() EventControl(0,0) |
| 165 | * | ||
| 166 | * FIXME: Candy-machine interface is a transgression. | ||
| 165 | */ | 167 | */ |
| 166 | 168 | ||
| 167 | Word EventControl(Word resetMask, Word flipMask) | 169 | EventControlSet EventControl(EventControlSet resetMask, |
| 170 | EventControlSet flipMask) | ||
| 168 | { | 171 | { |
| 169 | Word oldValue = EventKindControl; | 172 | EventControlSet oldValue = EventKindControl; |
| 170 | 173 | ||
| 171 | /* EventKindControl = (EventKindControl & ~resetMask) ^ flipMask */ | 174 | /* EventKindControl = (EventKindControl & ~resetMask) ^ flipMask */ |
| 172 | EventKindControl = | 175 | EventKindControl = |
| @@ -178,37 +181,33 @@ Word EventControl(Word resetMask, Word flipMask) | |||
| 178 | 181 | ||
| 179 | /* EventInternString -- emit an Intern event on the (null-term) string given */ | 182 | /* EventInternString -- emit an Intern event on the (null-term) string given */ |
| 180 | 183 | ||
| 181 | Word EventInternString(const char *label) | 184 | EventStringId EventInternString(const char *label) |
| 182 | { | 185 | { |
| 183 | Word id; | ||
| 184 | |||
| 185 | AVER(label != NULL); | 186 | AVER(label != NULL); |
| 186 | 187 | return EventInternGenString(StringLength(label), label); | |
| 187 | id = (Word)EventInternSerial; | ||
| 188 | ++EventInternSerial; | ||
| 189 | EVENT2S(Intern, id, StringLength(label), label); | ||
| 190 | return id; | ||
| 191 | } | 188 | } |
| 192 | 189 | ||
| 193 | 190 | ||
| 194 | /* EventInternGenString -- emit an Intern event on the string given */ | 191 | /* EventInternGenString -- emit an Intern event on the string given */ |
| 195 | 192 | ||
| 196 | Word EventInternGenString(size_t len, const char *label) | 193 | EventStringId EventInternGenString(size_t len, const char *label) |
| 197 | { | 194 | { |
| 198 | Word id; | 195 | EventStringId id; |
| 199 | 196 | ||
| 200 | AVER(label != NULL); | 197 | AVER(label != NULL); |
| 201 | 198 | ||
| 202 | id = (Word)EventInternSerial; | 199 | id = EventInternSerial; |
| 203 | ++EventInternSerial; | 200 | ++EventInternSerial; |
| 201 | |||
| 204 | EVENT2S(Intern, id, len, label); | 202 | EVENT2S(Intern, id, len, label); |
| 203 | |||
| 205 | return id; | 204 | return id; |
| 206 | } | 205 | } |
| 207 | 206 | ||
| 208 | 207 | ||
| 209 | /* EventLabelAddr -- emit event to label address with the given id */ | 208 | /* EventLabelAddr -- emit event to label address with the given id */ |
| 210 | 209 | ||
| 211 | void EventLabelAddr(Addr addr, Word id) | 210 | void EventLabelAddr(Addr addr, EventStringId id) |
| 212 | { | 211 | { |
| 213 | AVER((Serial)id < EventInternSerial); | 212 | AVER((Serial)id < EventInternSerial); |
| 214 | 213 | ||
| @@ -221,13 +220,13 @@ void EventLabelAddr(Addr addr, Word id) | |||
| 221 | 220 | ||
| 222 | Res (EventSync)(void) | 221 | Res (EventSync)(void) |
| 223 | { | 222 | { |
| 224 | return(ResOK); | 223 | return ResOK; |
| 225 | } | 224 | } |
| 226 | 225 | ||
| 227 | 226 | ||
| 228 | Res (EventInit)(void) | 227 | Res (EventInit)(void) |
| 229 | { | 228 | { |
| 230 | return(ResOK); | 229 | return ResOK; |
| 231 | } | 230 | } |
| 232 | 231 | ||
| 233 | 232 | ||
| @@ -237,28 +236,28 @@ void (EventFinish)(void) | |||
| 237 | } | 236 | } |
| 238 | 237 | ||
| 239 | 238 | ||
| 240 | Word (EventControl)(Word resetMask, Word flipMask) | 239 | EventControlSet (EventControl)(EventControlSet resetMask, |
| 240 | EventControlSet flipMask) | ||
| 241 | { | 241 | { |
| 242 | UNUSED(resetMask); | 242 | UNUSED(resetMask); |
| 243 | UNUSED(flipMask); | 243 | UNUSED(flipMask); |
| 244 | 244 | return BS_EMPTY(EventControlSet); | |
| 245 | return (Word)0; | ||
| 246 | } | 245 | } |
| 247 | 246 | ||
| 248 | 247 | ||
| 249 | Word (EventInternString)(const char *label) | 248 | EventStringId (EventInternString)(const char *label) |
| 250 | { | 249 | { |
| 251 | UNUSED(label); | 250 | UNUSED(label); |
| 252 | 251 | NOTREACHED; | |
| 253 | return (Word)0; | 252 | return (EventInternString)0x9024EACH; |
| 254 | } | 253 | } |
| 255 | 254 | ||
| 256 | 255 | ||
| 257 | Word (EventInternGenString)(size_t len, const char *label) | 256 | Word (EventInternGenString)(size_t len, const char *label) |
| 258 | { | 257 | { |
| 259 | UNUSED(len); UNUSED(label); | 258 | UNUSED(len); UNUSED(label); |
| 260 | 259 | NOTREACHED; | |
| 261 | return (Word)0; | 260 | return (EventInternString)0x9024EACH; |
| 262 | } | 261 | } |
| 263 | 262 | ||
| 264 | 263 | ||
| @@ -266,6 +265,7 @@ void (EventLabelAddr)(Addr addr, Word id) | |||
| 266 | { | 265 | { |
| 267 | UNUSED(addr); | 266 | UNUSED(addr); |
| 268 | UNUSED(id); | 267 | UNUSED(id); |
| 268 | NOTREACHED; | ||
| 269 | } | 269 | } |
| 270 | 270 | ||
| 271 | 271 | ||
diff --git a/mps/code/event.h b/mps/code/event.h index 161aa32d2e5..9af0225d7fd 100644 --- a/mps/code/event.h +++ b/mps/code/event.h | |||
| @@ -20,13 +20,17 @@ | |||
| 20 | #include "eventdef.h" | 20 | #include "eventdef.h" |
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | typedef Word EventStringId; | ||
| 24 | typedef Word EventControlSet; | ||
| 25 | |||
| 23 | extern Res EventSync(void); | 26 | extern Res EventSync(void); |
| 24 | extern Res EventInit(void); | 27 | extern Res EventInit(void); |
| 25 | extern void EventFinish(void); | 28 | extern void EventFinish(void); |
| 26 | extern Word EventControl(Word, Word); | 29 | extern EventControlSet EventControl(EventControlSet resetMask, |
| 27 | extern Word EventInternString(const char *); | 30 | EventControlSet flipMask); |
| 28 | extern Word EventInternGenString(size_t, const char *); | 31 | extern EventStringId EventInternString(const char *label); |
| 29 | extern void EventLabelAddr(Addr, Word); | 32 | extern EventStringId EventInternGenString(size_t, const char *label); |
| 33 | extern void EventLabelAddr(Addr addr, Word id); | ||
| 30 | extern Res EventFlush(void); | 34 | extern Res EventFlush(void); |
| 31 | 35 | ||
| 32 | 36 | ||
| @@ -38,10 +42,13 @@ extern char *EventNext, *EventLimit; | |||
| 38 | extern Word EventKindControl; | 42 | extern Word EventKindControl; |
| 39 | 43 | ||
| 40 | 44 | ||
| 45 | /* TODO: Append a size at EventNext - sizeof(EventSize) so that a backtrace | ||
| 46 | can step backwards through the event buffer. */ | ||
| 47 | |||
| 41 | #define EVENT_BEGIN(name, structSize) \ | 48 | #define EVENT_BEGIN(name, structSize) \ |
| 42 | BEGIN \ | 49 | BEGIN \ |
| 43 | if(Event##name##Always && \ | 50 | if(/* Event##name##Always && FIXME: depend on variety */ \ |
| 44 | BS_IS_MEMBER(EventKindControl, ((Index)Event##name##Kind))) { \ | 51 | BS_IS_MEMBER(EventKindControl, (Index)Event##name##Kind)) { \ |
| 45 | Event##name##Struct *_event; \ | 52 | Event##name##Struct *_event; \ |
| 46 | size_t _size = size_tAlignUp(structSize, MPS_PF_ALIGN); \ | 53 | size_t _size = size_tAlignUp(structSize, MPS_PF_ALIGN); \ |
| 47 | if (_size > (size_t)(EventLimit - EventNext)) \ | 54 | if (_size > (size_t)(EventLimit - EventNext)) \ |
| @@ -103,14 +110,6 @@ extern Word EventKindControl; | |||
| 103 | #else /* EVENT not */ | 110 | #else /* EVENT not */ |
| 104 | 111 | ||
| 105 | 112 | ||
| 106 | #define EventInit() NOOP | ||
| 107 | #define EventFinish() NOOP | ||
| 108 | #define EventControl(r, f) (UNUSED(r), UNUSED(f), (Word)0) | ||
| 109 | #define EventInternString(s) (UNUSED(s), (Word)0) | ||
| 110 | #define EventInternGenString(l, s) (UNUSED(l), UNUSED(s), (Word)0) | ||
| 111 | #define EventLabelAddr(a, i) BEGIN UNUSED(a); UNUSED(i); END | ||
| 112 | |||
| 113 | |||
| 114 | #define EVENT0(name) NOOP | 113 | #define EVENT0(name) NOOP |
| 115 | /* The following lines were generated with | 114 | /* The following lines were generated with |
| 116 | python -c 'for i in range(1,15): print "#define EVENT%d(name, %s) NOOP" % (i, ", ".join(["p%d" % j for j in range(0, i)]))' | 115 | python -c 'for i in range(1,15): print "#define EVENT%d(name, %s) NOOP" % (i, ", ".join(["p%d" % j for j in range(0, i)]))' |