some compile fix
[lttv.git] / ltt / branches / poly / ltt / event.c
1
2 #include <ltt/event.h>
3
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
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
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 {
45 ep->tracefile = e->tracefile;
46 ep->block = e->block;
47 ep->offset = e->offset;
48 ep->tsc = e->tsc;
49 }
50
51 LttEventPosition * ltt_event_position_new()
52 {
53 return g_new(LttEventPosition, 1);
54 }
55
56
57 /*****************************************************************************
58 * Function name
59 * ltt_event_position_compare : compare two positions
60 * A NULL value is infinite.
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 {
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;
80
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)
85 return -1;
86 if(ep1->block > ep2->block)
87 return 1;
88 if(ep1->offset < ep2->offset)
89 return -1;
90 if(ep1->offset > ep2->offset)
91 return 1;
92 return 0;
93 }
94
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 {
107 if(src == NULL)
108 dest = NULL;
109 else
110 *dest = *src;
111 }
112
113
114
115 LttTracefile *ltt_event_position_tracefile(LttEventPosition *ep)
116 {
117 return ep->tracefile;
118 }
119
This page took 0.032674 seconds and 5 git commands to generate.