-static inline void postInt8(EventsBuf *eb, StgInt8 i);
-static inline void postInt16(EventsBuf *eb, StgInt16 i);
-static inline void postInt32(EventsBuf *eb, StgInt32 i);
-static inline void postInt64(EventsBuf *eb, StgInt64 i);
-static inline void postWord8(EventsBuf *eb, StgWord8 i);
-static inline void postWord16(EventsBuf *eb, StgWord16 i);
-static inline void postWord32(EventsBuf *eb, StgWord32 i);
-static inline void postWord64(EventsBuf *eb, StgWord64 i);
+static inline void postWord8(EventsBuf *eb, StgWord8 i)
+{
+ *(eb->pos++) = i;
+}
+
+static inline void postWord16(EventsBuf *eb, StgWord16 i)
+{
+ postWord8(eb, (StgWord8)(i >> 8));
+ postWord8(eb, (StgWord8)i);
+}
+
+static inline void postWord32(EventsBuf *eb, StgWord32 i)
+{
+ postWord16(eb, (StgWord16)(i >> 16));
+ postWord16(eb, (StgWord16)i);
+}
+
+static inline void postWord64(EventsBuf *eb, StgWord64 i)
+{
+ postWord32(eb, (StgWord32)(i >> 32));
+ postWord32(eb, (StgWord32)i);
+}
+
+static inline void postBuf(EventsBuf *eb, StgWord8 *buf, nat size)
+{
+ memcpy(eb->pos, buf, size);
+ eb->pos += size;
+}
+
+static inline StgWord64 time_ns(void)
+{ return stat_getElapsedTime() * (1000000000LL/TICKS_PER_SECOND); }
+
+static inline void postEventTypeNum(EventsBuf *eb, EventTypeNum etNum)
+{ postWord16(eb, etNum); }
+
+static inline void postTimestamp(EventsBuf *eb)
+{ postWord64(eb, time_ns()); }
+
+static inline void postThreadID(EventsBuf *eb, EventThreadID id)
+{ postWord32(eb,id); }
+
+static inline void postCapNo(EventsBuf *eb, EventCapNo no)
+{ postWord16(eb,no); }
+
+static inline void postPayloadSize(EventsBuf *eb, EventPayloadSize size)
+{ postWord16(eb,size); }
+
+static inline void postEventHeader(EventsBuf *eb, EventTypeNum type)
+{
+ postEventTypeNum(eb, type);
+ postTimestamp(eb);
+}
+
+static inline void postInt8(EventsBuf *eb, StgInt8 i)
+{ postWord8(eb, (StgWord8)i); }
+
+static inline void postInt16(EventsBuf *eb, StgInt16 i)
+{ postWord16(eb, (StgWord16)i); }
+
+static inline void postInt32(EventsBuf *eb, StgInt32 i)
+{ postWord32(eb, (StgWord32)i); }
+
+static inline void postInt64(EventsBuf *eb, StgInt64 i)
+{ postWord64(eb, (StgWord64)i); }