1 #ifndef _LTT_FACILITY_TEST_H_
2 #define _LTT_FACILITY_TEST_H_
5 /* Facility activation at compile time. */
6 #ifdef CONFIG_LTT_FACILITY_TEST
11 enum lttng_tasklet_priority
{
21 struct lttng_mystruct2
{
23 enum lttng_irq_mode mode
;
24 //struct lttng_mystruct teststr1;
28 size_t lttng_get_size_mystruct2(
29 struct lttng_mystruct2
*obj
)
31 size_t size
=0, locsize
;
33 locsize
= sizeof(unsigned int);
34 size
+= ltt_align(size
, locsize
) + locsize
;
36 locsize
= sizeof(enum lttng_irq_mode
);
37 size
+= ltt_align(size
, locsize
) + locsize
;
39 BUG_ON(sizeof(struct lttng_mystruct2
) != size
);
41 return sizeof(struct lttng_mystruct2
);
44 size_t lttng_get_alignment_mystruct2(
45 struct lttng_mystruct2
*obj
)
47 size_t align
=0, localign
;
49 localign
= sizeof(unsigned int);
50 align
= max(align
, localign
);
52 localign
= sizeof(enum lttng_irq_mode
);
53 align
= max(align
, localign
);
58 void lttng_write_mystruct2(void **to
,
61 struct lttng_mystruct2
*obj
)
65 align
= lttng_get_alignment_mystruct2(obj
);
66 size
= lttng_get_size_mystruct2(obj
);
69 *to
+= ltt_align((size_t)(*to
), align
); /* align output */
71 *len
+= ltt_align((size_t)(*to
+*len
), align
); /* C alignment, ok to do a memcpy of it */
79 #define LTTNG_ARRAY_SIZE_mystruct_myarray 10
80 typedef uint64_t lttng_array_mystruct_myarray
[LTTNG_ARRAY_SIZE_mystruct_myarray
];
82 size_t lttng_get_size_array_mystruct_myarray(
83 lttng_array_mystruct_myarray obj
)
85 size_t size
=0, locsize
;
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
;
93 BUG_ON(size
!= LTTNG_ARRAY_SIZE_mystruct_myarray
* sizeof(uint64_t));
98 size_t lttng_get_alignment_array_mystruct_myarray(
99 lttng_array_mystruct_myarray obj
)
101 size_t align
=0, localign
;
103 localign
= sizeof(uint64_t);
104 align
= max(align
, localign
);
110 void lttng_write_array_mystruct_myarray(void **to
,
113 lttng_array_mystruct_myarray obj
)
117 align
= lttng_get_alignment_array_mystruct_myarray(obj
);
118 size
= lttng_get_size_array_mystruct_myarray(obj
);
121 *to
+= ltt_align((size_t)(*to
), align
); /* align output */
123 *len
+= ltt_align((size_t)(*to
+*len
), align
); /* C alignment, ok to do a memcpy of it */
130 typedef struct lttng_sequence_mystruct_mysequence lttng_sequence_mystruct_mysequence
;
131 struct lttng_sequence_mystruct_mysequence
{
137 size_t lttng_get_size_sequence_mystruct_mysequence(
138 lttng_sequence_mystruct_mysequence
*obj
)
140 size_t size
=0, locsize
;
142 locsize
= sizeof(unsigned int);
143 size
+= ltt_align(size
, locsize
) + locsize
;
145 locsize
= sizeof(double);
146 size
+= ltt_align(size
, locsize
) + (obj
->len
* locsize
);
151 size_t lttng_get_alignment_sequence_mystruct_mysequence(
152 lttng_sequence_mystruct_mysequence
*obj
)
154 size_t align
=0, localign
;
156 localign
= sizeof(unsigned int);
157 align
= max(align
, localign
);
159 localign
= sizeof(double);
160 align
= max(align
, localign
);
166 void lttng_write_sequence_mystruct_mysequence(void **to
,
169 lttng_sequence_mystruct_mysequence
*obj
)
175 /* Flush pending memcpy */
177 memcpy(*to
, *from
, *len
);
182 align
= lttng_get_alignment_sequence_mystruct_mysequence(obj
);
183 //no need size = lttng_get_size_sequence_mystruct_mysequence(obj);
186 *to
+= ltt_align((size_t)(*to
), align
);
189 *to
+= ltt_align((size_t)*to
, sizeof(unsigned int));
191 varlen
+= sizeof(unsigned int);
192 memcpy(*to
, varfrom
, varlen
);
196 *to
+= ltt_align((size_t)*to
, sizeof(double));
197 varfrom
= obj
->array
;
198 varlen
+= obj
->len
* sizeof(double);
199 memcpy(*to
, varfrom
, varlen
);
203 /* Put source *from just after the C sequence */
209 union lttng_mystruct_myunion
{
211 unsigned long myulong
;
215 size_t lttng_get_size_mystruct_myunion(
216 union lttng_mystruct_myunion
*obj
)
218 size_t size
=0, locsize
;
220 locsize
= sizeof(double);
221 size
= max(size
, locsize
);
223 locsize
= sizeof(unsigned long);
224 size
= max(size
, locsize
);
226 BUG_ON(size
!= sizeof(union lttng_mystruct_myunion
));
232 size_t lttng_get_alignment_mystruct_myunion(
233 union lttng_mystruct_myunion
*obj
)
235 size_t align
=0, localign
;
237 localign
= sizeof(double);
238 align
= max(align
, localign
);
240 localign
= sizeof(unsigned long);
241 align
= max(align
, localign
);
247 void lttng_write_mystruct_myunion(void **to
,
250 union lttng_mystruct_myunion
*obj
)
254 align
= lttng_get_alignment_mystruct_myunion(obj
);
255 size
= lttng_get_size_mystruct_myunion(obj
);
258 *to
+= ltt_align((size_t)(*to
), align
); /* align output */
260 *len
+= ltt_align((size_t)(*to
+*len
), align
); /* C alignment, ok to do a memcpy of it */
267 struct lttng_mystruct
{
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
;
276 size_t lttng_get_size_mystruct(
277 struct lttng_mystruct
*obj
)
279 size_t size
=0, locsize
, localign
;
281 locsize
= sizeof(unsigned int);
282 size
+= ltt_align(size
, locsize
) + locsize
;
284 locsize
= sizeof(enum lttng_irq_mode
);
285 size
+= ltt_align(size
, locsize
) + locsize
;
287 localign
= lttng_get_alignment_mystruct2(&obj
->teststr
);
288 locsize
= lttng_get_size_mystruct2(&obj
->teststr
);
289 size
+= ltt_align(size
, localign
) + locsize
;
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
;
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
;
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
;
307 size_t lttng_get_alignment_mystruct(
308 struct lttng_mystruct
*obj
)
310 size_t align
=0, localign
;
312 localign
= sizeof(unsigned int);
313 align
= max(align
, localign
);
315 localign
= sizeof(enum lttng_irq_mode
);
316 align
= max(align
, localign
);
318 localign
= lttng_get_alignment_mystruct2(&obj
->teststr
);
319 align
= max(align
, localign
);
321 localign
= lttng_get_alignment_array_mystruct_myarray(obj
->myarray
);
322 align
= max(align
, localign
);
324 localign
= lttng_get_alignment_sequence_mystruct_mysequence(&obj
->mysequence
);
325 align
= max(align
, localign
);
327 localign
= lttng_get_alignment_mystruct_myunion(&obj
->myunion
);
328 align
= max(align
, localign
);
333 void lttng_write_mystruct(void **to
,
336 struct lttng_mystruct
*obj
)
340 align
= lttng_get_alignment_mystruct(obj
);
341 // no need : contains variable size fields.
342 // locsize = lttng_get_size_mystruct(obj);
345 *to
+= ltt_align((size_t)(*to
), align
); /* align output */
347 *len
+= ltt_align((size_t)(*to
+*len
), align
); /* C alignment, ok to do a memcpy of it */
350 /* Contains variable sized fields : must explode the structure */
352 size
= sizeof(unsigned int);
353 *len
+= ltt_align((size_t)(*to
+*len
), size
) + size
;
355 size
= sizeof(enum lttng_irq_mode
);
356 *len
+= ltt_align((size_t)(*to
+*len
), size
) + size
;
358 lttng_write_mystruct2(to
, from
, len
, &obj
->teststr
);
360 lttng_write_array_mystruct_myarray(to
, from
, len
, obj
->myarray
);
362 /* Variable length field */
363 lttng_write_sequence_mystruct_mysequence(to
, from
, len
, &obj
->mysequence
);
365 lttng_write_mystruct_myunion(to
, from
, len
, &obj
->myunion
);
367 /* Don't forget to flush last write..... */
373 /* Event syscall_entry structures */
375 /* Event syscall_entry logging function */
376 static inline void trace_test_syscall_entry(
377 unsigned int syscall_id
,
388 /* Event syscall_exit structures */
390 /* Event syscall_exit logging function */
391 static inline void trace_test_syscall_exit(
402 /* Event trap_entry structures */
404 /* Event trap_entry logging function */
405 static inline void trace_test_trap_entry(
406 unsigned int trap_id
,
417 /* Event trap_exit structures */
419 /* Event trap_exit logging function */
420 static inline void trace_test_trap_exit(
431 /* Event soft_irq_entry structures */
433 /* Event soft_irq_entry logging function */
434 static inline void trace_test_soft_irq_entry(
445 /* Event soft_irq_exit structures */
447 /* Event soft_irq_exit logging function */
448 static inline void trace_test_soft_irq_exit(
459 /* Event tasklet_entry structures */
461 /* Event tasklet_entry logging function */
462 static inline void trace_test_tasklet_entry(
463 enum lttng_tasklet_priority priority
,
475 /* Event tasklet_exit structures */
477 /* Event tasklet_exit logging function */
478 static inline void trace_test_tasklet_exit(
479 enum lttng_tasklet_priority priority
,
491 /* Event irq_entry structures */
493 /* Event irq_entry logging function */
494 static inline void trace_test_irq_entry(
496 enum lttng_irq_mode mode
)
506 /* Event irq_exit structures */
508 /* Event irq_exit logging function */
509 static inline void trace_test_irq_exit(
520 /* Event big_array structures */
521 union lttng_test_big_array_myarray_b
{
525 struct lttng_test_big_array_myarray
{
527 union lttng_test_big_array_myarray_b b
;
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
];
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
];
537 /* Event big_array logging function */
538 static inline void trace_test_big_array(
539 lttng_array_test_big_array_myarray myarray
)
549 #endif //CONFIG_LTT_FACILITY_TEST
551 #endif //_LTT_FACILITY_TEST_H_