update compat
[lttv.git] / tags / LinuxTraceToolkitViewer-0.10.0-pre-115102007 / ltt / event.h
1 #ifndef _LTT_EVENT_H
2 #define _LTT_EVENT_H
3
4 #include <glib.h>
5 #include <stdint.h>
6 #include <sys/types.h>
7 #include <endian.h>
8 #include <ltt/ltt.h>
9 #include <ltt/time.h>
10 #include <ltt/marker.h>
11
12 /*
13 * Structure LttEvent and LttEventPosition must begin with the _exact_ same
14 * fields in the exact same order. LttEventPosition is a parent of LttEvent.
15 */
16 struct LttEvent {
17 /* Begin of LttEventPosition fields */
18 LttTracefile *tracefile;
19 unsigned int block;
20 unsigned int offset;
21
22 /* Timekeeping */
23 uint64_t tsc; /* Current timestamp counter */
24
25 /* End of LttEventPosition fields */
26 guint32 timestamp; /* truncated timestamp */
27
28 guint16 event_id;
29
30 LttTime event_time;
31
32 void *data; /* event data */
33 guint data_size;
34 guint event_size; /* event_size field of the header :
35 used to verify data_size from facility. */
36 uint32_t compact_data;
37
38 int count; /* the number of overflow of cycle count */
39 gint64 overflow_nsec; /* precalculated nsec for overflows */
40 };
41
42 struct LttEventPosition {
43 LttTracefile *tracefile;
44 unsigned int block;
45 unsigned int offset;
46
47 /* Timekeeping */
48 uint64_t tsc; /* Current timestamp counter */
49 };
50
51 static inline guint16 ltt_event_id(struct LttEvent *event)
52 {
53 return event->event_id;
54 }
55
56 static inline LttTime ltt_event_time(struct LttEvent *event)
57 {
58 return event->event_time;
59 }
60
61 /* Obtain the position of the event within the tracefile. This
62 is used to seek back to this position later or to seek to another
63 position, computed relative to this position. The event position
64 structure is opaque and contains several fields, only two
65 of which are user accessible: block number and event index
66 within the block. */
67
68 void ltt_event_position(LttEvent *e, LttEventPosition *ep);
69
70 LttEventPosition * ltt_event_position_new();
71
72 void ltt_event_position_get(LttEventPosition *ep, LttTracefile **tf,
73 guint *block, guint *offset, guint64 *tsc);
74
75 void ltt_event_position_set(LttEventPosition *ep, LttTracefile *tf,
76 guint block, guint offset, guint64 tsc);
77
78 gint ltt_event_position_compare(const LttEventPosition *ep1,
79 const LttEventPosition *ep2);
80
81 void ltt_event_position_copy(LttEventPosition *dest,
82 const LttEventPosition *src);
83
84 LttTracefile *ltt_event_position_tracefile(LttEventPosition *ep);
85
86 /* These functions extract data from an event after architecture specific
87 * conversions. */
88
89 guint32 ltt_event_get_unsigned(LttEvent *e, struct marker_field *f);
90
91 gint32 ltt_event_get_int(LttEvent *e, struct marker_field *f);
92
93 guint64 ltt_event_get_long_unsigned(LttEvent *e, struct marker_field *f);
94
95 gint64 ltt_event_get_long_int(LttEvent *e, struct marker_field *f);
96
97 float ltt_event_get_float(LttEvent *e, struct marker_field *f);
98
99 double ltt_event_get_double(LttEvent *e, struct marker_field *f);
100
101
102 /* The string obtained is only valid until the next read from
103 * the same tracefile. */
104
105 gchar *ltt_event_get_string(LttEvent *e, struct marker_field *f);
106
107 static inline LttCycleCount ltt_event_cycle_count(const LttEvent *e)
108 {
109 return e->tsc;
110 }
111
112 #endif //_LTT_EVENT_H
This page took 0.033086 seconds and 4 git commands to generate.