Generic Trace Generator (GTG)  0.1
GTGOTF2_Structs.h
Go to the documentation of this file.
1 
17 #ifndef _GTG_OTF2_STRUCTS_H_
18 #define _GTG_OTF2_STRUCTS_H_
19 
20 #include <stdint.h>
21 #include "GTGList.h"
22 #include "GTGStack.h"
23 
24 /* todo: remove this */
25 #define MAX_PROCESS 64
26 
27 typedef struct __OTF2_String {
29  char* name;
30 };
31 
32 typedef otf2_id_t uint32_t;
33 
35 typedef struct StateType { /* Func group */
38  int groupId;
39  otf2_id_t id;
40  struct gtg_list token; /* stored in the stateTypes list */
41 } StateType_t;
42 
44 typedef struct State {
48  gtg_stack token; /* stored in the states list */
49 } State_t;
50 
51 /* ContainerTypes */
52 typedef struct ContainerType {
55  otf2_id_t id;
57  struct gtg_list token; /* stored in the ctType list */
59 
61 typedef struct Container {
65  otf2_id_t id;
66  struct Container *parent;
67  struct gtg_list token; /* stored in the conts list */
69  OTF2_EvtWriter *evt_writer;
70 
71 } Container_t;
72 
74 typedef struct EntityValue {
77  int groupId;
78  otf2_id_t id;
79  struct gtg_list token; /* not used */
81 
83 typedef struct EventType {
87  otf2_id_t id;
88  struct gtg_list token; /* stored in the eventTypes list */
89 } EventType_t;
90 
92 typedef struct LinkType {
98  otf2_id_t id;
99  struct gtg_list token; /* stored in the linkTypes lisk */
100 } LinkType_t;
101 
102 typedef struct Link {
104  int src;
105 } Link_t;
106 
107 
109 typedef struct VariableType {
113  otf2_id_t id;
114  struct gtg_list token; /* stored in the variableTypes list */
116 
117 typedef struct Variable {
120  uint64_t value;
121  otf2_id_t id;
122  struct gtg_list token; /* stored in the variables list */
123 } Variable_t;
124 
125 struct otf_color {
126  char *colorID;
127  uint8_t red;
128  uint8_t green;
129  uint8_t blue;
130 };
131 
132 typedef struct otf_color* otf_color_t;
133 
134 #define ContainerType_NIL 0
135 #define Container_NIL 0
136 #define StateType_NIL 0
137 #define State_NIL 0
138 #define EntityValue_NIL 0
139 #define EventType_NIL 0
140 #define LinkType_NIL 0
141 #define VariableType_NIL 0
142 #define Variable_NIL 0
143 
144 #define init_OTF2_String(var) \
145  do { \
146  (var).id = -1; \
147  (var).name = NULL; \
148  } while(0)
149 
150 
151 #define init_StateType(var) \
152  do { \
153  init_OTF2_String((var).name); \
154  init_OTF2_String((var).alias); \
155  (var).groupId = 0; \
156  (var).id = StateType_NIL; \
157  GTG_LIST_INIT(&(var).token); \
158  }while(0)
159 
160 #define init_State(var) \
161  do { \
162  (var).value = EntityValue_NIL; \
163  (var).cont = NULL; \
164  (var).stateType = NULL; \
165  GTG_STACK_INIT(&(var).token); \
166  }while(0)
167 
168 #define init_ContainerType(var) \
169  do { \
170  init_OTF2_String((var).name); \
171  init_OTF2_String((var).alias); \
172  (var).id = ContainerType_NIL; \
173  GTG_LIST_INIT(&(var).token); \
174  }while(0)
175 
176 #define init_Container(var) \
177  do { \
178  init_OTF2_String((var).name); \
179  init_OTF2_String((var).alias); \
180  (var).ctType = NULL; \
181  (var).id = Container_NIL; \
182  (var).parent = NULL; \
183  (var).ev_writer = NULL; \
184  GTG_LIST_INIT(&(var).token); \
185  GTG_STACK_INIT(&(var).state_stack.token); \
186  }while(0)
187 
188 #define init_EntityValue(var) \
189  do { \
190  init_OTF2_String((var).name); \
191  init_OTF2_String((var).alias); \
192  (var).groupId = 0; \
193  (var).id = EntityValue_NIL; \
194  GTG_LIST_INIT(&(var).token); \
195  }while(0)
196 
197 #define init_EventType(var) \
198  do { \
199  init_OTF2_String((var).name); \
200  init_OTF2_String((var).alias); \
201  (var).contType = NULL; \
202  (var).id = EventType_NIL; \
203  GTG_LIST_INIT(&(var).token); \
204  }while(0)
205 
206 #define init_LinkType(var) \
207  do { \
208  init_OTF2_String((var).name); \
209  init_OTF2_String((var).alias); \
210  (var).contType = NULL; \
211  (var).srcType = NULL; \
212  (var).destType = NULL; \
213  (var).id = LinkType_NIL; \
214  GTG_LIST_INIT(&(var).token); \
215  }while(0)
216 
217 #define init_VariableType(var) \
218  do { \
219  init_OTF2_String((var).name); \
220  init_OTF2_String((var).alias); \
221  (var).contType = NULL; \
222  (var).id = VariableType_NIL; \
223  GTG_LIST_INIT(&(var).token); \
224  }while(0)
225 
226 #define init_Variable(var) \
227  do { \
228  (var).parent = NULL; \
229  (var).type = NULL; \
230  (var).value = 0; \
231  (var).id = Variable_NIL; \
232  GTG_LIST_INIT(&(var).token); \
233  }while(0)
234 
235 
236 #define alloc_struct(ptr, type, list_head) \
237  do { \
238  ptr = (type*) malloc(sizeof(type)); \
239  GTG_LIST_INIT(&(ptr->token)); \
240  ptr->id = (gtg_list_entry((list_head)->prev, type, token)->id) + 1; \
241  gtg_list_add_tail(&(ptr->token), list_head); \
242  } while(0)
243 
244 /* warning: do not use this ! (name and alias are no longer char* ) */
245 #define alloc_init_struct(type, ptr, list_head, _name_, _alias_) \
246  do { \
247  alloc_struct(ptr, type, list_head); \
248  (ptr)->name = (char *)malloc(sizeof(char)*(strlen(_name_)+1)); \
249  strcpy((ptr)->name, _name_); \
250  (ptr)->alias = (char *)malloc(sizeof(char)*(strlen(_alias_)+1)); \
251  strcpy((ptr)->alias, _alias_); \
252  }while(0)
253 
254 #define alloc_Variable(_ptr_, _id_, _parent_, _type_, _value_) \
255  do { \
256  (_ptr_) = (Variable_t*) malloc(sizeof(Variable_t)); \
257  init_Variable(*(_ptr_)); \
258  (_ptr_)->id = _id_; \
259  (_ptr_)->parent = _parent_; \
260  (_ptr_)->type = _type_; \
261  (_ptr_)->value = _value_; \
262  }while(0)
263 
264 #define alloc_State(_ptr_, _value_, _cont_, _stateType_) \
265  do { \
266  _ptr_ = (State_t*) malloc(sizeof(State_t)); \
267  init_State(*(_ptr_)); \
268  (_ptr_)->value = _value_; \
269  (_ptr_)->cont = _cont_; \
270  (_ptr_)->stateType = _stateType_; \
271  }while(0)
272 
273 #define free_struct(_type_, _list_head_)\
274  do{\
275  _type_ *ptr, *tmp; \
276  gtg_list_for_each_entry_safe(ptr, tmp, &(_list_head_).token, token) { \
277  gtg_list_del(&(ptr->token));\
278  free(ptr->name.name);\
279  free(ptr->alias);\
280  free(ptr);\
281  }\
282  }while(0)
283 
284 #endif /* _GTG_OTF2_STRUCTS_H_ */
otf2_id_t id
Definition: GTGOTF2_Structs.h:121
OTF2_EvtWriter * evt_writer
Definition: GTGOTF2_Structs.h:69
Definition: GTGList.h:4
struct LinkType LinkType_t
Definition: GTGOTF2_Structs.h:27
struct Variable Variable_t
struct __OTF2_String name
Definition: GTGOTF2_Structs.h:84
otf2_id_t id
Definition: GTGOTF2_Structs.h:55
struct gtg_list token
Definition: GTGOTF2_Structs.h:79
Definition: GTGOTF2_Structs.h:74
otf2_id_t uint32_t
Definition: GTGOTF2_Structs.h:32
struct EventType EventType_t
Definition: GTGOTF2_Structs.h:109
struct otf_color * otf_color_t
Definition: GTGOTF2_Structs.h:132
struct VariableType VariableType_t
double varPrec
Use the double precision type for time and value.
Definition: GTGTypes.h:28
struct gtg_list token
Definition: GTGOTF2_Structs.h:88
struct __OTF2_String name
Definition: GTGOTF2_Structs.h:75
otf2_id_t id
Definition: GTGOTF2_Structs.h:113
gtg_stack token
Definition: GTGOTF2_Structs.h:48
Definition: GTGOTF2_Structs.h:92
ContainerType_t * contType
Definition: GTGOTF2_Structs.h:95
otf2_id_t id
Definition: GTGOTF2_Structs.h:87
struct gtg_list token
Definition: GTGOTF2_Structs.h:122
struct gtg_list token
Definition: GTGOTF2_Structs.h:99
struct gtg_list token
Definition: GTGOTF2_Structs.h:114
ContainerType_t * destType
Definition: GTGOTF2_Structs.h:97
Definition: GTGOTF2_Structs.h:61
Container_t * parent
Definition: GTGOTF2_Structs.h:118
uint64_t value
Definition: GTGOTF2_Structs.h:120
State_t state_stack
Definition: GTGOTF2_Structs.h:68
struct __OTF2_String alias
Definition: GTGOTF2_Structs.h:63
struct __OTF2_String alias
Definition: GTGOTF2_Structs.h:54
ContainerType_t * contType
Definition: GTGOTF2_Structs.h:86
Definition: GTGOTF2_Structs.h:52
ContainerType_t * contType
Definition: GTGOTF2_Structs.h:112
otf2_id_t id
Definition: GTGOTF2_Structs.h:78
Container_t * cont
Definition: GTGOTF2_Structs.h:46
otf2_id_t id
Definition: GTGOTF2_Structs.h:65
struct State State_t
ContainerType_t * ctType
Definition: GTGOTF2_Structs.h:64
StateType_t * stateType
Definition: GTGOTF2_Structs.h:47
struct Container * parent
Definition: GTGOTF2_Structs.h:66
struct EntityValue EntityValue_t
struct __OTF2_String name
Definition: GTGOTF2_Structs.h:53
ContainerType_t * srcType
Definition: GTGOTF2_Structs.h:96
struct __OTF2_String alias
Definition: GTGOTF2_Structs.h:111
uint8_t green
Definition: GTGOTF2_Structs.h:128
VariableType_t * type
Definition: GTGOTF2_Structs.h:119
struct __OTF2_String alias
Definition: GTGOTF2_Structs.h:94
struct __OTF2_String alias
Definition: GTGOTF2_Structs.h:37
int groupId
Definition: GTGOTF2_Structs.h:77
struct ContainerType ContainerType_t
struct __OTF2_String name
Definition: GTGOTF2_Structs.h:36
char * colorID
Definition: GTGOTF2_Structs.h:126
struct __OTF2_String alias
Definition: GTGOTF2_Structs.h:85
struct __OTF2_String name
Definition: GTGOTF2_Structs.h:110
char * name
Definition: GTGOTF2_Structs.h:29
Definition: GTGOTF2_Structs.h:83
Definition: GTGOTF2_Structs.h:125
struct __OTF2_String name
Definition: GTGOTF2_Structs.h:62
struct __OTF2_String alias
Definition: GTGOTF2_Structs.h:76
struct gtg_list token
Definition: GTGOTF2_Structs.h:57
uint8_t blue
Definition: GTGOTF2_Structs.h:129
uint8_t red
Definition: GTGOTF2_Structs.h:127
struct gtg_list token
Definition: GTGOTF2_Structs.h:40
Definition: GTGOTF2_Structs.h:44
uint32_t id
Definition: GTGOTF2_Structs.h:28
struct __OTF2_String name
Definition: GTGOTF2_Structs.h:93
struct ContainerType * parent_type
Definition: GTGOTF2_Structs.h:56
otf2_id_t id
Definition: GTGOTF2_Structs.h:39
struct gtg_list token
Definition: GTGOTF2_Structs.h:67
struct Container Container_t
struct Link Link_t
Definition: GTGOTF2_Structs.h:35
int groupId
Definition: GTGOTF2_Structs.h:38
struct StateType StateType_t
Definition: GTGOTF2_Structs.h:117
otf2_id_t id
Definition: GTGOTF2_Structs.h:98
EntityValue_t * value
Definition: GTGOTF2_Structs.h:45