]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/valgrind/src/valgrind-3.6.0-svn/callgrind/events.h
c3ddbe36c5400ac47bb24dded1cd74f1fa379192
[l4.git] / l4 / pkg / valgrind / src / valgrind-3.6.0-svn / callgrind / events.h
1 /*--------------------------------------------------------------------*/
2 /*--- Callgrind                                                    ---*/
3 /*---                                                     events.h ---*/
4 /*--- (C) 2004-2005, Josef Weidendorfer                            ---*/
5 /*--------------------------------------------------------------------*/
6
7
8 /* Abstractions for 64-bit cost lists (events.h) */
9
10 #ifndef CG_EVENTS
11 #define CG_EVENTS
12
13 #include "pub_tool_basics.h"
14
15 #define CLG_(str) VGAPPEND(vgCallgrind_,str)
16
17 /* An event type */
18 typedef struct _EventType EventType;
19 struct _EventType {
20   Char* name;
21   Char* description;
22   Int id;
23 };
24
25 EventType* CLG_(register_eventtype)(Char*);
26 EventType* CLG_(get_eventtype)(Char*);
27 EventType* CLG_(get_eventtype_byindex)(Int id);
28
29 /* An event set is a ordered list of event types, which comes down
30  * to some description for ordered lists of costs.
31  * Often, costs of 2 event types are related, e.g. one is always smaller
32  * than the other. This is useful to speed up arithmetics on cost lists:
33  * Each event type in the set has a <nextTop>. All indexes before are
34  * promised to hold smaller values than the current.
35  */
36 typedef struct _EventSetEntry EventSetEntry;
37 struct _EventSetEntry {
38   EventType* type;
39   Int nextTop;
40 };
41 typedef struct _EventSet EventSet;
42 struct _EventSet {
43   Char* name;
44   Int size;
45   Int capacity;
46   EventSetEntry e[0];
47 };
48
49
50 /* Some events out of an event set.
51  * Used to print out part of an EventSet, or in another order.
52  */
53 typedef struct _EventMapping EventMapping;
54 struct _EventMapping {
55   EventSet* set;
56   Int size;
57   Int capacity;
58   Int index[0];
59 };
60
61   
62 /* Allocate space for an event set */
63 EventSet* CLG_(get_eventset)(Char* n, Int capacity);
64 /* Incorporate a event type into a set, get start offset */
65 Int CLG_(add_eventtype)(EventSet* dst, EventType*);
66 /* Incorporate event types into a set, with ... < second < first */
67 Int CLG_(add_dep_event2)(EventSet* dst, EventType* e1, EventType* e2);
68 Int CLG_(add_dep_event3)(EventSet* dst,
69                         EventType* e1, EventType* e2, EventType* e3);
70 Int CLG_(add_dep_event4)(EventSet* dst,
71                         EventType* e1, EventType* e2, EventType* e3,
72                         EventType* e4);
73 /* Incorporate one event set into another, get start offset */
74 Int CLG_(add_eventset)(EventSet* dst, EventSet* src);
75 /* Returns number of characters written */
76 Int CLG_(sprint_eventset)(Char* buf, EventSet*);
77 /* Allocate cost array for an event set */
78 ULong* CLG_(get_eventset_cost)(EventSet*);
79
80 /* Operations on costs. A cost pointer of 0 means zero cost.
81  * Functions ending in _lz allocate costs lazy if needed
82  */
83 /* Set costs according full capacity of event set to 0 */
84 void CLG_(init_cost)(EventSet*,ULong*);
85 /* This always allocates counter and sets them to 0 */
86 void CLG_(init_cost_lz)(EventSet*,ULong**);
87 /* Set costs of an event set to zero */
88 void CLG_(zero_cost)(EventSet*,ULong*);
89 Bool CLG_(is_zero_cost)(EventSet*,ULong*);
90 Bool CLG_(is_equal_cost)(EventSet*,ULong*,ULong*);
91 void CLG_(copy_cost)(EventSet*,ULong* dst, ULong* src);
92 void CLG_(copy_cost_lz)(EventSet*,ULong** pdst, ULong* src);
93 void CLG_(add_cost)(EventSet*,ULong* dst, ULong* src);
94 void CLG_(add_cost_lz)(EventSet*,ULong** pdst, ULong* src);
95 /* Adds src to dst and zeros src. Returns false if nothing changed */
96 Bool CLG_(add_and_zero_cost)(EventSet*,ULong* dst, ULong* src);
97 Bool CLG_(add_and_zero_cost_lz)(EventSet*,ULong** pdst, ULong* src);
98 /* Adds difference of new and old to to dst, and set old to new.
99  * Returns false if nothing changed */
100 Bool CLG_(add_diff_cost)(EventSet*,ULong* dst, ULong* old, ULong* new_cost);
101 Bool CLG_(add_diff_cost_lz)(EventSet*,ULong** pdst, ULong* old, ULong* new_cost);
102 /* Returns number of characters written */
103 Int CLG_(sprint_cost)(Char* buf, EventSet*, ULong*);
104
105 /* Allocate space for an event mapping */
106 EventMapping* CLG_(get_eventmapping)(EventSet*);
107 void CLG_(append_event)(EventMapping*, Char*);
108 /* Returns number of characters written */
109 Int CLG_(sprint_eventmapping)(Char* buf, EventMapping*);
110 /* Returns number of characters written */
111 Int CLG_(sprint_mappingcost)(Char* buf, EventMapping*, ULong*);
112
113 #endif /* CG_EVENTS */