]> git.proxmox.com Git - mirror_zfs-debian.git/blob - include/sys/sdt.h
Imported Upstream version 0.6.4.2
[mirror_zfs-debian.git] / include / sys / sdt.h
1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22 /*
23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 #ifndef _SYS_SDT_H
28 #define _SYS_SDT_H
29
30 #ifndef _KERNEL
31
32 #define ZFS_PROBE(a) ((void) 0)
33 #define ZFS_PROBE1(a, c) ((void) 0)
34 #define ZFS_PROBE2(a, c, e) ((void) 0)
35 #define ZFS_PROBE3(a, c, e, g) ((void) 0)
36 #define ZFS_PROBE4(a, c, e, g, i) ((void) 0)
37 #define ZFS_SET_ERROR(err) ((void) 0)
38
39 #else
40
41 #if defined(HAVE_DECLARE_EVENT_CLASS)
42
43 #include <sys/trace.h>
44
45 /*
46 * The set-error SDT probe is extra static, in that we declare its fake
47 * function literally, rather than with the DTRACE_PROBE1() macro. This is
48 * necessary so that SET_ERROR() can evaluate to a value, which wouldn't
49 * be possible if it required multiple statements (to declare the function
50 * and then call it).
51 *
52 * SET_ERROR() uses the comma operator so that it can be used without much
53 * additional code. For example, "return (EINVAL);" becomes
54 * "return (SET_ERROR(EINVAL));". Note that the argument will be evaluated
55 * twice, so it should not have side effects (e.g. something like:
56 * "return (SET_ERROR(log_error(EINVAL, info)));" would log the error twice).
57 */
58 #define SET_ERROR(err) \
59 (trace_zfs_set__error(__FILE__, __func__, __LINE__, err), err)
60
61 #else
62
63 #undef SET_ERROR
64 #define SET_ERROR(err) (err)
65
66 #endif /* HAVE_DECLARE_EVENT_CLASS */
67
68 #endif /* _KERNEL */
69
70 #endif /* _SYS_SDT_H */