1 #ifndef _LTT_FACILITY_TESTS_H_
2 #define _LTT_FACILITY_TESTS_H_
5 #include <linux/types.h>
6 #include "ltt-facility-id-tests.h"
7 #include <ltt/ltt-tracer.h>
9 #define ltt_get_index_from_facility_tests ltt_get_index_from_facility
13 /* Event write_4bytes structures */
15 /* Event write_4bytes logging function */
16 static inline void trace_tests_write_4bytes(
17 unsigned int lttng_param_value
)
20 struct ltt_channel_struct
*channel
;
21 struct ltt_trace_struct
*trace
;
24 size_t real_to_base
= 0; /* The buffer is allocated on arch_size alignment */
25 size_t *to_base
= &real_to_base
;
27 size_t *to
= &real_to
;
29 size_t *len
= &real_len
;
33 const char *real_from
;
34 const char **from
= &real_from
;
36 size_t before_hdr_pad
, after_hdr_pad
, header_size
;
38 if (ltt_traces
.num_active_traces
== 0)
41 /* For each field, calculate the field size. */
42 /* size = *to_base + *to + *len */
43 /* Assume that the padding for alignment starts at a
44 * sizeof(void *) address. */
46 *from
= (const char*)<tng_param_value
;
47 align
= sizeof(unsigned int);
50 *to
+= ltt_align(*to
, align
); /* align output */
52 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
55 *len
+= sizeof(unsigned int);
57 reserve_size
= *to_base
+ *to
+ *len
;
59 ltt_nesting
[smp_processor_id()]++;
60 index
= ltt_get_index_from_facility_tests( event_tests_write_4bytes
);
62 list_for_each_entry_rcu(trace
, <t_traces
.head
, list
) {
66 channel
= ltt_get_channel_from_index(trace
, index
);
69 buffer
= ltt_reserve_slot(trace
, channel
, &transport_data
,
70 reserve_size
, &slot_size
, &tsc
,
71 &before_hdr_pad
, &after_hdr_pad
, &header_size
);
73 continue; /* buffer full */
75 *to_base
= *to
= *len
= 0;
77 ltt_write_event_header(trace
, channel
, buffer
,
78 ltt_facility_tests_CA7F1536
, event_tests_write_4bytes
,
79 reserve_size
, before_hdr_pad
, tsc
);
80 *to_base
+= before_hdr_pad
+ after_hdr_pad
+ header_size
;
82 *from
= (const char*)<tng_param_value
;
83 align
= sizeof(unsigned int);
86 *to
+= ltt_align(*to
, align
); /* align output */
88 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
91 *len
+= sizeof(unsigned int);
93 /* Flush pending memcpy */
95 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
100 ltt_commit_slot(channel
, &transport_data
, buffer
, slot_size
);
104 ltt_nesting
[smp_processor_id()]--;
105 preempt_enable_no_resched();
108 #endif //_LTT_FACILITY_TESTS_H_