d469235b5ad1f03a141cd45dda9b57d4ad30c2f1
[~emulex/for-vlad/old/compat.git] / include / linux / tracepoint.h
1 #ifndef _COMPAT_LINUX_TRACEPOINT_H
2 #define _COMPAT_LINUX_TRACEPOINT_H 1
3
4 #include <linux/version.h>
5
6 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27))
7
8 #include_next <linux/tracepoint.h>
9
10 /* Backports f42c85e7 */
11 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30))
12 #undef TP_STRUCT__entry
13 #define TP_STRUCT__entry(args...) args
14 #endif
15
16 /* Backports 091ad365, a rename */
17 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33))
18 #define DECLARE_EVENT_CLASS TRACE_EVENT_TEMPLATE
19 #endif
20
21 /* Backpports 2939b0469 */
22 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30))
23 #define TP_PROTO TPPROTO
24 #define TP_ARGS TPARGS
25 #define TP_FMT TPFMT
26 #define TP_RAW_FMT TPRAWFMT
27 #endif
28
29 /* Force disabling tracing */
30
31 #undef PARAMS
32 #define PARAMS(args...) args
33
34 #undef TRACE_EVENT
35 #define TRACE_EVENT(name, proto, ...) \
36 DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
37
38 #undef DECLARE_EVENT_CLASS
39 #define DECLARE_EVENT_CLASS(...)
40 #undef DEFINE_EVENT
41
42 #define DEFINE_EVENT(template, name, proto, args)               \
43         DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
44
45 #undef DECLARE_TRACE_NOARGS
46 #define DECLARE_TRACE_NOARGS(name)                                      \
47                 __DECLARE_TRACE(name, void, , 1, void *__data, __data)
48
49
50 /* Backports 38516ab59fbc5b3bb278cf5e1fe2867c70cff32e */
51 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35))
52
53 #undef DECLARE_TRACE
54 #define DECLARE_TRACE(name, proto, args)                                \
55                 __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), 1,   \
56                                 PARAMS(void *__data, proto),            \
57                                 PARAMS(__data, args))
58
59 #undef DECLARE_TRACE_CONDITION
60 #define DECLARE_TRACE_CONDITION(name, proto, args, cond)                \
61         __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), PARAMS(cond), \
62                         PARAMS(void *__data, proto),                    \
63                         PARAMS(__data, args))
64
65 #else
66
67 #undef DECLARE_TRACE
68 #define DECLARE_TRACE(name, proto, args)                                \
69                 __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), 1,   \
70                                 PARAMS(void *__data, proto),            \
71                                 PARAMS(__data, args))
72
73 #undef DECLARE_TRACE_CONDITION
74 #define DECLARE_TRACE_CONDITION(name, proto, args, cond)                \
75         __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), PARAMS(cond), \
76                         PARAMS(void *__data, proto),                    \
77                         PARAMS(__data, args))
78 #endif /* backport 38516ab59fbc5b3bb278cf5e1fe2867c70cff32e */
79
80 /* Backports 38516ab59fbc5b3bb278cf5e1fe2867c70cff32e */
81 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35))
82
83 /* Backports c420970ef476d7d68df119711700666224001f43 */
84 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30))
85
86 #undef __DECLARE_TRACE
87 #define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \
88         static inline void trace_##name(proto)                          \
89         { }                                                             \
90         static inline void trace_##name##_rcuidle(proto)                \
91         { }                                                             \
92         static inline int                                               \
93         register_trace_##name(void (*probe)(proto))                     \
94         {                                                               \
95                 return -ENOSYS;                                         \
96         }                                                               \
97         static inline void                                              \
98         unregister_trace_##name(void (*probe)(proto))                   \
99         {                                                               \
100                 return -ENOSYS;                                         \
101         }                                                               \
102         static inline void check_trace_callback_type_##name(void (*cb)(data_proto)) \
103         {                                                               \
104         }
105 #else
106
107 #undef __DECLARE_TRACE
108 #define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \
109         static inline void trace_##name(proto)                          \
110         { }                                                             \
111         static inline void trace_##name##_rcuidle(proto)                \
112         { }                                                             \
113         static inline int                                               \
114         register_trace_##name(void (*probe)(proto))                     \
115         {                                                               \
116                 return -ENOSYS;                                         \
117         }                                                               \
118         static inline int                                               \
119         unregister_trace_##name(void (*probe)(proto))                   \
120         {                                                               \
121                 return -ENOSYS;                                         \
122         }                                                               \
123         static inline void check_trace_callback_type_##name(void (*cb)(data_proto)) \
124         {                                                               \
125         }
126 #endif /* backport c420970ef476d7d68df119711700666224001f43 */
127
128 #else
129
130 #undef __DECLARE_TRACE
131 #define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \
132         static inline void trace_##name(proto)                          \
133         { }                                                             \
134         static inline void trace_##name##_rcuidle(proto)                \
135         { }                                                             \
136         static inline int                                               \
137         register_trace_##name(void (*probe)(data_proto),                \
138                               void *data)                               \
139         {                                                               \
140                 return -ENOSYS;                                         \
141         }                                                               \
142         static inline int                                               \
143         unregister_trace_##name(void (*probe)(data_proto),              \
144                                 void *data)                             \
145         {                                                               \
146                 return -ENOSYS;                                         \
147         }                                                               \
148         static inline void check_trace_callback_type_##name(void (*cb)(data_proto)) \
149         {                                                               \
150         }
151
152 #endif /* backport 38516ab59fbc5b3bb278cf5e1fe2867c70cff32e */
153
154 #undef DEFINE_TRACE_FN
155 #define DEFINE_TRACE_FN(name, reg, unreg)
156
157 #undef DEFINE_TRACE
158 #define DEFINE_TRACE(name)
159
160 #undef EXPORT_TRACEPOINT_SYMBOL_GPL
161 #define EXPORT_TRACEPOINT_SYMBOL_GPL(name)
162
163 #undef EXPORT_TRACEPOINT_SYMBOL
164 #define EXPORT_TRACEPOINT_SYMBOL(name)
165
166 #ifdef CONFIG_TRACEPOINTS
167 #else /* CONFIG_TRACEPOINTS */
168 #endif /* CONFIG_TRACEPOINTS */
169
170 #else /* just disable tracing */
171
172 /* Disable all tracing */
173 #undef TRACE_EVENT
174 #define TRACE_EVENT(name, proto, ...) \
175 static inline void trace_ ## name(proto) {}
176 #undef DECLARE_EVENT_CLASS
177 #define DECLARE_EVENT_CLASS(...)
178 #undef DEFINE_EVENT
179 #define DEFINE_EVENT(evt_class, name, proto, ...) \
180 static inline void trace_ ## name(proto) {}
181
182 #define TP_PROTO(args...)  args
183 #define TP_ARGS(args...)   args
184 #define TP_CONDITION(args...)      args
185
186 #endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27)) */
187
188 #endif  /* _COMPAT_LINUX_TRACEPOINT_H */