1 #ifndef _LTT_FACILITY_USER_TESTS_H_
2 #define _LTT_FACILITY_USER_TESTS_H_
5 #include <ltt/ltt-facility-id-user_tests.h>
6 #include <ltt/ltt-usertrace.h>
10 /* Event write_4bytes structures */
12 /* Event write_4bytes logging function */
13 #ifndef LTT_TRACE_FAST
14 static inline int trace_user_tests_write_4bytes(
23 size_t real_to_base
= 0; /* The buffer is allocated on arch_size alignment */
24 size_t *to_base
= &real_to_base
;
26 size_t *to
= &real_to
;
28 size_t *len
= &real_len
;
32 const void *real_from
;
33 const void **from
= &real_from
;
34 /* For each field, calculate the field size. */
35 /* size = *to_base + *to + *len */
36 /* Assume that the padding for alignment starts at a
37 * sizeof(void *) address. */
39 *from
= <tng_param_data
;
43 *to
+= ltt_align(*to
, align
); /* align output */
45 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
50 reserve_size
= *to_base
+ *to
+ *len
;
52 char stack_buffer
[reserve_size
];
53 buffer
= stack_buffer
;
55 *to_base
= *to
= *len
= 0;
57 *from
= <tng_param_data
;
61 *to
+= ltt_align(*to
, align
); /* align output */
63 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
68 /* Flush pending memcpy */
70 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
75 ret
= ltt_trace_generic(ltt_facility_user_tests_CDD24456
, event_user_tests_write_4bytes
, buffer
, reserve_size
, LTT_BLOCKING
);
82 #endif //!LTT_TRACE_FAST
85 static inline int trace_user_tests_write_4bytes(
93 struct ltt_trace_info
*trace
= thread_trace_info
;
94 struct ltt_buf
*ltt_buf
;
96 size_t real_to_base
= 0; /* The buffer is allocated on arch_size alignment */
97 size_t *to_base
= &real_to_base
;
99 size_t *to
= &real_to
;
101 size_t *len
= &real_len
;
105 const void *real_from
;
106 const void **from
= &real_from
;
108 size_t before_hdr_pad
, after_hdr_pad
, header_size
;
112 trace
= thread_trace_info
;
116 /* For each field, calculate the field size. */
117 /* size = *to_base + *to + *len */
118 /* Assume that the padding for alignment starts at a
119 * sizeof(void *) address. */
121 *from
= <tng_param_data
;
125 *to
+= ltt_align(*to
, align
); /* align output */
127 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
132 reserve_size
= *to_base
+ *to
+ *len
;
134 index
= ltt_get_index_from_facility(ltt_facility_user_tests_CDD24456
,
135 event_user_tests_write_4bytes
);
138 ltt_buf
= ltt_get_channel_from_index(trace
, index
);
140 buffer
= ltt_reserve_slot(trace
, ltt_buf
,
141 reserve_size
, &slot_size
, &tsc
,
142 &before_hdr_pad
, &after_hdr_pad
, &header_size
);
143 if(!buffer
) goto end
; /* buffer full */
145 *to_base
= *to
= *len
= 0;
147 ltt_write_event_header(trace
, ltt_buf
, buffer
,
148 ltt_facility_user_tests_CDD24456
, event_user_tests_write_4bytes
,
149 reserve_size
, before_hdr_pad
, tsc
);
150 *to_base
+= before_hdr_pad
+ after_hdr_pad
+ header_size
;
152 *from
= <tng_param_data
;
156 *to
+= ltt_align(*to
, align
); /* align output */
158 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
163 /* Flush pending memcpy */
165 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
170 ltt_commit_slot(ltt_buf
, buffer
, slot_size
);
178 #endif //LTT_TRACE_FAST
180 #endif //_LTT_FACILITY_USER_TESTS_H_