44c9a5d550c6d4d6ab96759d86c9e4c9450a0067
[~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 TRACE_EVENT
32 #define TRACE_EVENT(name, proto, ...) \
33 DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
34
35 #undef DECLARE_EVENT_CLASS
36 #define DECLARE_EVENT_CLASS(...)
37 #undef DEFINE_EVENT
38
39 #define DEFINE_EVENT(template, name, proto, args)               \
40         DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
41
42 #undef DECLARE_TRACE_NOARGS
43 #define DECLARE_TRACE_NOARGS(name)                                      \
44                 __DECLARE_TRACE(name, void, , 1, void *__data, __data)
45
46
47 /* Backports 38516ab59fbc5b3bb278cf5e1fe2867c70cff32e */
48 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35))
49
50 #undef DECLARE_TRACE
51 #define DECLARE_TRACE(name, proto, args)                                \
52                 __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), 1,   \
53                                 PARAMS(void *__data, proto),            \
54                                 PARAMS(__data, args))
55
56 #undef DECLARE_TRACE_CONDITION
57 #define DECLARE_TRACE_CONDITION(name, proto, args, cond)                \
58         __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), PARAMS(cond), \
59                         PARAMS(void *__data, proto),                    \
60                         PARAMS(__data, args))
61
62 #else
63
64 #undef DECLARE_TRACE
65 #define DECLARE_TRACE(name, proto, args)                                \
66                 __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), 1,   \
67                                 PARAMS(void *__data, proto),            \
68                                 PARAMS(__data, args))
69
70 #undef DECLARE_TRACE_CONDITION
71 #define DECLARE_TRACE_CONDITION(name, proto, args, cond)                \
72         __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), PARAMS(cond), \
73                         PARAMS(void *__data, proto),                    \
74                         PARAMS(__data, args))
75 #endif /* backport 38516ab59fbc5b3bb278cf5e1fe2867c70cff32e */
76
77 /* Backports 38516ab59fbc5b3bb278cf5e1fe2867c70cff32e */
78 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35))
79
80 /* Backports c420970ef476d7d68df119711700666224001f43 */
81 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30))
82
83 #undef __DECLARE_TRACE
84 #define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \
85         static inline void trace_##name(proto)                          \
86         { }                                                             \
87         static inline void trace_##name##_rcuidle(proto)                \
88         { }                                                             \
89         static inline int                                               \
90         register_trace_##name(void (*probe)(proto))                     \
91         {                                                               \
92                 return -ENOSYS;                                         \
93         }                                                               \
94         static inline void                                              \
95         unregister_trace_##name(void (*probe)(proto))                   \
96         {                                                               \
97                 return -ENOSYS;                                         \
98         }                                                               \
99         static inline void check_trace_callback_type_##name(void (*cb)(data_proto)) \
100         {                                                               \
101         }
102 #else
103
104 #undef __DECLARE_TRACE
105 #define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \
106         static inline void trace_##name(proto)                          \
107         { }                                                             \
108         static inline void trace_##name##_rcuidle(proto)                \
109         { }                                                             \
110         static inline int                                               \
111         register_trace_##name(void (*probe)(proto))                     \
112         {                                                               \
113                 return -ENOSYS;                                         \
114         }                                                               \
115         static inline int                                               \
116         unregister_trace_##name(void (*probe)(proto))                   \
117         {                                                               \
118                 return -ENOSYS;                                         \
119         }                                                               \
120         static inline void check_trace_callback_type_##name(void (*cb)(data_proto)) \
121         {                                                               \
122         }
123 #endif /* backport c420970ef476d7d68df119711700666224001f43 */
124
125 #else
126
127 #undef __DECLARE_TRACE
128 #define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \
129         static inline void trace_##name(proto)                          \
130         { }                                                             \
131         static inline void trace_##name##_rcuidle(proto)                \
132         { }                                                             \
133         static inline int                                               \
134         register_trace_##name(void (*probe)(data_proto),                \
135                               void *data)                               \
136         {                                                               \
137                 return -ENOSYS;                                         \
138         }                                                               \
139         static inline int                                               \
140         unregister_trace_##name(void (*probe)(data_proto),              \
141                                 void *data)                             \
142         {                                                               \
143                 return -ENOSYS;                                         \
144         }                                                               \
145         static inline void check_trace_callback_type_##name(void (*cb)(data_proto)) \
146         {                                                               \
147         }
148
149 #endif /* backport 38516ab59fbc5b3bb278cf5e1fe2867c70cff32e */
150
151 #undef DEFINE_TRACE_FN
152 #define DEFINE_TRACE_FN(name, reg, unreg)
153
154 #undef DEFINE_TRACE
155 #define DEFINE_TRACE(name)
156
157 #undef EXPORT_TRACEPOINT_SYMBOL_GPL
158 #define EXPORT_TRACEPOINT_SYMBOL_GPL(name)
159
160 #undef EXPORT_TRACEPOINT_SYMBOL
161 #define EXPORT_TRACEPOINT_SYMBOL(name)
162
163 #ifdef CONFIG_TRACEPOINTS
164 #else /* CONFIG_TRACEPOINTS */
165 #endif /* CONFIG_TRACEPOINTS */
166
167 #else /* just disable tracing */
168
169 /* Disable all tracing */
170 #undef TRACE_EVENT
171 #define TRACE_EVENT(name, proto, ...) \
172 static inline void trace_ ## name(proto) {}
173 #undef DECLARE_EVENT_CLASS
174 #define DECLARE_EVENT_CLASS(...)
175 #undef DEFINE_EVENT
176 #define DEFINE_EVENT(evt_class, name, proto, ...) \
177 static inline void trace_ ## name(proto) {}
178
179 #define TP_PROTO(args...)  args
180 #define TP_ARGS(args...)   args
181 #define TP_CONDITION(args...)      args
182
183 #endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27)) */
184
185 #endif  /* _COMPAT_LINUX_TRACEPOINT_H */