+}
+
+#define BUF 512
+
+void postMsg(char *msg, va_list ap)
+{
+ EventsBuf *eb;
+ char buf[BUF];
+ nat size;
+
+ size = vsnprintf(buf,BUF,msg,ap);
+ if (size > BUF) {
+ buf[BUF-1] = '\0';
+ size = BUF;
+ }
+
+ ACQUIRE_LOCK(&eventBufMutex);
+ eb = &eventBuf;
+
+ if (!hasRoomForVariableEvent(eb, size)) {
+ // Flush event buffer to make room for new event.
+ printAndClearEventBuf(eb);
+ }
+
+ postEventTypeNum(eb, EVENT_LOG_MSG);
+ postTimestamp(eb, stat_getElapsedTime() * (1000000000LL/TICKS_PER_SECOND));
+ postPayloadSize(eb, size);
+ postBuf(eb,(StgWord8*)buf,size);
+
+ RELEASE_LOCK(&eventBufMutex);
+}
+
+void postCapMsg(Capability *cap, char *msg, va_list ap)
+{
+ EventsBuf *eb;
+ char buf[BUF];
+ nat size;
+
+ size = vsnprintf(buf,BUF,msg,ap);
+ if (size > BUF) {
+ buf[BUF-1] = '\0';
+ size = BUF;
+ }
+
+ eb = &capEventBuf[cap->no];
+
+ if (!hasRoomForVariableEvent(eb, size)) {
+ // Flush event buffer to make room for new event.
+ printAndClearEventBuf(eb);
+ }