1 #ifndef _LTTNG_WRAPPER_TRACEPOINT_H
2 #define _LTTNG_WRAPPER_TRACEPOINT_H
7 * wrapper around DECLARE_EVENT_CLASS.
9 * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; only
14 * version 2.1 of the License.
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26 #include <linux/version.h>
27 #include <linux/tracepoint.h>
28 #include <linux/module.h>
30 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35))
32 #define DECLARE_EVENT_CLASS(name, proto, args, tstruct, assign, print)
36 #ifndef HAVE_KABI_2635_TRACEPOINT
38 #define kabi_2635_tracepoint_probe_register tracepoint_probe_register
39 #define kabi_2635_tracepoint_probe_unregister tracepoint_probe_unregister
41 #endif /* HAVE_KABI_2635_TRACEPOINT */
43 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
45 #include <lttng-tracepoint.h>
47 #define lttng_wrapper_tracepoint_probe_register lttng_tracepoint_probe_register
48 #define lttng_wrapper_tracepoint_probe_unregister lttng_tracepoint_probe_unregister
50 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)) */
52 #define lttng_wrapper_tracepoint_probe_register kabi_2635_tracepoint_probe_register
53 #define lttng_wrapper_tracepoint_probe_unregister kabi_2635_tracepoint_probe_unregister
56 int lttng_tracepoint_init(void)
62 void lttng_tracepoint_exit(void)
66 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)) */
68 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG))
70 #include <linux/kallsyms.h>
71 #include <wrapper/kallsyms.h>
74 int wrapper_tracepoint_module_notify(struct notifier_block
*nb
,
75 unsigned long val
, struct module
*mod
)
77 int (*tracepoint_module_notify_sym
)(struct notifier_block
*nb
,
78 unsigned long val
, struct module
*mod
);
80 tracepoint_module_notify_sym
=
81 (void *) kallsyms_lookup_funcptr("tracepoint_module_notify");
82 if (tracepoint_module_notify_sym
) {
83 return tracepoint_module_notify_sym(nb
, val
, mod
);
85 printk_once(KERN_WARNING
"LTTng: tracepoint_module_notify symbol lookup failed. It probably means you kernel don't need this work-around. Please consider upgrading LTTng modules to make this warning go away.\n");
90 #endif /* #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG)) */
92 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG) && defined(MODULE))
95 int wrapper_lttng_fixup_sig(struct module
*mod
)
100 * This is for module.c confusing force loaded modules with
103 if (!THIS_MODULE
->sig_ok
&&
104 THIS_MODULE
->taints
& (1U << TAINT_FORCED_MODULE
)) {
105 THIS_MODULE
->taints
&= ~(1U << TAINT_FORCED_MODULE
);
106 ret
= wrapper_tracepoint_module_notify(NULL
,
107 MODULE_STATE_COMING
, mod
);
108 THIS_MODULE
->taints
|= (1U << TAINT_FORCED_MODULE
);
113 #else /* #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG) && defined(MODULE)) */
116 int wrapper_lttng_fixup_sig(struct module
*mod
)
121 #endif /* #else #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) && defined(CONFIG_MODULE_SIG) && defined(MODULE)) */
123 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,19,0))
124 static inline struct tracepoint
*lttng_tracepoint_ptr_deref(tracepoint_ptr_t
*p
)
126 return tracepoint_ptr_deref(p
);
128 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,19,0)) */
129 static inline struct tracepoint
*lttng_tracepoint_ptr_deref(struct tracepoint
* const *p
)
133 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,19,0)) */
135 #endif /* _LTTNG_WRAPPER_TRACEPOINT_H */