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-usertrace.h>
14 /* Event string structures */
15 static inline void lttng_write_string_user_generic_string_data(
26 /* Flush pending memcpy */
29 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
37 *to
+= ltt_align(*to
, align
); /* align output */
39 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
42 /* Contains variable sized fields : must explode the structure */
44 size
= strlen(obj
) + 1; /* Include final NULL char. */
46 memcpy(buffer
+*to_base
+*to
, obj
, size
);
49 /* Realign the *to_base on arch size, set *to to 0 */
50 *to
+= ltt_align(*to
, sizeof(void *));
51 *to_base
= *to_base
+*to
;
54 /* Put source *from just after the C string */
59 /* Event string logging function */
60 static inline int trace_user_generic_string(
61 const char * lttng_param_data
);
63 #ifndef LTT_TRACE_FAST
64 static inline int trace_user_generic_string(
65 const char * lttng_param_data
)
73 size_t real_to_base
= 0; /* The buffer is allocated on arch_size alignment */
74 size_t *to_base
= &real_to_base
;
76 size_t *to
= &real_to
;
78 size_t *len
= &real_len
;
81 const char *real_from
;
82 const char **from
= &real_from
;
83 /* For each field, calculate the field size. */
84 /* size = *to_base + *to + *len */
85 /* Assume that the padding for alignment starts at a
86 * sizeof(void *) address. */
88 *from
= (const char*)lttng_param_data
;
89 lttng_write_string_user_generic_string_data(buffer
, to_base
, to
, from
, len
, lttng_param_data
);
91 reserve_size
= *to_base
+ *to
+ *len
;
93 char stack_buffer
[reserve_size
];
94 buffer
= stack_buffer
;
96 *to_base
= *to
= *len
= 0;
98 *from
= (const char*)lttng_param_data
;
99 lttng_write_string_user_generic_string_data(buffer
, to_base
, to
, from
, len
, lttng_param_data
);
101 /* Flush pending memcpy */
103 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
108 ret
= ltt_trace_generic(ltt_facility_user_generic_B1865E44
, event_user_generic_string
, buffer
, reserve_size
, LTT_BLOCKING
, 0);
115 #endif //!LTT_TRACE_FAST
117 #ifdef LTT_TRACE_FAST
118 static inline int trace_user_generic_string(
119 const char * lttng_param_data
)
126 struct ltt_trace_info
*trace
= thread_trace_info
;
127 struct ltt_buf
*ltt_buf
;
129 size_t real_to_base
= 0; /* The buffer is allocated on arch_size alignment */
130 size_t *to_base
= &real_to_base
;
132 size_t *to
= &real_to
;
134 size_t *len
= &real_len
;
137 const char *real_from
;
138 const char **from
= &real_from
;
142 trace
= thread_trace_info
;
146 /* For each field, calculate the field size. */
147 /* size = *to_base + *to + *len */
148 /* Assume that the padding for alignment starts at a
149 * sizeof(void *) address. */
151 *from
= (const char*)lttng_param_data
;
152 lttng_write_string_user_generic_string_data(buffer
, to_base
, to
, from
, len
, lttng_param_data
);
154 reserve_size
= *to_base
+ *to
+ *len
;
156 index
= ltt_get_index_from_facility(ltt_facility_user_generic_B1865E44
,
157 event_user_generic_string
);
160 ltt_buf
= ltt_get_channel_from_index(trace
, index
);
162 buffer
= ltt_reserve_slot(trace
, ltt_buf
,
163 reserve_size
, &slot_size
, &tsc
);
165 goto end
; /* buffer full */
167 *to_base
= *to
= *len
= 0;
169 buffer
= ltt_write_event_header(trace
, ltt_buf
, buffer
,
170 ltt_facility_user_generic_B1865E44
, event_user_generic_string
,
172 *from
= (const char*)lttng_param_data
;
173 lttng_write_string_user_generic_string_data(buffer
, to_base
, to
, from
, len
, lttng_param_data
);
175 /* Flush pending memcpy */
177 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
182 ltt_commit_slot(ltt_buf
, buffer
, slot_size
);
190 #endif //LTT_TRACE_FAST
192 /* Event string_pointer structures */
193 static inline void lttng_write_string_user_generic_string_pointer_string(
204 /* Flush pending memcpy */
207 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
212 align
= sizeof(char);
215 *to
+= ltt_align(*to
, align
); /* align output */
217 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
220 /* Contains variable sized fields : must explode the structure */
222 size
= strlen(obj
) + 1; /* Include final NULL char. */
224 memcpy(buffer
+*to_base
+*to
, obj
, size
);
227 /* Realign the *to_base on arch size, set *to to 0 */
228 *to
+= ltt_align(*to
, sizeof(void *));
229 *to_base
= *to_base
+*to
;
232 /* Put source *from just after the C string */
237 /* Event string_pointer logging function */
238 static inline int trace_user_generic_string_pointer(
239 const char * lttng_param_string
,
240 const void * lttng_param_pointer
);
242 #ifndef LTT_TRACE_FAST
243 static inline int trace_user_generic_string_pointer(
244 const char * lttng_param_string
,
245 const void * lttng_param_pointer
)
253 size_t real_to_base
= 0; /* The buffer is allocated on arch_size alignment */
254 size_t *to_base
= &real_to_base
;
256 size_t *to
= &real_to
;
258 size_t *len
= &real_len
;
262 const char *real_from
;
263 const char **from
= &real_from
;
264 /* For each field, calculate the field size. */
265 /* size = *to_base + *to + *len */
266 /* Assume that the padding for alignment starts at a
267 * sizeof(void *) address. */
269 *from
= (const char*)lttng_param_string
;
270 lttng_write_string_user_generic_string_pointer_string(buffer
, to_base
, to
, from
, len
, lttng_param_string
);
272 *from
= (const char*)<tng_param_pointer
;
273 align
= sizeof(const void *);
276 *to
+= ltt_align(*to
, align
); /* align output */
278 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
281 *len
+= sizeof(const void *);
283 reserve_size
= *to_base
+ *to
+ *len
;
285 char stack_buffer
[reserve_size
];
286 buffer
= stack_buffer
;
288 *to_base
= *to
= *len
= 0;
290 *from
= (const char*)lttng_param_string
;
291 lttng_write_string_user_generic_string_pointer_string(buffer
, to_base
, to
, from
, len
, lttng_param_string
);
293 /* Flush pending memcpy */
295 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
300 *from
= (const char*)<tng_param_pointer
;
301 align
= sizeof(const void *);
304 *to
+= ltt_align(*to
, align
); /* align output */
306 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
309 *len
+= sizeof(const void *);
311 /* Flush pending memcpy */
313 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
318 ret
= ltt_trace_generic(ltt_facility_user_generic_B1865E44
, event_user_generic_string_pointer
, buffer
, reserve_size
, LTT_BLOCKING
, 0);
325 #endif //!LTT_TRACE_FAST
327 #ifdef LTT_TRACE_FAST
328 static inline int trace_user_generic_string_pointer(
329 const char * lttng_param_string
,
330 const void * lttng_param_pointer
)
337 struct ltt_trace_info
*trace
= thread_trace_info
;
338 struct ltt_buf
*ltt_buf
;
340 size_t real_to_base
= 0; /* The buffer is allocated on arch_size alignment */
341 size_t *to_base
= &real_to_base
;
343 size_t *to
= &real_to
;
345 size_t *len
= &real_len
;
349 const char *real_from
;
350 const char **from
= &real_from
;
354 trace
= thread_trace_info
;
358 /* For each field, calculate the field size. */
359 /* size = *to_base + *to + *len */
360 /* Assume that the padding for alignment starts at a
361 * sizeof(void *) address. */
363 *from
= (const char*)lttng_param_string
;
364 lttng_write_string_user_generic_string_pointer_string(buffer
, to_base
, to
, from
, len
, lttng_param_string
);
366 *from
= (const char*)<tng_param_pointer
;
367 align
= sizeof(const void *);
370 *to
+= ltt_align(*to
, align
); /* align output */
372 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
375 *len
+= sizeof(const void *);
377 reserve_size
= *to_base
+ *to
+ *len
;
379 index
= ltt_get_index_from_facility(ltt_facility_user_generic_B1865E44
,
380 event_user_generic_string_pointer
);
383 ltt_buf
= ltt_get_channel_from_index(trace
, index
);
385 buffer
= ltt_reserve_slot(trace
, ltt_buf
,
386 reserve_size
, &slot_size
, &tsc
);
388 goto end
; /* buffer full */
390 *to_base
= *to
= *len
= 0;
392 buffer
= ltt_write_event_header(trace
, ltt_buf
, buffer
,
393 ltt_facility_user_generic_B1865E44
, event_user_generic_string_pointer
,
395 *from
= (const char*)lttng_param_string
;
396 lttng_write_string_user_generic_string_pointer_string(buffer
, to_base
, to
, from
, len
, lttng_param_string
);
398 /* Flush pending memcpy */
400 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
405 *from
= (const char*)<tng_param_pointer
;
406 align
= sizeof(const void *);
409 *to
+= ltt_align(*to
, align
); /* align output */
411 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
414 *len
+= sizeof(const void *);
416 /* Flush pending memcpy */
418 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
423 ltt_commit_slot(ltt_buf
, buffer
, slot_size
);
431 #endif //LTT_TRACE_FAST
433 /* Event slow_printf structures */
434 static inline void lttng_write_string_user_generic_slow_printf_string(
445 /* Flush pending memcpy */
448 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
453 align
= sizeof(char);
456 *to
+= ltt_align(*to
, align
); /* align output */
458 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
461 /* Contains variable sized fields : must explode the structure */
463 size
= strlen(obj
) + 1; /* Include final NULL char. */
465 memcpy(buffer
+*to_base
+*to
, obj
, size
);
468 /* Realign the *to_base on arch size, set *to to 0 */
469 *to
+= ltt_align(*to
, sizeof(void *));
470 *to_base
= *to_base
+*to
;
473 /* Put source *from just after the C string */
478 /* Event slow_printf logging function */
479 static inline int trace_user_generic_slow_printf_param_buffer(
481 size_t reserve_size
);
483 #ifndef LTT_TRACE_FAST
484 static inline int trace_user_generic_slow_printf_param_buffer(
494 ret
= ltt_trace_generic(ltt_facility_user_generic_B1865E44
, event_user_generic_slow_printf
, buffer
, reserve_size
, LTT_BLOCKING
, 0);
501 #endif //!LTT_TRACE_FAST
503 #ifdef LTT_TRACE_FAST
504 static inline int trace_user_generic_slow_printf(
505 const char * lttng_param_string
)
512 struct ltt_trace_info
*trace
= thread_trace_info
;
513 struct ltt_buf
*ltt_buf
;
515 size_t real_to_base
= 0; /* The buffer is allocated on arch_size alignment */
516 size_t *to_base
= &real_to_base
;
518 size_t *to
= &real_to
;
520 size_t *len
= &real_len
;
523 const char *real_from
;
524 const char **from
= &real_from
;
528 trace
= thread_trace_info
;
532 /* For each field, calculate the field size. */
533 /* size = *to_base + *to + *len */
534 /* Assume that the padding for alignment starts at a
535 * sizeof(void *) address. */
537 *from
= (const char*)lttng_param_string
;
538 lttng_write_string_user_generic_slow_printf_string(buffer
, to_base
, to
, from
, len
, lttng_param_string
);
540 reserve_size
= *to_base
+ *to
+ *len
;
542 index
= ltt_get_index_from_facility(ltt_facility_user_generic_B1865E44
,
543 event_user_generic_slow_printf
);
546 ltt_buf
= ltt_get_channel_from_index(trace
, index
);
548 buffer
= ltt_reserve_slot(trace
, ltt_buf
,
549 reserve_size
, &slot_size
, &tsc
);
551 goto end
; /* buffer full */
553 *to_base
= *to
= *len
= 0;
555 buffer
= ltt_write_event_header(trace
, ltt_buf
, buffer
,
556 ltt_facility_user_generic_B1865E44
, event_user_generic_slow_printf
,
558 *from
= (const char*)lttng_param_string
;
559 lttng_write_string_user_generic_slow_printf_string(buffer
, to_base
, to
, from
, len
, lttng_param_string
);
561 /* Flush pending memcpy */
563 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
568 ltt_commit_slot(ltt_buf
, buffer
, slot_size
);
576 #endif //LTT_TRACE_FAST
578 /* Event function_entry structures */
580 /* Event function_entry logging function */
581 static inline __attribute__((no_instrument_function
)) int trace_user_generic_function_entry(
582 const void * lttng_param_this_fn
,
583 const void * lttng_param_call_site
);
585 #ifndef LTT_TRACE_FAST
586 static inline int trace_user_generic_function_entry(
587 const void * lttng_param_this_fn
,
588 const void * lttng_param_call_site
)
596 size_t real_to_base
= 0; /* The buffer is allocated on arch_size alignment */
597 size_t *to_base
= &real_to_base
;
599 size_t *to
= &real_to
;
601 size_t *len
= &real_len
;
605 const char *real_from
;
606 const char **from
= &real_from
;
607 /* For each field, calculate the field size. */
608 /* size = *to_base + *to + *len */
609 /* Assume that the padding for alignment starts at a
610 * sizeof(void *) address. */
612 *from
= (const char*)<tng_param_this_fn
;
613 align
= sizeof(const void *);
616 *to
+= ltt_align(*to
, align
); /* align output */
618 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
621 *len
+= sizeof(const void *);
623 *from
= (const char*)<tng_param_call_site
;
624 align
= sizeof(const void *);
627 *to
+= ltt_align(*to
, align
); /* align output */
629 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
632 *len
+= sizeof(const void *);
634 reserve_size
= *to_base
+ *to
+ *len
;
636 char stack_buffer
[reserve_size
];
637 buffer
= stack_buffer
;
639 *to_base
= *to
= *len
= 0;
641 *from
= (const char*)<tng_param_this_fn
;
642 align
= sizeof(const void *);
645 *to
+= ltt_align(*to
, align
); /* align output */
647 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
650 *len
+= sizeof(const void *);
652 /* Flush pending memcpy */
654 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
659 *from
= (const char*)<tng_param_call_site
;
660 align
= sizeof(const void *);
663 *to
+= ltt_align(*to
, align
); /* align output */
665 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
668 *len
+= sizeof(const void *);
670 /* Flush pending memcpy */
672 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
677 ret
= ltt_trace_generic(ltt_facility_user_generic_B1865E44
, event_user_generic_function_entry
, buffer
, reserve_size
, LTT_BLOCKING
, 0);
684 #endif //!LTT_TRACE_FAST
686 #ifdef LTT_TRACE_FAST
687 static inline __attribute__((no_instrument_function
)) int trace_user_generic_function_entry(
688 const void * lttng_param_this_fn
,
689 const void * lttng_param_call_site
)
696 struct ltt_trace_info
*trace
= thread_trace_info
;
697 struct ltt_buf
*ltt_buf
;
699 size_t real_to_base
= 0; /* The buffer is allocated on arch_size alignment */
700 size_t *to_base
= &real_to_base
;
702 size_t *to
= &real_to
;
704 size_t *len
= &real_len
;
708 const char *real_from
;
709 const char **from
= &real_from
;
713 trace
= thread_trace_info
;
717 /* For each field, calculate the field size. */
718 /* size = *to_base + *to + *len */
719 /* Assume that the padding for alignment starts at a
720 * sizeof(void *) address. */
722 *from
= (const char*)<tng_param_this_fn
;
723 align
= sizeof(const void *);
726 *to
+= ltt_align(*to
, align
); /* align output */
728 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
731 *len
+= sizeof(const void *);
733 *from
= (const char*)<tng_param_call_site
;
734 align
= sizeof(const void *);
737 *to
+= ltt_align(*to
, align
); /* align output */
739 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
742 *len
+= sizeof(const void *);
744 reserve_size
= *to_base
+ *to
+ *len
;
746 index
= ltt_get_index_from_facility(ltt_facility_user_generic_B1865E44
,
747 event_user_generic_function_entry
);
750 ltt_buf
= ltt_get_channel_from_index(trace
, index
);
752 buffer
= ltt_reserve_slot(trace
, ltt_buf
,
753 reserve_size
, &slot_size
, &tsc
);
755 goto end
; /* buffer full */
757 *to_base
= *to
= *len
= 0;
759 buffer
= ltt_write_event_header(trace
, ltt_buf
, buffer
,
760 ltt_facility_user_generic_B1865E44
, event_user_generic_function_entry
,
762 *from
= (const char*)<tng_param_this_fn
;
763 align
= sizeof(const void *);
766 *to
+= ltt_align(*to
, align
); /* align output */
768 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
771 *len
+= sizeof(const void *);
773 /* Flush pending memcpy */
775 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
780 *from
= (const char*)<tng_param_call_site
;
781 align
= sizeof(const void *);
784 *to
+= ltt_align(*to
, align
); /* align output */
786 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
789 *len
+= sizeof(const void *);
791 /* Flush pending memcpy */
793 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
798 ltt_commit_slot(ltt_buf
, buffer
, slot_size
);
806 #endif //LTT_TRACE_FAST
808 /* Event function_exit structures */
810 /* Event function_exit logging function */
811 static inline __attribute__((no_instrument_function
)) int trace_user_generic_function_exit(
812 const void * lttng_param_this_fn
,
813 const void * lttng_param_call_site
);
815 #ifndef LTT_TRACE_FAST
816 static inline int trace_user_generic_function_exit(
817 const void * lttng_param_this_fn
,
818 const void * lttng_param_call_site
)
826 size_t real_to_base
= 0; /* The buffer is allocated on arch_size alignment */
827 size_t *to_base
= &real_to_base
;
829 size_t *to
= &real_to
;
831 size_t *len
= &real_len
;
835 const char *real_from
;
836 const char **from
= &real_from
;
837 /* For each field, calculate the field size. */
838 /* size = *to_base + *to + *len */
839 /* Assume that the padding for alignment starts at a
840 * sizeof(void *) address. */
842 *from
= (const char*)<tng_param_this_fn
;
843 align
= sizeof(const void *);
846 *to
+= ltt_align(*to
, align
); /* align output */
848 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
851 *len
+= sizeof(const void *);
853 *from
= (const char*)<tng_param_call_site
;
854 align
= sizeof(const void *);
857 *to
+= ltt_align(*to
, align
); /* align output */
859 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
862 *len
+= sizeof(const void *);
864 reserve_size
= *to_base
+ *to
+ *len
;
866 char stack_buffer
[reserve_size
];
867 buffer
= stack_buffer
;
869 *to_base
= *to
= *len
= 0;
871 *from
= (const char*)<tng_param_this_fn
;
872 align
= sizeof(const void *);
875 *to
+= ltt_align(*to
, align
); /* align output */
877 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
880 *len
+= sizeof(const void *);
882 /* Flush pending memcpy */
884 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
889 *from
= (const char*)<tng_param_call_site
;
890 align
= sizeof(const void *);
893 *to
+= ltt_align(*to
, align
); /* align output */
895 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
898 *len
+= sizeof(const void *);
900 /* Flush pending memcpy */
902 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
907 ret
= ltt_trace_generic(ltt_facility_user_generic_B1865E44
, event_user_generic_function_exit
, buffer
, reserve_size
, LTT_BLOCKING
, 0);
914 #endif //!LTT_TRACE_FAST
916 #ifdef LTT_TRACE_FAST
917 static inline __attribute__((no_instrument_function
)) int trace_user_generic_function_exit(
918 const void * lttng_param_this_fn
,
919 const void * lttng_param_call_site
)
926 struct ltt_trace_info
*trace
= thread_trace_info
;
927 struct ltt_buf
*ltt_buf
;
929 size_t real_to_base
= 0; /* The buffer is allocated on arch_size alignment */
930 size_t *to_base
= &real_to_base
;
932 size_t *to
= &real_to
;
934 size_t *len
= &real_len
;
938 const char *real_from
;
939 const char **from
= &real_from
;
943 trace
= thread_trace_info
;
947 /* For each field, calculate the field size. */
948 /* size = *to_base + *to + *len */
949 /* Assume that the padding for alignment starts at a
950 * sizeof(void *) address. */
952 *from
= (const char*)<tng_param_this_fn
;
953 align
= sizeof(const void *);
956 *to
+= ltt_align(*to
, align
); /* align output */
958 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
961 *len
+= sizeof(const void *);
963 *from
= (const char*)<tng_param_call_site
;
964 align
= sizeof(const void *);
967 *to
+= ltt_align(*to
, align
); /* align output */
969 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
972 *len
+= sizeof(const void *);
974 reserve_size
= *to_base
+ *to
+ *len
;
976 index
= ltt_get_index_from_facility(ltt_facility_user_generic_B1865E44
,
977 event_user_generic_function_exit
);
980 ltt_buf
= ltt_get_channel_from_index(trace
, index
);
982 buffer
= ltt_reserve_slot(trace
, ltt_buf
,
983 reserve_size
, &slot_size
, &tsc
);
985 goto end
; /* buffer full */
987 *to_base
= *to
= *len
= 0;
989 buffer
= ltt_write_event_header(trace
, ltt_buf
, buffer
,
990 ltt_facility_user_generic_B1865E44
, event_user_generic_function_exit
,
992 *from
= (const char*)<tng_param_this_fn
;
993 align
= sizeof(const void *);
996 *to
+= ltt_align(*to
, align
); /* align output */
998 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
1001 *len
+= sizeof(const void *);
1003 /* Flush pending memcpy */
1005 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
1010 *from
= (const char*)<tng_param_call_site
;
1011 align
= sizeof(const void *);
1014 *to
+= ltt_align(*to
, align
); /* align output */
1016 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
1019 *len
+= sizeof(const void *);
1021 /* Flush pending memcpy */
1023 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
1028 ltt_commit_slot(ltt_buf
, buffer
, slot_size
);
1036 #endif //LTT_TRACE_FAST
1038 /* Event thread_brand structures */
1039 static inline void lttng_write_string_user_generic_thread_brand_name(
1050 /* Flush pending memcpy */
1053 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
1058 align
= sizeof(char);
1061 *to
+= ltt_align(*to
, align
); /* align output */
1063 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
1066 /* Contains variable sized fields : must explode the structure */
1068 size
= strlen(obj
) + 1; /* Include final NULL char. */
1070 memcpy(buffer
+*to_base
+*to
, obj
, size
);
1073 /* Realign the *to_base on arch size, set *to to 0 */
1074 *to
+= ltt_align(*to
, sizeof(void *));
1075 *to_base
= *to_base
+*to
;
1078 /* Put source *from just after the C string */
1083 /* Event thread_brand logging function */
1084 static inline int trace_user_generic_thread_brand(
1085 const char * lttng_param_name
);
1087 #ifndef LTT_TRACE_FAST
1088 static inline int trace_user_generic_thread_brand(
1089 const char * lttng_param_name
)
1096 char *buffer
= NULL
;
1097 size_t real_to_base
= 0; /* The buffer is allocated on arch_size alignment */
1098 size_t *to_base
= &real_to_base
;
1100 size_t *to
= &real_to
;
1101 size_t real_len
= 0;
1102 size_t *len
= &real_len
;
1103 size_t reserve_size
;
1105 const char *real_from
;
1106 const char **from
= &real_from
;
1107 /* For each field, calculate the field size. */
1108 /* size = *to_base + *to + *len */
1109 /* Assume that the padding for alignment starts at a
1110 * sizeof(void *) address. */
1112 *from
= (const char*)lttng_param_name
;
1113 lttng_write_string_user_generic_thread_brand_name(buffer
, to_base
, to
, from
, len
, lttng_param_name
);
1115 reserve_size
= *to_base
+ *to
+ *len
;
1117 char stack_buffer
[reserve_size
];
1118 buffer
= stack_buffer
;
1120 *to_base
= *to
= *len
= 0;
1122 *from
= (const char*)lttng_param_name
;
1123 lttng_write_string_user_generic_thread_brand_name(buffer
, to_base
, to
, from
, len
, lttng_param_name
);
1125 /* Flush pending memcpy */
1127 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
1132 ret
= ltt_trace_generic(ltt_facility_user_generic_B1865E44
, event_user_generic_thread_brand
, buffer
, reserve_size
, LTT_BLOCKING
, 1);
1139 #endif //!LTT_TRACE_FAST
1141 #ifdef LTT_TRACE_FAST
1142 static inline int trace_user_generic_thread_brand(
1143 const char * lttng_param_name
)
1150 struct ltt_trace_info
*trace
= thread_trace_info
;
1151 struct ltt_buf
*ltt_buf
;
1152 char *buffer
= NULL
;
1153 size_t real_to_base
= 0; /* The buffer is allocated on arch_size alignment */
1154 size_t *to_base
= &real_to_base
;
1156 size_t *to
= &real_to
;
1157 size_t real_len
= 0;
1158 size_t *len
= &real_len
;
1159 size_t reserve_size
;
1161 const char *real_from
;
1162 const char **from
= &real_from
;
1166 trace
= thread_trace_info
;
1170 /* For each field, calculate the field size. */
1171 /* size = *to_base + *to + *len */
1172 /* Assume that the padding for alignment starts at a
1173 * sizeof(void *) address. */
1175 *from
= (const char*)lttng_param_name
;
1176 lttng_write_string_user_generic_thread_brand_name(buffer
, to_base
, to
, from
, len
, lttng_param_name
);
1178 reserve_size
= *to_base
+ *to
+ *len
;
1180 index
= ltt_get_index_from_facility(ltt_facility_user_generic_B1865E44
,
1181 event_user_generic_thread_brand
);
1184 ltt_buf
= ltt_get_channel_from_index(trace
, index
);
1186 buffer
= ltt_reserve_slot(trace
, ltt_buf
,
1187 reserve_size
, &slot_size
, &tsc
);
1189 goto end
; /* buffer full */
1191 *to_base
= *to
= *len
= 0;
1193 buffer
= ltt_write_event_header(trace
, ltt_buf
, buffer
,
1194 ltt_facility_user_generic_B1865E44
, event_user_generic_thread_brand
,
1196 *from
= (const char*)lttng_param_name
;
1197 lttng_write_string_user_generic_thread_brand_name(buffer
, to_base
, to
, from
, len
, lttng_param_name
);
1199 /* Flush pending memcpy */
1201 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
1206 ltt_commit_slot(ltt_buf
, buffer
, slot_size
);
1214 #endif //LTT_TRACE_FAST
1217 } /* end of extern "C" */
1220 #endif //_LTT_FACILITY_USER_GENERIC_H_