update warning
[lttv.git] / trunk / lttv / ltt / ltt-private.h
... / ...
CommitLineData
1/* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 Xiangxiu Yang
3 * 2006 Mathieu Desnoyers
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License Version 2.1 as published by the Free Software Foundation.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 */
19
20#ifndef LTT_PRIVATE_H
21#define LTT_PRIVATE_H
22
23#include <glib.h>
24#include <sys/types.h>
25#include <ltt/ltt.h>
26#include <endian.h>
27#include <ltt/event.h>
28
29#ifndef max
30#define max(a,b) ((a)>(b)?(a):(b))
31#endif
32
33#ifndef min
34#define min(a,b) ((a)<(b)?(a):(b))
35#endif
36
37
38
39#define LTT_MAGIC_NUMBER 0x00D6B7ED
40#define LTT_REV_MAGIC_NUMBER 0xEDB7D600
41
42#define NSEC_PER_USEC 1000
43
44/* Byte ordering */
45#define LTT_GET_BO(t) ((t)->reverse_bo)
46
47#define LTT_HAS_FLOAT(t) ((t)->float_word_order ! =0)
48#define LTT_GET_FLOAT_BO(t) \
49 (((t)->float_word_order == __BYTE_ORDER) ? 0 : 1)
50
51#define SEQUENCE_AVG_ELEMENTS 1000
52
53typedef guint8 uint8_t;
54typedef guint16 uint16_t;
55typedef guint32 uint32_t;
56typedef guint64 uint64_t;
57
58/* Subbuffer header */
59struct ltt_subbuffer_header_2_0 {
60 uint64_t cycle_count_begin; /* Cycle count at subbuffer start */
61 uint64_t cycle_count_end; /* Cycle count at subbuffer end */
62 uint32_t magic_number; /* Trace magic number.
63 * contains endianness information.
64 */
65 uint8_t major_version;
66 uint8_t minor_version;
67 uint8_t arch_size; /* Architecture pointer size */
68 uint8_t alignment; /* LTT data alignment */
69 uint64_t start_time_sec; /* NTP-corrected start time */
70 uint64_t start_time_usec;
71 uint64_t start_freq; /*
72 * Frequency at trace start,
73 * used all along the trace.
74 */
75 uint32_t freq_scale; /* Frequency scaling */
76 uint32_t lost_size; /* Size unused at end of subbuffer */
77 uint32_t buf_size; /* Size of this subbuffer */
78};
79
80typedef struct ltt_subbuffer_header_2_0 ltt_subbuffer_header_t;
81
82enum field_status { FIELD_UNKNOWN, FIELD_VARIABLE, FIELD_FIXED };
83
84typedef struct _LttBuffer {
85 void * head;
86 unsigned int index;
87
88 struct {
89 LttTime timestamp;
90 uint64_t cycle_count;
91 uint64_t freq; /* Frequency in khz */
92 } begin;
93 struct {
94 LttTime timestamp;
95 uint64_t cycle_count;
96 uint64_t freq; /* Frequency in khz */
97 } end;
98 uint32_t lost_size; /* Size unused at the end of the buffer */
99
100 /* Timekeeping */
101 uint64_t tsc; /* Current timestamp counter */
102 uint64_t freq; /* Frequency in khz */
103 guint32 cyc2ns_scale;
104} LttBuffer;
105
106struct LttTracefile {
107 gboolean cpu_online; //is the cpu online ?
108 GQuark long_name; //tracefile complete filename
109 GQuark name; //tracefile name
110 guint cpu_num; //cpu number of the tracefile
111 guint tid; //Usertrace tid, else 0
112 guint pgid; //Usertrace pgid, else 0
113 guint64 creation; //Usertrace creation, else 0
114 LttTrace * trace; //trace containing the tracefile
115 int fd; //file descriptor
116 off_t file_size; //file size
117 //unsigned block_size; //block_size
118 guint num_blocks; //number of blocks in the file
119 gboolean reverse_bo; //must we reverse byte order ?
120 gboolean float_word_order; //what is the byte order of floats ?
121 size_t alignment; //alignment of events in the tracefile.
122 // 0 or the architecture size in bytes.
123
124 size_t buffer_header_size;
125 uint8_t tscbits;
126 uint8_t eventbits;
127 uint64_t tsc_mask;
128 uint64_t tsc_mask_next_bit; //next MSB after the mask
129
130 /* Current event */
131 LttEvent event; //Event currently accessible in the trace
132
133 /* Current block */
134 LttBuffer buffer; //current buffer
135 guint32 buf_size; /* The size of blocks */
136};
137
138/* The characteristics of the system on which the trace was obtained
139 is described in a LttSystemDescription structure. */
140
141struct LttSystemDescription {
142 gchar *description;
143 gchar *node_name;
144 gchar *domain_name;
145 unsigned nb_cpu;
146 LttArchSize size;
147 LttArchEndian endian;
148 gchar *kernel_name;
149 gchar *kernel_release;
150 gchar *kernel_version;
151 gchar *machine;
152 gchar *processor;
153 gchar *hardware_platform;
154 gchar *operating_system;
155 LttTime trace_start;
156 LttTime trace_end;
157};
158
159/* Calculate the offset needed to align the type.
160 * If alignment is 0, alignment is disactivated.
161 * else, the function returns the offset needed to
162 * align align_drift on the alignment value (should be
163 * the size of the architecture). */
164static inline unsigned int ltt_align(size_t align_drift,
165 size_t size_of_type,
166 size_t alignment)
167{
168 size_t align_offset = min(alignment, size_of_type);
169
170 if(!alignment)
171 return 0;
172
173 g_assert(size_of_type != 0);
174 return ((align_offset - align_drift) & (align_offset-1));
175}
176
177
178#endif /* LTT_PRIVATE_H */
This page took 0.022504 seconds and 4 git commands to generate.