add high speed blocking test
[lttv.git] / usertrace-generic / ltt / ltt-facility-user_generic.h
CommitLineData
3d57eb5b 1#ifndef _LTT_FACILITY_USER_GENERIC_H_
2#define _LTT_FACILITY_USER_GENERIC_H_
3
4#include <sys/types.h>
5#include <ltt/ltt-facility-id-user_generic.h>
6#include <ltt/ltt-generic.h>
7
8/* Named types */
9
10/* Event string structures */
11static inline void lttng_write_string_user_generic_string_data(
12 void *buffer,
13 size_t *to_base,
14 size_t *to,
15 const void **from,
16 size_t *len,
17 const char * obj)
18{
19 size_t size;
20 size_t align;
21
22 /* Flush pending memcpy */
23 if(*len != 0) {
24 if(buffer != NULL)
25 memcpy(buffer+*to_base+*to, *from, *len);
26 }
27 *to += *len;
28 *len = 0;
29
30 align = sizeof(char);
31
32 if(*len == 0) {
33 *to += ltt_align(*to, align); /* align output */
34 } else {
35 *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
36 }
37
38 /* Contains variable sized fields : must explode the structure */
39
40 size = strlen(obj) + 1; /* Include final NULL char. */
41 if(buffer != NULL)
42 memcpy(buffer+*to_base+*to, obj, size);
43 *to += size;
44
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;
48 *to = 0;
49
50 /* Put source *from just after the C string */
51 *from += size;
52}
53
54
55/* Event string logging function */
56static inline int trace_user_generic_string(
57 const char * lttng_param_data)
58#ifndef LTT_TRACE
59{
60}
61#else
62{
63 void *buffer = NULL;
64 size_t real_to_base = 0; /* The buffer is allocated on arch_size alignment */
65 size_t *to_base = &real_to_base;
66 size_t real_to = 0;
67 size_t *to = &real_to;
68 size_t real_len = 0;
69 size_t *len = &real_len;
70 size_t reserve_size;
71 size_t slot_size;
72 int ret = 0;
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. */
79
80 *from = lttng_param_data;
81 lttng_write_string_user_generic_string_data(buffer, to_base, to, from, len, lttng_param_data);
82
83 reserve_size = *to_base + *to + *len;
84 {
85 char stack_buffer[reserve_size];
86 buffer = stack_buffer;
87
88 *to_base = *to = *len = 0;
89
90 *from = lttng_param_data;
91 lttng_write_string_user_generic_string_data(buffer, to_base, to, from, len, lttng_param_data);
92
93 /* Flush pending memcpy */
94 if(*len != 0) {
95 memcpy(buffer+*to_base+*to, *from, *len);
96 *to += *len;
97 *len = 0;
98 }
99
972a52cf 100 ret = ltt_trace_generic(ltt_facility_user_generic_411B0F83, event_user_generic_string, stack_buffer, sizeof(stack_buffer), LTT_BLOCKING);
3d57eb5b 101 }
102
103 return ret;
104
105}
106#endif //LTT_TRACE
107
108/* Event string_pointer structures */
109static inline void lttng_write_string_user_generic_string_pointer_string(
110 void *buffer,
111 size_t *to_base,
112 size_t *to,
113 const void **from,
114 size_t *len,
115 const char * obj)
116{
117 size_t size;
118 size_t align;
119
120 /* Flush pending memcpy */
121 if(*len != 0) {
122 if(buffer != NULL)
123 memcpy(buffer+*to_base+*to, *from, *len);
124 }
125 *to += *len;
126 *len = 0;
127
128 align = sizeof(char);
129
130 if(*len == 0) {
131 *to += ltt_align(*to, align); /* align output */
132 } else {
133 *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
134 }
135
136 /* Contains variable sized fields : must explode the structure */
137
138 size = strlen(obj) + 1; /* Include final NULL char. */
139 if(buffer != NULL)
140 memcpy(buffer+*to_base+*to, obj, size);
141 *to += size;
142
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;
146 *to = 0;
147
148 /* Put source *from just after the C string */
149 *from += size;
150}
151
152
153/* Event string_pointer logging function */
154static inline int trace_user_generic_string_pointer(
155 const char * lttng_param_string,
156 const void * lttng_param_pointer)
157#ifndef LTT_TRACE
158{
159}
160#else
161{
162 void *buffer = NULL;
163 size_t real_to_base = 0; /* The buffer is allocated on arch_size alignment */
164 size_t *to_base = &real_to_base;
165 size_t real_to = 0;
166 size_t *to = &real_to;
167 size_t real_len = 0;
168 size_t *len = &real_len;
169 size_t reserve_size;
170 size_t slot_size;
171 int ret = 0;
172 size_t align;
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. */
179
180 *from = lttng_param_string;
181 lttng_write_string_user_generic_string_pointer_string(buffer, to_base, to, from, len, lttng_param_string);
182
183 *from = &lttng_param_pointer;
184 align = sizeof(const void *);
185
186 if(*len == 0) {
187 *to += ltt_align(*to, align); /* align output */
188 } else {
189 *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
190 }
191
192 *len += sizeof(const void *);
193
194 reserve_size = *to_base + *to + *len;
195 {
196 char stack_buffer[reserve_size];
197 buffer = stack_buffer;
198
199 *to_base = *to = *len = 0;
200
201 *from = lttng_param_string;
202 lttng_write_string_user_generic_string_pointer_string(buffer, to_base, to, from, len, lttng_param_string);
203
204 /* Flush pending memcpy */
205 if(*len != 0) {
206 memcpy(buffer+*to_base+*to, *from, *len);
207 *to += *len;
208 *len = 0;
209 }
210
211 *from = &lttng_param_pointer;
212 align = sizeof(const void *);
213
214 if(*len == 0) {
215 *to += ltt_align(*to, align); /* align output */
216 } else {
217 *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
218 }
219
220 *len += sizeof(const void *);
221
222 /* Flush pending memcpy */
223 if(*len != 0) {
224 memcpy(buffer+*to_base+*to, *from, *len);
225 *to += *len;
226 *len = 0;
227 }
228
972a52cf 229 ret = ltt_trace_generic(ltt_facility_user_generic_411B0F83, event_user_generic_string_pointer, stack_buffer, sizeof(stack_buffer), LTT_BLOCKING);
3d57eb5b 230 }
231
232 return ret;
233
234}
235#endif //LTT_TRACE
236
237#endif //_LTT_FACILITY_USER_GENERIC_H_
This page took 0.031213 seconds and 4 git commands to generate.