convert from svn repository: remove tags directory
[lttv.git] / trunk / obsolete / genevent / ltt-facility-test-template.h
1 #ifndef _LTT_FACILITY_TEST_H_
2 #define _LTT_FACILITY_TEST_H_
3
4
5 /* Facility activation at compile time. */
6 #ifdef CONFIG_LTT_FACILITY_TEST
7
8 /* Named types */
9
10
11 enum lttng_tasklet_priority {
12 LTTNG_LOW,
13 LTTNG_HIGH,
14 };
15
16 enum lttng_irq_mode {
17 LTTNG_user,
18 LTTNG_kernel,
19 };
20
21 struct lttng_mystruct2 {
22 unsigned int irq_id;
23 enum lttng_irq_mode mode;
24 //struct lttng_mystruct teststr1;
25 };
26
27
28 size_t lttng_get_size_mystruct2(
29 struct lttng_mystruct2 *obj)
30 {
31 size_t size=0, locsize;
32
33 locsize = sizeof(unsigned int);
34 size += ltt_align(size, locsize) + locsize;
35
36 locsize = sizeof(enum lttng_irq_mode);
37 size += ltt_align(size, locsize) + locsize;
38
39 BUG_ON(sizeof(struct lttng_mystruct2) != size);
40
41 return sizeof(struct lttng_mystruct2);
42 }
43
44 size_t lttng_get_alignment_mystruct2(
45 struct lttng_mystruct2 *obj)
46 {
47 size_t align=0, localign;
48
49 localign = sizeof(unsigned int);
50 align = max(align, localign);
51
52 localign = sizeof(enum lttng_irq_mode);
53 align = max(align, localign);
54
55 return align;
56 }
57
58 void lttng_write_mystruct2(void **to,
59 void **from,
60 size_t *len,
61 struct lttng_mystruct2 *obj)
62 {
63 size_t align, size;
64
65 align = lttng_get_alignment_mystruct2(obj);
66 size = lttng_get_size_mystruct2(obj);
67
68 if(*len == 0) {
69 *to += ltt_align((size_t)(*to), align); /* align output */
70 } else {
71 *len += ltt_align((size_t)(*to+*len), align); /* C alignment, ok to do a memcpy of it */
72 }
73
74 *len += size;
75 }
76
77
78
79 #define LTTNG_ARRAY_SIZE_mystruct_myarray 10
80 typedef uint64_t lttng_array_mystruct_myarray[LTTNG_ARRAY_SIZE_mystruct_myarray];
81
82 size_t lttng_get_size_array_mystruct_myarray(
83 lttng_array_mystruct_myarray obj)
84 {
85 size_t size=0, locsize;
86
87 locsize = sizeof(uint64_t);
88 /* ltt_align == 0 always*/
89 //size += ltt_align(size, locsize) + (LTTNG_ARRAY_SIZE_mystruct_myarray * locsize);
90 BUG_ON(ltt_align(size, locsize) != 0);
91 size += LTTNG_ARRAY_SIZE_mystruct_myarray * locsize;
92
93 BUG_ON(size != LTTNG_ARRAY_SIZE_mystruct_myarray * sizeof(uint64_t));
94
95 return size;
96 }
97
98 size_t lttng_get_alignment_array_mystruct_myarray(
99 lttng_array_mystruct_myarray obj)
100 {
101 size_t align=0, localign;
102
103 localign = sizeof(uint64_t);
104 align = max(align, localign);
105
106 return align;
107 }
108
109
110 void lttng_write_array_mystruct_myarray(void **to,
111 void **from,
112 size_t *len,
113 lttng_array_mystruct_myarray obj)
114 {
115 size_t align, size;
116
117 align = lttng_get_alignment_array_mystruct_myarray(obj);
118 size = lttng_get_size_array_mystruct_myarray(obj);
119
120 if(*len == 0) {
121 *to += ltt_align((size_t)(*to), align); /* align output */
122 } else {
123 *len += ltt_align((size_t)(*to+*len), align); /* C alignment, ok to do a memcpy of it */
124 }
125
126 *len += size;
127 }
128
129
130 typedef struct lttng_sequence_mystruct_mysequence lttng_sequence_mystruct_mysequence;
131 struct lttng_sequence_mystruct_mysequence {
132 unsigned int len;
133 double *array;
134 };
135
136
137 size_t lttng_get_size_sequence_mystruct_mysequence(
138 lttng_sequence_mystruct_mysequence *obj)
139 {
140 size_t size=0, locsize;
141
142 locsize = sizeof(unsigned int);
143 size += ltt_align(size, locsize) + locsize;
144
145 locsize = sizeof(double);
146 size += ltt_align(size, locsize) + (obj->len * locsize);
147
148 return size;
149 }
150
151 size_t lttng_get_alignment_sequence_mystruct_mysequence(
152 lttng_sequence_mystruct_mysequence *obj)
153 {
154 size_t align=0, localign;
155
156 localign = sizeof(unsigned int);
157 align = max(align, localign);
158
159 localign = sizeof(double);
160 align = max(align, localign);
161
162 return align;
163 }
164
165
166 void lttng_write_sequence_mystruct_mysequence(void **to,
167 void **from,
168 size_t *len,
169 lttng_sequence_mystruct_mysequence *obj)
170 {
171 size_t align, size;
172 void *varfrom;
173 size_t varlen=0;
174
175 /* Flush pending memcpy */
176 if(*len != 0) {
177 memcpy(*to, *from, *len);
178 *to += *len;
179 *len = 0;
180 }
181
182 align = lttng_get_alignment_sequence_mystruct_mysequence(obj);
183 //no need size = lttng_get_size_sequence_mystruct_mysequence(obj);
184
185 /* Align output */
186 *to += ltt_align((size_t)(*to), align);
187
188 /* Copy members */
189 *to += ltt_align((size_t)*to, sizeof(unsigned int));
190 varfrom = &obj->len;
191 varlen += sizeof(unsigned int);
192 memcpy(*to, varfrom, varlen);
193 *to += varlen;
194 varlen = 0;
195
196 *to += ltt_align((size_t)*to, sizeof(double));
197 varfrom = obj->array;
198 varlen += obj->len * sizeof(double);
199 memcpy(*to, varfrom, varlen);
200 *to += varlen;
201 varlen = 0;
202
203 /* Put source *from just after the C sequence */
204 *from = obj+1;
205 }
206
207
208
209 union lttng_mystruct_myunion {
210 double myfloat;
211 unsigned long myulong;
212 };
213
214
215 size_t lttng_get_size_mystruct_myunion(
216 union lttng_mystruct_myunion *obj)
217 {
218 size_t size=0, locsize;
219
220 locsize = sizeof(double);
221 size = max(size, locsize);
222
223 locsize = sizeof(unsigned long);
224 size = max(size, locsize);
225
226 BUG_ON(size != sizeof(union lttng_mystruct_myunion));
227
228 return size;
229 }
230
231
232 size_t lttng_get_alignment_mystruct_myunion(
233 union lttng_mystruct_myunion *obj)
234 {
235 size_t align=0, localign;
236
237 localign = sizeof(double);
238 align = max(align, localign);
239
240 localign = sizeof(unsigned long);
241 align = max(align, localign);
242
243 return align;
244 }
245
246
247 void lttng_write_mystruct_myunion(void **to,
248 void **from,
249 size_t *len,
250 union lttng_mystruct_myunion *obj)
251 {
252 size_t align, size;
253
254 align = lttng_get_alignment_mystruct_myunion(obj);
255 size = lttng_get_size_mystruct_myunion(obj);
256
257 if(*len == 0) {
258 *to += ltt_align((size_t)(*to), align); /* align output */
259 } else {
260 *len += ltt_align((size_t)(*to+*len), align); /* C alignment, ok to do a memcpy of it */
261 }
262
263 *len += size;
264 }
265
266
267 struct lttng_mystruct {
268 unsigned int irq_id;
269 enum lttng_irq_mode mode;
270 struct lttng_mystruct2 teststr;
271 lttng_array_mystruct_myarray myarray;
272 lttng_sequence_mystruct_mysequence mysequence;
273 union lttng_mystruct_myunion myunion;
274 };
275
276 size_t lttng_get_size_mystruct(
277 struct lttng_mystruct *obj)
278 {
279 size_t size=0, locsize, localign;
280
281 locsize = sizeof(unsigned int);
282 size += ltt_align(size, locsize) + locsize;
283
284 locsize = sizeof(enum lttng_irq_mode);
285 size += ltt_align(size, locsize) + locsize;
286
287 localign = lttng_get_alignment_mystruct2(&obj->teststr);
288 locsize = lttng_get_size_mystruct2(&obj->teststr);
289 size += ltt_align(size, localign) + locsize;
290
291 localign = lttng_get_alignment_array_mystruct_myarray(obj->myarray);
292 locsize = lttng_get_size_array_mystruct_myarray(obj->myarray);
293 size += ltt_align(size, localign) + locsize;
294
295 localign = lttng_get_alignment_sequence_mystruct_mysequence(&obj->mysequence);
296 locsize = lttng_get_size_sequence_mystruct_mysequence(&obj->mysequence);
297 size += ltt_align(size, localign) + locsize;
298
299 localign = lttng_get_alignment_mystruct_myunion(&obj->myunion);
300 locsize = lttng_get_size_mystruct_myunion(&obj->myunion);
301 size += ltt_align(size, localign) + locsize;
302
303 return size;
304 }
305
306
307 size_t lttng_get_alignment_mystruct(
308 struct lttng_mystruct *obj)
309 {
310 size_t align=0, localign;
311
312 localign = sizeof(unsigned int);
313 align = max(align, localign);
314
315 localign = sizeof(enum lttng_irq_mode);
316 align = max(align, localign);
317
318 localign = lttng_get_alignment_mystruct2(&obj->teststr);
319 align = max(align, localign);
320
321 localign = lttng_get_alignment_array_mystruct_myarray(obj->myarray);
322 align = max(align, localign);
323
324 localign = lttng_get_alignment_sequence_mystruct_mysequence(&obj->mysequence);
325 align = max(align, localign);
326
327 localign = lttng_get_alignment_mystruct_myunion(&obj->myunion);
328 align = max(align, localign);
329
330 return align;
331 }
332
333 void lttng_write_mystruct(void **to,
334 void **from,
335 size_t *len,
336 struct lttng_mystruct *obj)
337 {
338 size_t align, size;
339
340 align = lttng_get_alignment_mystruct(obj);
341 // no need : contains variable size fields.
342 // locsize = lttng_get_size_mystruct(obj);
343
344 if(*len == 0) {
345 *to += ltt_align((size_t)(*to), align); /* align output */
346 } else {
347 *len += ltt_align((size_t)(*to+*len), align); /* C alignment, ok to do a memcpy of it */
348 }
349
350 /* Contains variable sized fields : must explode the structure */
351
352 size = sizeof(unsigned int);
353 *len += ltt_align((size_t)(*to+*len), size) + size;
354
355 size = sizeof(enum lttng_irq_mode);
356 *len += ltt_align((size_t)(*to+*len), size) + size;
357
358 lttng_write_mystruct2(to, from, len, &obj->teststr);
359
360 lttng_write_array_mystruct_myarray(to, from, len, obj->myarray);
361
362 /* Variable length field */
363 lttng_write_sequence_mystruct_mysequence(to, from, len, &obj->mysequence);
364
365 lttng_write_mystruct_myunion(to, from, len, &obj->myunion);
366
367 /* Don't forget to flush last write..... */
368 }
369
370
371
372
373 /* Event syscall_entry structures */
374
375 /* Event syscall_entry logging function */
376 static inline void trace_test_syscall_entry(
377 unsigned int syscall_id,
378 void * address)
379 #ifndef CONFIG_LTT
380 {
381 }
382 #else
383 {
384 }
385 #endif //CONFIG_LTT
386
387
388 /* Event syscall_exit structures */
389
390 /* Event syscall_exit logging function */
391 static inline void trace_test_syscall_exit(
392 void)
393 #ifndef CONFIG_LTT
394 {
395 }
396 #else
397 {
398 }
399 #endif //CONFIG_LTT
400
401
402 /* Event trap_entry structures */
403
404 /* Event trap_entry logging function */
405 static inline void trace_test_trap_entry(
406 unsigned int trap_id,
407 void * address)
408 #ifndef CONFIG_LTT
409 {
410 }
411 #else
412 {
413 }
414 #endif //CONFIG_LTT
415
416
417 /* Event trap_exit structures */
418
419 /* Event trap_exit logging function */
420 static inline void trace_test_trap_exit(
421 void)
422 #ifndef CONFIG_LTT
423 {
424 }
425 #else
426 {
427 }
428 #endif //CONFIG_LTT
429
430
431 /* Event soft_irq_entry structures */
432
433 /* Event soft_irq_entry logging function */
434 static inline void trace_test_soft_irq_entry(
435 void * softirq_id)
436 #ifndef CONFIG_LTT
437 {
438 }
439 #else
440 {
441 }
442 #endif //CONFIG_LTT
443
444
445 /* Event soft_irq_exit structures */
446
447 /* Event soft_irq_exit logging function */
448 static inline void trace_test_soft_irq_exit(
449 void * softirq_id)
450 #ifndef CONFIG_LTT
451 {
452 }
453 #else
454 {
455 }
456 #endif //CONFIG_LTT
457
458
459 /* Event tasklet_entry structures */
460
461 /* Event tasklet_entry logging function */
462 static inline void trace_test_tasklet_entry(
463 enum lttng_tasklet_priority priority,
464 void * address,
465 unsigned long data)
466 #ifndef CONFIG_LTT
467 {
468 }
469 #else
470 {
471 }
472 #endif //CONFIG_LTT
473
474
475 /* Event tasklet_exit structures */
476
477 /* Event tasklet_exit logging function */
478 static inline void trace_test_tasklet_exit(
479 enum lttng_tasklet_priority priority,
480 void * address,
481 unsigned long data)
482 #ifndef CONFIG_LTT
483 {
484 }
485 #else
486 {
487 }
488 #endif //CONFIG_LTT
489
490
491 /* Event irq_entry structures */
492
493 /* Event irq_entry logging function */
494 static inline void trace_test_irq_entry(
495 unsigned int irq_id,
496 enum lttng_irq_mode mode)
497 #ifndef CONFIG_LTT
498 {
499 }
500 #else
501 {
502 }
503 #endif //CONFIG_LTT
504
505
506 /* Event irq_exit structures */
507
508 /* Event irq_exit logging function */
509 static inline void trace_test_irq_exit(
510 void)
511 #ifndef CONFIG_LTT
512 {
513 }
514 #else
515 {
516 }
517 #endif //CONFIG_LTT
518
519
520 /* Event big_array structures */
521 union lttng_test_big_array_myarray_b {
522 void * c;
523 };
524
525 struct lttng_test_big_array_myarray {
526 void * a;
527 union lttng_test_big_array_myarray_b b;
528 };
529
530 #define LTTNG_ARRAY_SIZE_test_big_array_myarray 2
531 typedef struct lttng_test_big_array_myarray lttng_array_test_big_array_myarray[LTTNG_ARRAY_SIZE_test_big_array_myarray];
532
533 #define LTTNG_ARRAY_SIZE_test_big_array_myarray 10000
534 typedef lttng_array_test_big_array_myarray lttng_array_test_big_array_myarray[LTTNG_ARRAY_SIZE_test_big_array_myarray];
535
536
537 /* Event big_array logging function */
538 static inline void trace_test_big_array(
539 lttng_array_test_big_array_myarray myarray)
540 #ifndef CONFIG_LTT
541 {
542 }
543 #else
544 {
545 }
546 #endif //CONFIG_LTT
547
548
549 #endif //CONFIG_LTT_FACILITY_TEST
550
551 #endif //_LTT_FACILITY_TEST_H_
This page took 0.040599 seconds and 4 git commands to generate.