449cb9d7 |
1 | |
6cd62ccf |
2 | #include <ltt/event.h> |
6cd62ccf |
3 | |
eed2ef37 |
4 | /***************************************************************************** |
5 | *Function name |
6 | * ltt_event_position_get : get the event position data |
7 | *Input params |
8 | * e : an instance of an event type |
9 | * ep : a pointer to event's position structure |
10 | * tf : tracefile pointer |
11 | * block : current block |
12 | * offset : current offset |
13 | * tsc : current tsc |
14 | ****************************************************************************/ |
15 | void ltt_event_position_get(LttEventPosition *ep, LttTracefile **tf, |
16 | guint *block, guint *offset, guint64 *tsc) |
17 | { |
18 | *tf = ep->tracefile; |
19 | *block = ep->block; |
20 | *offset = ep->offset; |
21 | *tsc = ep->tsc; |
22 | } |
23 | |
24 | |
6d0cdf22 |
25 | void ltt_event_position_set(LttEventPosition *ep, LttTracefile *tf, |
26 | guint block, guint offset, guint64 tsc) |
27 | { |
28 | ep->tracefile = tf; |
29 | ep->block = block; |
30 | ep->offset = offset; |
31 | ep->tsc = tsc; |
32 | } |
33 | |
34 | |
80da81ad |
35 | /***************************************************************************** |
36 | *Function name |
37 | * ltt_event_position : get the event's position |
38 | *Input params |
39 | * e : an instance of an event type |
40 | * ep : a pointer to event's position structure |
41 | ****************************************************************************/ |
42 | |
43 | void ltt_event_position(LttEvent *e, LttEventPosition *ep) |
44 | { |
3aee1200 |
45 | ep->tracefile = e->tracefile; |
46 | ep->block = e->block; |
47 | ep->offset = e->offset; |
48 | ep->tsc = e->tsc; |
80da81ad |
49 | } |
50 | |
a5dcde2f |
51 | LttEventPosition * ltt_event_position_new() |
52 | { |
53 | return g_new(LttEventPosition, 1); |
54 | } |
55 | |
80da81ad |
56 | |
96da5c0d |
57 | /***************************************************************************** |
58 | * Function name |
59 | * ltt_event_position_compare : compare two positions |
a00149f6 |
60 | * A NULL value is infinite. |
96da5c0d |
61 | * Input params |
62 | * ep1 : a pointer to event's position structure |
63 | * ep2 : a pointer to event's position structure |
64 | * Return |
65 | * -1 is ep1 < ep2 |
66 | * 1 if ep1 > ep2 |
67 | * 0 if ep1 == ep2 |
68 | ****************************************************************************/ |
69 | |
70 | |
71 | gint ltt_event_position_compare(const LttEventPosition *ep1, |
72 | const LttEventPosition *ep2) |
73 | { |
a00149f6 |
74 | if(ep1 == NULL && ep2 == NULL) |
75 | return 0; |
76 | if(ep1 != NULL && ep2 == NULL) |
77 | return -1; |
78 | if(ep1 == NULL && ep2 != NULL) |
79 | return 1; |
96da5c0d |
80 | |
3aee1200 |
81 | if(ep1->tracefile != ep2->tracefile) |
82 | g_error("ltt_event_position_compare on different tracefiles makes no sense"); |
83 | |
84 | if(ep1->block < ep2->block) |
96da5c0d |
85 | return -1; |
3aee1200 |
86 | if(ep1->block > ep2->block) |
96da5c0d |
87 | return 1; |
3aee1200 |
88 | if(ep1->offset < ep2->offset) |
96da5c0d |
89 | return -1; |
3aee1200 |
90 | if(ep1->offset > ep2->offset) |
96da5c0d |
91 | return 1; |
92 | return 0; |
93 | } |
94 | |
2a74fbf4 |
95 | /***************************************************************************** |
96 | * Function name |
97 | * ltt_event_position_copy : copy position |
98 | * Input params |
99 | * src : a pointer to event's position structure source |
100 | * dest : a pointer to event's position structure dest |
101 | * Return |
102 | * void |
103 | ****************************************************************************/ |
104 | void ltt_event_position_copy(LttEventPosition *dest, |
105 | const LttEventPosition *src) |
106 | { |
a00149f6 |
107 | if(src == NULL) |
108 | dest = NULL; |
109 | else |
110 | *dest = *src; |
2a74fbf4 |
111 | } |
96da5c0d |
112 | |
113 | |
27304273 |
114 | |
115 | LttTracefile *ltt_event_position_tracefile(LttEventPosition *ep) |
116 | { |
117 | return ep->tracefile; |
118 | } |
119 | |