-void postCapsetModifyEvent (EventTypeNum tag,
- EventCapsetID capset,
- StgWord32 other,
- StgWord32 other2)
-{
- ACQUIRE_LOCK(&eventBufMutex);
-
- if (!hasRoomForEvent(&eventBuf, tag)) {
- // Flush event buffer to make room for new event.
- printAndClearEventBuf(&eventBuf);
- }
-
- postEventHeader(&eventBuf, tag);
- postCapsetID(&eventBuf, capset);
-
- switch (tag) {
- case EVENT_CAPSET_CREATE: // (capset, capset_type)
- {
- postCapsetType(&eventBuf, other /* capset_type */);
- break;
- }
-
- case EVENT_CAPSET_DELETE: // (capset)
- {
- break;
- }
-
- case EVENT_CAPSET_ASSIGN_CAP: // (capset, capno)
- case EVENT_CAPSET_REMOVE_CAP: // (capset, capno)
- {
- postCapNo(&eventBuf, other /* capno */);
- break;
- }
- case EVENT_OSPROCESS_PID:
- {
- postWord32(&eventBuf, other);
- postWord32(&eventBuf, other2);
- break;
- }
- default:
- barf("postCapsetModifyEvent: unknown event tag %d", tag);
- }
-
- RELEASE_LOCK(&eventBufMutex);
-}
-
-void postCapsetStrEvent (EventTypeNum tag,
- EventCapsetID capset,
- char *msg)
-{
- int strsize = strlen(msg);
- int size = strsize + sizeof(EventCapsetID)
-
- ACQUIRE_LOCK(&eventBufMutex);
-
- if (!hasRoomForVariableEvent(&eventBuf, size)){
- printAndClearEventBuf(&eventBuf);
-
- if (!hasRoomForVariableEvent(&eventBuf, size)){
- // Event size exceeds buffer size, bail out:
- RELEASE_LOCK(&eventBufMutex);
- return;
- }
- }
-
- postEventHeader(&eventBuf, tag);
- postPayloadSize(&eventBuf, size);
- postCapsetID(&eventBuf, capset);
-
- postBuf(&eventBuf, (StgWord8*) msg, strsize);
-
- RELEASE_LOCK(&eventBufMutex);
-}
-
-void postCapsetVecEvent (EventTypeNum tag,
- EventCapsetID capset,
- int argc,
- char *argv[])
-{
- int i, size = sizeof(EventCapsetID);
-
- for (i = 0; i < argc; i++) {
- // 1 + strlen to account for the trailing \0, used as separator
- size += 1 + strlen(argv[i]);
- }
-
- ACQUIRE_LOCK(&eventBufMutex);
-
- if (!hasRoomForVariableEvent(&eventBuf, size)){
- printAndClearEventBuf(&eventBuf);
-
- if(!hasRoomForVariableEvent(&eventBuf, size)){
- // Event size exceeds buffer size, bail out:
- RELEASE_LOCK(&eventBufMutex);
- return;
- }
- }
-
- postEventHeader(&eventBuf, tag);
- postPayloadSize(&eventBuf, size);
- postCapsetID(&eventBuf, capset);
-
- for( i = 0; i < argc; i++ ) {
- // again, 1 + to account for \0
- postBuf(&eventBuf, (StgWord8*) argv[i], 1 + strlen(argv[i]));
- }
-
- RELEASE_LOCK(&eventBufMutex);
-}
-