1 /* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1)
5 * wrapper around DECLARE_EVENT_CLASS.
7 * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 #ifndef _LTTNG_WRAPPER_TRACEPOINT_H
11 #define _LTTNG_WRAPPER_TRACEPOINT_H
13 #include <linux/version.h>
14 #include <linux/tracepoint.h>
15 #include <linux/module.h>
17 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35))
19 #define DECLARE_EVENT_CLASS(name, proto, args, tstruct, assign, print)
23 #ifndef HAVE_KABI_2635_TRACEPOINT
25 #define kabi_2635_tracepoint_probe_register tracepoint_probe_register
26 #define kabi_2635_tracepoint_probe_unregister tracepoint_probe_unregister
28 #endif /* HAVE_KABI_2635_TRACEPOINT */
30 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
32 #include <lttng-tracepoint.h>
34 #define lttng_wrapper_tracepoint_probe_register lttng_tracepoint_probe_register
35 #define lttng_wrapper_tracepoint_probe_unregister lttng_tracepoint_probe_unregister
37 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)) */
39 #define lttng_wrapper_tracepoint_probe_register kabi_2635_tracepoint_probe_register
40 #define lttng_wrapper_tracepoint_probe_unregister kabi_2635_tracepoint_probe_unregister
43 int lttng_tracepoint_init(void)
49 void lttng_tracepoint_exit(void)
53 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)) */
55 #ifdef CONFIG_MODULE_SIG
57 #include <linux/kallsyms.h>
58 #include <wrapper/kallsyms.h>
61 int wrapper_tracepoint_module_notify(struct notifier_block
*nb
,
62 unsigned long val
, struct module
*mod
)
64 int (*tracepoint_module_notify_sym
)(struct notifier_block
*nb
,
65 unsigned long val
, struct module
*mod
);
67 tracepoint_module_notify_sym
=
68 (void *) kallsyms_lookup_funcptr("tracepoint_module_notify");
69 if (tracepoint_module_notify_sym
) {
70 return tracepoint_module_notify_sym(nb
, val
, mod
);
72 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");
77 #endif /* CONFIG_MODULE_SIG */
79 #if defined(CONFIG_MODULE_SIG) && defined(MODULE)
82 int wrapper_lttng_fixup_sig(struct module
*mod
)
87 * This is for module.c confusing force loaded modules with
90 if (!THIS_MODULE
->sig_ok
&&
91 THIS_MODULE
->taints
& (1U << TAINT_FORCED_MODULE
)) {
92 THIS_MODULE
->taints
&= ~(1U << TAINT_FORCED_MODULE
);
93 ret
= wrapper_tracepoint_module_notify(NULL
,
94 MODULE_STATE_COMING
, mod
);
95 THIS_MODULE
->taints
|= (1U << TAINT_FORCED_MODULE
);
100 #else /* #if defined(CONFIG_MODULE_SIG) && defined(MODULE) */
103 int wrapper_lttng_fixup_sig(struct module
*mod
)
108 #endif /*#else #if defined(CONFIG_MODULE_SIG) && defined(MODULE) */
110 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,19,0))
111 static inline struct tracepoint
*lttng_tracepoint_ptr_deref(tracepoint_ptr_t
*p
)
113 return tracepoint_ptr_deref(p
);
115 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,19,0)) */
116 static inline struct tracepoint
*lttng_tracepoint_ptr_deref(struct tracepoint
* const *p
)
120 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,19,0)) */
122 #endif /* _LTTNG_WRAPPER_TRACEPOINT_H */