5027 zfs large block support (add copyright)
[unleashed.git] / usr / src / uts / common / sys / sdt.h
blob6cbbe856bb41ec5dff897e09eaae971b246595aa
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
22 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2013 by Delphix. All rights reserved.
26 #ifndef _SYS_SDT_H
27 #define _SYS_SDT_H
29 #include <sys/stdint.h>
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
35 #ifndef _KERNEL
37 #define DTRACE_PROBE(provider, name) { \
38 extern void __dtrace_##provider##___##name(void); \
39 __dtrace_##provider##___##name(); \
42 #define DTRACE_PROBE1(provider, name, arg1) { \
43 extern void __dtrace_##provider##___##name(unsigned long); \
44 __dtrace_##provider##___##name((unsigned long)arg1); \
47 #define DTRACE_PROBE2(provider, name, arg1, arg2) { \
48 extern void __dtrace_##provider##___##name(unsigned long, \
49 unsigned long); \
50 __dtrace_##provider##___##name((unsigned long)arg1, \
51 (unsigned long)arg2); \
54 #define DTRACE_PROBE3(provider, name, arg1, arg2, arg3) { \
55 extern void __dtrace_##provider##___##name(unsigned long, \
56 unsigned long, unsigned long); \
57 __dtrace_##provider##___##name((unsigned long)arg1, \
58 (unsigned long)arg2, (unsigned long)arg3); \
61 #define DTRACE_PROBE4(provider, name, arg1, arg2, arg3, arg4) { \
62 extern void __dtrace_##provider##___##name(unsigned long, \
63 unsigned long, unsigned long, unsigned long); \
64 __dtrace_##provider##___##name((unsigned long)arg1, \
65 (unsigned long)arg2, (unsigned long)arg3, \
66 (unsigned long)arg4); \
69 #define DTRACE_PROBE5(provider, name, arg1, arg2, arg3, arg4, arg5) { \
70 extern void __dtrace_##provider##___##name(unsigned long, \
71 unsigned long, unsigned long, unsigned long, unsigned long);\
72 __dtrace_##provider##___##name((unsigned long)arg1, \
73 (unsigned long)arg2, (unsigned long)arg3, \
74 (unsigned long)arg4, (unsigned long)arg5); \
77 #else /* _KERNEL */
79 #define DTRACE_PROBE(name) { \
80 extern void __dtrace_probe_##name(void); \
81 __dtrace_probe_##name(); \
84 #define DTRACE_PROBE1(name, type1, arg1) { \
85 extern void __dtrace_probe_##name(uintptr_t); \
86 __dtrace_probe_##name((uintptr_t)(arg1)); \
89 #define DTRACE_PROBE2(name, type1, arg1, type2, arg2) { \
90 extern void __dtrace_probe_##name(uintptr_t, uintptr_t); \
91 __dtrace_probe_##name((uintptr_t)(arg1), (uintptr_t)(arg2)); \
94 #define DTRACE_PROBE3(name, type1, arg1, type2, arg2, type3, arg3) { \
95 extern void __dtrace_probe_##name(uintptr_t, uintptr_t, uintptr_t); \
96 __dtrace_probe_##name((uintptr_t)(arg1), (uintptr_t)(arg2), \
97 (uintptr_t)(arg3)); \
100 #define DTRACE_PROBE4(name, type1, arg1, type2, arg2, \
101 type3, arg3, type4, arg4) { \
102 extern void __dtrace_probe_##name(uintptr_t, uintptr_t, \
103 uintptr_t, uintptr_t); \
104 __dtrace_probe_##name((uintptr_t)(arg1), (uintptr_t)(arg2), \
105 (uintptr_t)(arg3), (uintptr_t)(arg4)); \
108 #define DTRACE_PROBE5(name, type1, arg1, type2, arg2, \
109 type3, arg3, type4, arg4, type5, arg5) { \
110 extern void __dtrace_probe_##name(uintptr_t, uintptr_t, \
111 uintptr_t, uintptr_t, uintptr_t); \
112 __dtrace_probe_##name((uintptr_t)(arg1), (uintptr_t)(arg2), \
113 (uintptr_t)(arg3), (uintptr_t)(arg4), (uintptr_t)(arg5)); \
116 #define DTRACE_PROBE6(name, type1, arg1, type2, arg2, \
117 type3, arg3, type4, arg4, type5, arg5, type6, arg6) { \
118 extern void __dtrace_probe_##name(uintptr_t, uintptr_t, \
119 uintptr_t, uintptr_t, uintptr_t, uintptr_t); \
120 __dtrace_probe_##name((uintptr_t)(arg1), (uintptr_t)(arg2), \
121 (uintptr_t)(arg3), (uintptr_t)(arg4), (uintptr_t)(arg5), \
122 (uintptr_t)(arg6)); \
125 #define DTRACE_PROBE7(name, type1, arg1, type2, arg2, type3, arg3, \
126 type4, arg4, type5, arg5, type6, arg6, type7, arg7) { \
127 extern void __dtrace_probe_##name(uintptr_t, uintptr_t, \
128 uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t); \
129 __dtrace_probe_##name((uintptr_t)(arg1), (uintptr_t)(arg2), \
130 (uintptr_t)(arg3), (uintptr_t)(arg4), (uintptr_t)(arg5), \
131 (uintptr_t)(arg6), (uintptr_t)(arg7)); \
134 #define DTRACE_PROBE8(name, type1, arg1, type2, arg2, type3, arg3, \
135 type4, arg4, type5, arg5, type6, arg6, type7, arg7, type8, arg8) { \
136 extern void __dtrace_probe_##name(uintptr_t, uintptr_t, \
137 uintptr_t, uintptr_t, uintptr_t, uintptr_t, \
138 uintptr_t, uintptr_t); \
139 __dtrace_probe_##name((uintptr_t)(arg1), (uintptr_t)(arg2), \
140 (uintptr_t)(arg3), (uintptr_t)(arg4), (uintptr_t)(arg5), \
141 (uintptr_t)(arg6), (uintptr_t)(arg7), (uintptr_t)(arg8)); \
144 #define DTRACE_SCHED(name) \
145 DTRACE_PROBE(__sched_##name);
147 #define DTRACE_SCHED1(name, type1, arg1) \
148 DTRACE_PROBE1(__sched_##name, type1, arg1);
150 #define DTRACE_SCHED2(name, type1, arg1, type2, arg2) \
151 DTRACE_PROBE2(__sched_##name, type1, arg1, type2, arg2);
153 #define DTRACE_SCHED3(name, type1, arg1, type2, arg2, type3, arg3) \
154 DTRACE_PROBE3(__sched_##name, type1, arg1, type2, arg2, type3, arg3);
156 #define DTRACE_SCHED4(name, type1, arg1, type2, arg2, \
157 type3, arg3, type4, arg4) \
158 DTRACE_PROBE4(__sched_##name, type1, arg1, type2, arg2, \
159 type3, arg3, type4, arg4);
161 #define DTRACE_PROC(name) \
162 DTRACE_PROBE(__proc_##name);
164 #define DTRACE_PROC1(name, type1, arg1) \
165 DTRACE_PROBE1(__proc_##name, type1, arg1);
167 #define DTRACE_PROC2(name, type1, arg1, type2, arg2) \
168 DTRACE_PROBE2(__proc_##name, type1, arg1, type2, arg2);
170 #define DTRACE_PROC3(name, type1, arg1, type2, arg2, type3, arg3) \
171 DTRACE_PROBE3(__proc_##name, type1, arg1, type2, arg2, type3, arg3);
173 #define DTRACE_PROC4(name, type1, arg1, type2, arg2, \
174 type3, arg3, type4, arg4) \
175 DTRACE_PROBE4(__proc_##name, type1, arg1, type2, arg2, \
176 type3, arg3, type4, arg4);
178 #define DTRACE_IO(name) \
179 DTRACE_PROBE(__io_##name);
181 #define DTRACE_IO1(name, type1, arg1) \
182 DTRACE_PROBE1(__io_##name, type1, arg1);
184 #define DTRACE_IO2(name, type1, arg1, type2, arg2) \
185 DTRACE_PROBE2(__io_##name, type1, arg1, type2, arg2);
187 #define DTRACE_IO3(name, type1, arg1, type2, arg2, type3, arg3) \
188 DTRACE_PROBE3(__io_##name, type1, arg1, type2, arg2, type3, arg3);
190 #define DTRACE_IO4(name, type1, arg1, type2, arg2, \
191 type3, arg3, type4, arg4) \
192 DTRACE_PROBE4(__io_##name, type1, arg1, type2, arg2, \
193 type3, arg3, type4, arg4);
195 #define DTRACE_ISCSI_2(name, type1, arg1, type2, arg2) \
196 DTRACE_PROBE2(__iscsi_##name, type1, arg1, type2, arg2);
198 #define DTRACE_ISCSI_3(name, type1, arg1, type2, arg2, type3, arg3) \
199 DTRACE_PROBE3(__iscsi_##name, type1, arg1, type2, arg2, type3, arg3);
201 #define DTRACE_ISCSI_4(name, type1, arg1, type2, arg2, \
202 type3, arg3, type4, arg4) \
203 DTRACE_PROBE4(__iscsi_##name, type1, arg1, type2, arg2, \
204 type3, arg3, type4, arg4);
206 #define DTRACE_ISCSI_5(name, type1, arg1, type2, arg2, \
207 type3, arg3, type4, arg4, type5, arg5) \
208 DTRACE_PROBE5(__iscsi_##name, type1, arg1, type2, arg2, \
209 type3, arg3, type4, arg4, type5, arg5);
211 #define DTRACE_ISCSI_6(name, type1, arg1, type2, arg2, \
212 type3, arg3, type4, arg4, type5, arg5, type6, arg6) \
213 DTRACE_PROBE6(__iscsi_##name, type1, arg1, type2, arg2, \
214 type3, arg3, type4, arg4, type5, arg5, type6, arg6);
216 #define DTRACE_ISCSI_7(name, type1, arg1, type2, arg2, \
217 type3, arg3, type4, arg4, type5, arg5, type6, arg6, type7, arg7) \
218 DTRACE_PROBE7(__iscsi_##name, type1, arg1, type2, arg2, \
219 type3, arg3, type4, arg4, type5, arg5, type6, arg6, \
220 type7, arg7);
222 #define DTRACE_ISCSI_8(name, type1, arg1, type2, arg2, \
223 type3, arg3, type4, arg4, type5, arg5, type6, arg6, \
224 type7, arg7, type8, arg8) \
225 DTRACE_PROBE8(__iscsi_##name, type1, arg1, type2, arg2, \
226 type3, arg3, type4, arg4, type5, arg5, type6, arg6, \
227 type7, arg7, type8, arg8);
229 #define DTRACE_NFSV3_3(name, type1, arg1, type2, arg2, \
230 type3, arg3) \
231 DTRACE_PROBE3(__nfsv3_##name, type1, arg1, type2, arg2, \
232 type3, arg3);
233 #define DTRACE_NFSV3_4(name, type1, arg1, type2, arg2, \
234 type3, arg3, type4, arg4) \
235 DTRACE_PROBE4(__nfsv3_##name, type1, arg1, type2, arg2, \
236 type3, arg3, type4, arg4);
238 #define DTRACE_NFSV4_1(name, type1, arg1) \
239 DTRACE_PROBE1(__nfsv4_##name, type1, arg1);
241 #define DTRACE_NFSV4_2(name, type1, arg1, type2, arg2) \
242 DTRACE_PROBE2(__nfsv4_##name, type1, arg1, type2, arg2);
244 #define DTRACE_NFSV4_3(name, type1, arg1, type2, arg2, type3, arg3) \
245 DTRACE_PROBE3(__nfsv4_##name, type1, arg1, type2, arg2, type3, arg3);
247 #define DTRACE_SMB_1(name, type1, arg1) \
248 DTRACE_PROBE1(__smb_##name, type1, arg1);
250 #define DTRACE_SMB_2(name, type1, arg1, type2, arg2) \
251 DTRACE_PROBE2(__smb_##name, type1, arg1, type2, arg2);
253 #define DTRACE_IP(name) \
254 DTRACE_PROBE(__ip_##name);
256 #define DTRACE_IP1(name, type1, arg1) \
257 DTRACE_PROBE1(__ip_##name, type1, arg1);
259 #define DTRACE_IP2(name, type1, arg1, type2, arg2) \
260 DTRACE_PROBE2(__ip_##name, type1, arg1, type2, arg2);
262 #define DTRACE_IP3(name, type1, arg1, type2, arg2, type3, arg3) \
263 DTRACE_PROBE3(__ip_##name, type1, arg1, type2, arg2, type3, arg3);
265 #define DTRACE_IP4(name, type1, arg1, type2, arg2, \
266 type3, arg3, type4, arg4) \
267 DTRACE_PROBE4(__ip_##name, type1, arg1, type2, arg2, \
268 type3, arg3, type4, arg4);
270 #define DTRACE_IP5(name, type1, arg1, type2, arg2, \
271 type3, arg3, type4, arg4, type5, arg5) \
272 DTRACE_PROBE5(__ip_##name, type1, arg1, type2, arg2, \
273 type3, arg3, type4, arg4, type5, arg5);
275 #define DTRACE_IP6(name, type1, arg1, type2, arg2, \
276 type3, arg3, type4, arg4, type5, arg5, type6, arg6) \
277 DTRACE_PROBE6(__ip_##name, type1, arg1, type2, arg2, \
278 type3, arg3, type4, arg4, type5, arg5, type6, arg6);
280 #define DTRACE_IP7(name, type1, arg1, type2, arg2, type3, arg3, \
281 type4, arg4, type5, arg5, type6, arg6, type7, arg7) \
282 DTRACE_PROBE7(__ip_##name, type1, arg1, type2, arg2, \
283 type3, arg3, type4, arg4, type5, arg5, type6, arg6, \
284 type7, arg7);
286 #define DTRACE_TCP(name) \
287 DTRACE_PROBE(__tcp_##name);
289 #define DTRACE_TCP1(name, type1, arg1) \
290 DTRACE_PROBE1(__tcp_##name, type1, arg1);
292 #define DTRACE_TCP2(name, type1, arg1, type2, arg2) \
293 DTRACE_PROBE2(__tcp_##name, type1, arg1, type2, arg2);
295 #define DTRACE_TCP3(name, type1, arg1, type2, arg2, type3, arg3) \
296 DTRACE_PROBE3(__tcp_##name, type1, arg1, type2, arg2, type3, arg3);
298 #define DTRACE_TCP4(name, type1, arg1, type2, arg2, \
299 type3, arg3, type4, arg4) \
300 DTRACE_PROBE4(__tcp_##name, type1, arg1, type2, arg2, \
301 type3, arg3, type4, arg4);
303 #define DTRACE_TCP5(name, type1, arg1, type2, arg2, \
304 type3, arg3, type4, arg4, type5, arg5) \
305 DTRACE_PROBE5(__tcp_##name, type1, arg1, type2, arg2, \
306 type3, arg3, type4, arg4, type5, arg5);
308 #define DTRACE_TCP6(name, type1, arg1, type2, arg2, \
309 type3, arg3, type4, arg4, type5, arg5, type6, arg6) \
310 DTRACE_PROBE6(__tcp_##name, type1, arg1, type2, arg2, \
311 type3, arg3, type4, arg4, type5, arg5, type6, arg6);
313 #define DTRACE_UDP(name) \
314 DTRACE_PROBE(__udp_##name);
316 #define DTRACE_UDP1(name, type1, arg1) \
317 DTRACE_PROBE1(__udp_##name, type1, arg1);
319 #define DTRACE_UDP2(name, type1, arg1, type2, arg2) \
320 DTRACE_PROBE2(__udp_##name, type1, arg1, type2, arg2);
322 #define DTRACE_UDP3(name, type1, arg1, type2, arg2, type3, arg3) \
323 DTRACE_PROBE3(__udp_##name, type1, arg1, type2, arg2, type3, arg3);
325 #define DTRACE_UDP4(name, type1, arg1, type2, arg2, \
326 type3, arg3, type4, arg4) \
327 DTRACE_PROBE4(__udp_##name, type1, arg1, type2, arg2, \
328 type3, arg3, type4, arg4);
330 #define DTRACE_UDP5(name, type1, arg1, type2, arg2, \
331 type3, arg3, type4, arg4, type5, arg5) \
332 DTRACE_PROBE5(__udp_##name, type1, arg1, type2, arg2, \
333 type3, arg3, type4, arg4, type5, arg5);
336 #define DTRACE_SYSEVENT2(name, type1, arg1, type2, arg2) \
337 DTRACE_PROBE2(__sysevent_##name, type1, arg1, type2, arg2);
339 #define DTRACE_XPV(name) \
340 DTRACE_PROBE(__xpv_##name);
342 #define DTRACE_XPV1(name, type1, arg1) \
343 DTRACE_PROBE1(__xpv_##name, type1, arg1);
345 #define DTRACE_XPV2(name, type1, arg1, type2, arg2) \
346 DTRACE_PROBE2(__xpv_##name, type1, arg1, type2, arg2);
348 #define DTRACE_XPV3(name, type1, arg1, type2, arg2, type3, arg3) \
349 DTRACE_PROBE3(__xpv_##name, type1, arg1, type2, arg2, type3, arg3);
351 #define DTRACE_XPV4(name, type1, arg1, type2, arg2, type3, arg3, \
352 type4, arg4) \
353 DTRACE_PROBE4(__xpv_##name, type1, arg1, type2, arg2, \
354 type3, arg3, type4, arg4);
356 #define DTRACE_FC_1(name, type1, arg1) \
357 DTRACE_PROBE1(__fc_##name, type1, arg1);
359 #define DTRACE_FC_2(name, type1, arg1, type2, arg2) \
360 DTRACE_PROBE2(__fc_##name, type1, arg1, type2, arg2);
362 #define DTRACE_FC_3(name, type1, arg1, type2, arg2, type3, arg3) \
363 DTRACE_PROBE3(__fc_##name, type1, arg1, type2, arg2, type3, arg3);
365 #define DTRACE_FC_4(name, type1, arg1, type2, arg2, type3, arg3, type4, arg4) \
366 DTRACE_PROBE4(__fc_##name, type1, arg1, type2, arg2, type3, arg3, \
367 type4, arg4);
369 #define DTRACE_FC_5(name, type1, arg1, type2, arg2, type3, arg3, \
370 type4, arg4, type5, arg5) \
371 DTRACE_PROBE5(__fc_##name, type1, arg1, type2, arg2, type3, arg3, \
372 type4, arg4, type5, arg5);
374 #define DTRACE_SRP_1(name, type1, arg1) \
375 DTRACE_PROBE1(__srp_##name, type1, arg1);
377 #define DTRACE_SRP_2(name, type1, arg1, type2, arg2) \
378 DTRACE_PROBE2(__srp_##name, type1, arg1, type2, arg2);
380 #define DTRACE_SRP_3(name, type1, arg1, type2, arg2, type3, arg3) \
381 DTRACE_PROBE3(__srp_##name, type1, arg1, type2, arg2, type3, arg3);
383 #define DTRACE_SRP_4(name, type1, arg1, type2, arg2, type3, arg3, \
384 type4, arg4) \
385 DTRACE_PROBE4(__srp_##name, type1, arg1, type2, arg2, \
386 type3, arg3, type4, arg4);
388 #define DTRACE_SRP_5(name, type1, arg1, type2, arg2, type3, arg3, \
389 type4, arg4, type5, arg5) \
390 DTRACE_PROBE5(__srp_##name, type1, arg1, type2, arg2, \
391 type3, arg3, type4, arg4, type5, arg5);
393 #define DTRACE_SRP_6(name, type1, arg1, type2, arg2, type3, arg3, \
394 type4, arg4, type5, arg5, type6, arg6) \
395 DTRACE_PROBE6(__srp_##name, type1, arg1, type2, arg2, \
396 type3, arg3, type4, arg4, type5, arg5, type6, arg6);
398 #define DTRACE_SRP_7(name, type1, arg1, type2, arg2, type3, arg3, \
399 type4, arg4, type5, arg5, type6, arg6, type7, arg7) \
400 DTRACE_PROBE7(__srp_##name, type1, arg1, type2, arg2, \
401 type3, arg3, type4, arg4, type5, arg5, type6, arg6, type7, arg7);
403 #define DTRACE_SRP_8(name, type1, arg1, type2, arg2, type3, arg3, \
404 type4, arg4, type5, arg5, type6, arg6, type7, arg7, type8, arg8) \
405 DTRACE_PROBE8(__srp_##name, type1, arg1, type2, arg2, \
406 type3, arg3, type4, arg4, type5, arg5, type6, arg6, \
407 type7, arg7, type8, arg8);
410 * The set-error SDT probe is extra static, in that we declare its fake
411 * function literally, rather than with the DTRACE_PROBE1() macro. This is
412 * necessary so that SET_ERROR() can evaluate to a value, which wouldn't
413 * be possible if it required multiple statements (to declare the function
414 * and then call it).
416 * SET_ERROR() uses the comma operator so that it can be used without much
417 * additional code. For example, "return (EINVAL);" becomes
418 * "return (SET_ERROR(EINVAL));". Note that the argument will be evaluated
419 * twice, so it should not have side effects (e.g. something like:
420 * "return (SET_ERROR(log_error(EINVAL, info)));" would log the error twice).
422 extern void __dtrace_probe_set__error(uintptr_t);
423 #define SET_ERROR(err) (__dtrace_probe_set__error(err), err)
425 #endif /* _KERNEL */
427 extern const char *sdt_prefix;
429 typedef struct sdt_probedesc {
430 char *sdpd_name; /* name of this probe */
431 unsigned long sdpd_offset; /* offset of call in text */
432 struct sdt_probedesc *sdpd_next; /* next static probe */
433 } sdt_probedesc_t;
435 #ifdef __cplusplus
437 #endif
439 #endif /* _SYS_SDT_H */