convert from svn repository: remove tags directory
[lttv.git] / trunk / obsolete / genevent / ltt-facility-test-template.h
CommitLineData
a67cd958 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
6ef4987c 10
a67cd958 11enum lttng_tasklet_priority {
12 LTTNG_LOW,
13 LTTNG_HIGH,
14};
15
16enum lttng_irq_mode {
17 LTTNG_user,
18 LTTNG_kernel,
19};
20
21struct lttng_mystruct2 {
22 unsigned int irq_id;
23 enum lttng_irq_mode mode;
24 //struct lttng_mystruct teststr1;
25};
26
6ef4987c 27
28size_t lttng_get_size_mystruct2(
a67cd958 29 struct lttng_mystruct2 *obj)
30{
6ef4987c 31 size_t size=0, locsize;
a67cd958 32
33 locsize = sizeof(unsigned int);
a67cd958 34 size += ltt_align(size, locsize) + locsize;
35
36 locsize = sizeof(enum lttng_irq_mode);
a67cd958 37 size += ltt_align(size, locsize) + locsize;
38
6ef4987c 39 BUG_ON(sizeof(struct lttng_mystruct2) != size);
40
41 return sizeof(struct lttng_mystruct2);
42}
43
44size_t lttng_get_alignment_mystruct2(
45 struct lttng_mystruct2 *obj)
46{
47 size_t align=0, localign;
a67cd958 48
6ef4987c 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;
a67cd958 56}
57
6ef4987c 58void lttng_write_mystruct2(void **to,
59 void **from,
60 size_t *len,
a67cd958 61 struct lttng_mystruct2 *obj)
62{
6ef4987c 63 size_t align, size;
a67cd958 64
6ef4987c 65 align = lttng_get_alignment_mystruct2(obj);
66 size = lttng_get_size_mystruct2(obj);
a67cd958 67
6ef4987c 68 if(*len == 0) {
69 *to += ltt_align((size_t)(*to), align); /* align output */
a67cd958 70 } else {
6ef4987c 71 *len += ltt_align((size_t)(*to+*len), align); /* C alignment, ok to do a memcpy of it */
a67cd958 72 }
73
6ef4987c 74 *len += size;
a67cd958 75}
76
77
78
79#define LTTNG_ARRAY_SIZE_mystruct_myarray 10
80typedef uint64_t lttng_array_mystruct_myarray[LTTNG_ARRAY_SIZE_mystruct_myarray];
81
6ef4987c 82size_t lttng_get_size_array_mystruct_myarray(
a67cd958 83 lttng_array_mystruct_myarray obj)
84{
6ef4987c 85 size_t size=0, locsize;
a67cd958 86
87 locsize = sizeof(uint64_t);
6ef4987c 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));
a67cd958 94
a67cd958 95 return size;
96}
97
6ef4987c 98size_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
110void lttng_write_array_mystruct_myarray(void **to,
111 void **from,
112 size_t *len,
113 lttng_array_mystruct_myarray obj)
a67cd958 114{
6ef4987c 115 size_t align, size;
a67cd958 116
6ef4987c 117 align = lttng_get_alignment_array_mystruct_myarray(obj);
118 size = lttng_get_size_array_mystruct_myarray(obj);
a67cd958 119
6ef4987c 120 if(*len == 0) {
121 *to += ltt_align((size_t)(*to), align); /* align output */
a67cd958 122 } else {
6ef4987c 123 *len += ltt_align((size_t)(*to+*len), align); /* C alignment, ok to do a memcpy of it */
a67cd958 124 }
125
6ef4987c 126 *len += size;
a67cd958 127}
128
129
130typedef struct lttng_sequence_mystruct_mysequence lttng_sequence_mystruct_mysequence;
131struct lttng_sequence_mystruct_mysequence {
132 unsigned int len;
133 double *array;
134};
135
136
6ef4987c 137size_t lttng_get_size_sequence_mystruct_mysequence(
a67cd958 138 lttng_sequence_mystruct_mysequence *obj)
139{
6ef4987c 140 size_t size=0, locsize;
a67cd958 141
142 locsize = sizeof(unsigned int);
a67cd958 143 size += ltt_align(size, locsize) + locsize;
144
145 locsize = sizeof(double);
a67cd958 146 size += ltt_align(size, locsize) + (obj->len * locsize);
147
a67cd958 148 return size;
149}
150
6ef4987c 151size_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
166void lttng_write_sequence_mystruct_mysequence(void **to,
167 void **from,
168 size_t *len,
a67cd958 169 lttng_sequence_mystruct_mysequence *obj)
170{
6ef4987c 171 size_t align, size;
172 void *varfrom;
173 size_t varlen=0;
a67cd958 174
175 /* Flush pending memcpy */
6ef4987c 176 if(*len != 0) {
177 memcpy(*to, *from, *len);
178 *to += *len;
179 *len = 0;
a67cd958 180 }
a67cd958 181
6ef4987c 182 align = lttng_get_alignment_sequence_mystruct_mysequence(obj);
183 //no need size = lttng_get_size_sequence_mystruct_mysequence(obj);
a67cd958 184
6ef4987c 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;
a67cd958 205}
206
207
208
209union lttng_mystruct_myunion {
210 double myfloat;
211 unsigned long myulong;
212};
213
6ef4987c 214
215size_t lttng_get_size_mystruct_myunion(
a67cd958 216 union lttng_mystruct_myunion *obj)
217{
6ef4987c 218 size_t size=0, locsize;
a67cd958 219
220 locsize = sizeof(double);
a67cd958 221 size = max(size, locsize);
222
223 locsize = sizeof(unsigned long);
a67cd958 224 size = max(size, locsize);
225
6ef4987c 226 BUG_ON(size != sizeof(union lttng_mystruct_myunion));
a67cd958 227
228 return size;
229}
230
231
6ef4987c 232size_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
247void lttng_write_mystruct_myunion(void **to,
248 void **from,
249 size_t *len,
a67cd958 250 union lttng_mystruct_myunion *obj)
251{
6ef4987c 252 size_t align, size;
a67cd958 253
6ef4987c 254 align = lttng_get_alignment_mystruct_myunion(obj);
255 size = lttng_get_size_mystruct_myunion(obj);
a67cd958 256
6ef4987c 257 if(*len == 0) {
258 *to += ltt_align((size_t)(*to), align); /* align output */
a67cd958 259 } else {
6ef4987c 260 *len += ltt_align((size_t)(*to+*len), align); /* C alignment, ok to do a memcpy of it */
a67cd958 261 }
262
6ef4987c 263 *len += size;
a67cd958 264}
265
266
267struct 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
6ef4987c 276size_t lttng_get_size_mystruct(
a67cd958 277 struct lttng_mystruct *obj)
278{
6ef4987c 279 size_t size=0, locsize, localign;
a67cd958 280
281 locsize = sizeof(unsigned int);
a67cd958 282 size += ltt_align(size, locsize) + locsize;
283
284 locsize = sizeof(enum lttng_irq_mode);
a67cd958 285 size += ltt_align(size, locsize) + locsize;
286
6ef4987c 287 localign = lttng_get_alignment_mystruct2(&obj->teststr);
288 locsize = lttng_get_size_mystruct2(&obj->teststr);
a67cd958 289 size += ltt_align(size, localign) + locsize;
290
6ef4987c 291 localign = lttng_get_alignment_array_mystruct_myarray(obj->myarray);
292 locsize = lttng_get_size_array_mystruct_myarray(obj->myarray);
a67cd958 293 size += ltt_align(size, localign) + locsize;
294
6ef4987c 295 localign = lttng_get_alignment_sequence_mystruct_mysequence(&obj->mysequence);
296 locsize = lttng_get_size_sequence_mystruct_mysequence(&obj->mysequence);
a67cd958 297 size += ltt_align(size, localign) + locsize;
298
6ef4987c 299 localign = lttng_get_alignment_mystruct_myunion(&obj->myunion);
300 locsize = lttng_get_size_mystruct_myunion(&obj->myunion);
a67cd958 301 size += ltt_align(size, localign) + locsize;
302
a67cd958 303 return size;
304}
305
a67cd958 306
6ef4987c 307size_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);
a67cd958 317
6ef4987c 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
333void lttng_write_mystruct(void **to,
334 void **from,
335 size_t *len,
a67cd958 336 struct lttng_mystruct *obj)
337{
6ef4987c 338 size_t align, size;
a67cd958 339
6ef4987c 340 align = lttng_get_alignment_mystruct(obj);
341 // no need : contains variable size fields.
342 // locsize = lttng_get_size_mystruct(obj);
a67cd958 343
6ef4987c 344 if(*len == 0) {
345 *to += ltt_align((size_t)(*to), align); /* align output */
a67cd958 346 } else {
6ef4987c 347 *len += ltt_align((size_t)(*to+*len), align); /* C alignment, ok to do a memcpy of it */
a67cd958 348 }
349
6ef4987c 350 /* Contains variable sized fields : must explode the structure */
a67cd958 351
6ef4987c 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;
a67cd958 357
6ef4987c 358 lttng_write_mystruct2(to, from, len, &obj->teststr);
a67cd958 359
6ef4987c 360 lttng_write_array_mystruct_myarray(to, from, len, obj->myarray);
a67cd958 361
362 /* Variable length field */
6ef4987c 363 lttng_write_sequence_mystruct_mysequence(to, from, len, &obj->mysequence);
a67cd958 364
6ef4987c 365 lttng_write_mystruct_myunion(to, from, len, &obj->myunion);
a67cd958 366
367 /* Don't forget to flush last write..... */
368}
369
370
371
6ef4987c 372
a67cd958 373/* Event syscall_entry structures */
374
375/* Event syscall_entry logging function */
376static 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 */
391static 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 */
405static 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 */
420static 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 */
434static 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 */
448static 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 */
462static 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 */
478static 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 */
494static 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 */
509static 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 */
521union lttng_test_big_array_myarray_b {
522 void * c;
523};
524
525struct 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
531typedef 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
534typedef 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 */
538static 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.057202 seconds and 4 git commands to generate.