1 #ifndef _LTT_FACILITY_USER_GENERIC_H_
2 #define _LTT_FACILITY_USER_GENERIC_H_
5 #include <ltt/ltt-facility-id-user_generic.h>
6 #include <ltt/ltt-generic.h>
10 /* Event string structures */
11 static inline void lttng_write_string_user_generic_string_data(
22 /* Flush pending memcpy */
25 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
33 *to
+= ltt_align(*to
, align
); /* align output */
35 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
38 /* Contains variable sized fields : must explode the structure */
40 size
= strlen(obj
) + 1; /* Include final NULL char. */
42 memcpy(buffer
+*to_base
+*to
, obj
, size
);
45 /* Realign the *to_base on arch size, set *to to 0 */
46 *to
+= ltt_align(*to
, sizeof(void *));
47 *to_base
= *to_base
+*to
;
50 /* Put source *from just after the C string */
55 /* Event string logging function */
56 static inline int trace_user_generic_string(
57 const char * lttng_param_data
)
65 size_t real_to_base
= 0; /* The buffer is allocated on arch_size alignment */
66 size_t *to_base
= &real_to_base
;
68 size_t *to
= &real_to
;
70 size_t *len
= &real_len
;
73 const void *real_from
;
74 const void **from
= &real_from
;
75 /* For each field, calculate the field size. */
76 /* size = *to_base + *to + *len */
77 /* Assume that the padding for alignment starts at a
78 * sizeof(void *) address. */
80 *from
= lttng_param_data
;
81 lttng_write_string_user_generic_string_data(buffer
, to_base
, to
, from
, len
, lttng_param_data
);
83 reserve_size
= *to_base
+ *to
+ *len
;
85 char stack_buffer
[reserve_size
];
86 buffer
= stack_buffer
;
88 *to_base
= *to
= *len
= 0;
90 *from
= lttng_param_data
;
91 lttng_write_string_user_generic_string_data(buffer
, to_base
, to
, from
, len
, lttng_param_data
);
93 /* Flush pending memcpy */
95 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
100 ret
= ltt_trace_generic(ltt_facility_user_generic_FB850A80
, event_user_generic_string
, buffer
, reserve_size
, LTT_BLOCKING
);
108 /* Event string_pointer structures */
109 static inline void lttng_write_string_user_generic_string_pointer_string(
120 /* Flush pending memcpy */
123 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
128 align
= sizeof(char);
131 *to
+= ltt_align(*to
, align
); /* align output */
133 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
136 /* Contains variable sized fields : must explode the structure */
138 size
= strlen(obj
) + 1; /* Include final NULL char. */
140 memcpy(buffer
+*to_base
+*to
, obj
, size
);
143 /* Realign the *to_base on arch size, set *to to 0 */
144 *to
+= ltt_align(*to
, sizeof(void *));
145 *to_base
= *to_base
+*to
;
148 /* Put source *from just after the C string */
153 /* Event string_pointer logging function */
154 static inline int trace_user_generic_string_pointer(
155 const char * lttng_param_string
,
156 const void * lttng_param_pointer
)
164 size_t real_to_base
= 0; /* The buffer is allocated on arch_size alignment */
165 size_t *to_base
= &real_to_base
;
167 size_t *to
= &real_to
;
169 size_t *len
= &real_len
;
173 const void *real_from
;
174 const void **from
= &real_from
;
175 /* For each field, calculate the field size. */
176 /* size = *to_base + *to + *len */
177 /* Assume that the padding for alignment starts at a
178 * sizeof(void *) address. */
180 *from
= lttng_param_string
;
181 lttng_write_string_user_generic_string_pointer_string(buffer
, to_base
, to
, from
, len
, lttng_param_string
);
183 *from
= <tng_param_pointer
;
184 align
= sizeof(const void *);
187 *to
+= ltt_align(*to
, align
); /* align output */
189 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
192 *len
+= sizeof(const void *);
194 reserve_size
= *to_base
+ *to
+ *len
;
196 char stack_buffer
[reserve_size
];
197 buffer
= stack_buffer
;
199 *to_base
= *to
= *len
= 0;
201 *from
= lttng_param_string
;
202 lttng_write_string_user_generic_string_pointer_string(buffer
, to_base
, to
, from
, len
, lttng_param_string
);
204 /* Flush pending memcpy */
206 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
211 *from
= <tng_param_pointer
;
212 align
= sizeof(const void *);
215 *to
+= ltt_align(*to
, align
); /* align output */
217 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
220 *len
+= sizeof(const void *);
222 /* Flush pending memcpy */
224 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
229 ret
= ltt_trace_generic(ltt_facility_user_generic_FB850A80
, event_user_generic_string_pointer
, buffer
, reserve_size
, LTT_BLOCKING
);
237 /* Event slow_printf structures */
238 static inline void lttng_write_string_user_generic_slow_printf_string(
249 /* Flush pending memcpy */
252 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
257 align
= sizeof(char);
260 *to
+= ltt_align(*to
, align
); /* align output */
262 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
265 /* Contains variable sized fields : must explode the structure */
267 size
= strlen(obj
) + 1; /* Include final NULL char. */
269 memcpy(buffer
+*to_base
+*to
, obj
, size
);
272 /* Realign the *to_base on arch size, set *to to 0 */
273 *to
+= ltt_align(*to
, sizeof(void *));
274 *to_base
= *to_base
+*to
;
277 /* Put source *from just after the C string */
282 /* Event slow_printf logging function */
283 static inline int trace_user_generic_slow_printf_param_buffer(
292 reserve_size
+= ltt_align(reserve_size
, sizeof(void *));
294 ret
= ltt_trace_generic(ltt_facility_user_generic_FB850A80
, event_user_generic_slow_printf
, buffer
, reserve_size
, LTT_BLOCKING
);
302 #endif //_LTT_FACILITY_USER_GENERIC_H_