Add fast event logging
[ghc-hetmet.git] / rts / eventlog / EventLog.h
1 /* -----------------------------------------------------------------------------
2  *
3  * (c) The GHC Team, 2008-2009
4  *
5  * Support for fast binary event logging.
6  *
7  * ---------------------------------------------------------------------------*/
8
9 #ifndef EVENTLOG_H
10 #define EVENTLOG_H
11
12 #include "Capability.h"
13 #include "EventLogFormat.h"
14
15 #ifdef EVENTLOG
16
17 /*
18  * Descriptions of EventTags for events.
19  */
20 extern char *EventTagDesc[];
21
22 void initEventLogging(void);
23 void endEventLogging(void);
24 void freeEventLogging(void);
25
26 void postEvent_(Capability *cap, EventTypeNum tag, StgThreadID id, nat from);
27
28 /* 
29  * Post an event to the capability's event buffer.
30  */
31 INLINE_HEADER void postEvent(Capability *cap, EventTypeNum tag, StgThreadID id, nat from)
32 {
33     if (RtsFlags.EventLogFlags.doEventLogging) {
34         postEvent_(cap, tag, id, from);
35     }
36 }
37
38 void printAndClearEventLog(Capability *cap);
39
40 #else /* !EVENTLOG */
41
42 INLINE_HEADER void postEvent(Capability *cap  STG_UNUSED,
43                              EventTypeNum tag STG_UNUSED,
44                              StgThreadID id   STG_UNUSED,
45                              nat from         STG_UNUSED)
46 {
47     /* nothing */
48 }
49
50 #endif
51
52 #endif /* EVENTLOG_H */