Drop support for kernels < 3.0 from tracepoint.h wrapper
[lttng-modules.git] / wrapper / tracepoint.h
... / ...
CommitLineData
1/* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1)
2 *
3 * wrapper/tracepoint.h
4 *
5 * wrapper around DECLARE_EVENT_CLASS.
6 *
7 * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 */
9
10#ifndef _LTTNG_WRAPPER_TRACEPOINT_H
11#define _LTTNG_WRAPPER_TRACEPOINT_H
12
13#include <linux/version.h>
14#include <linux/tracepoint.h>
15#include <linux/module.h>
16
17#ifndef HAVE_KABI_2635_TRACEPOINT
18
19#define kabi_2635_tracepoint_probe_register tracepoint_probe_register
20#define kabi_2635_tracepoint_probe_unregister tracepoint_probe_unregister
21
22#endif /* HAVE_KABI_2635_TRACEPOINT */
23
24#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
25
26#include <lttng-tracepoint.h>
27
28#define lttng_wrapper_tracepoint_probe_register lttng_tracepoint_probe_register
29#define lttng_wrapper_tracepoint_probe_unregister lttng_tracepoint_probe_unregister
30
31#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)) */
32
33#define lttng_wrapper_tracepoint_probe_register kabi_2635_tracepoint_probe_register
34#define lttng_wrapper_tracepoint_probe_unregister kabi_2635_tracepoint_probe_unregister
35
36static inline
37int lttng_tracepoint_init(void)
38{
39 return 0;
40}
41
42static inline
43void lttng_tracepoint_exit(void)
44{
45}
46
47#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)) */
48
49#ifdef CONFIG_MODULE_SIG
50
51#include <linux/kallsyms.h>
52#include <wrapper/kallsyms.h>
53
54static inline
55int wrapper_tracepoint_module_notify(struct notifier_block *nb,
56 unsigned long val, struct module *mod)
57{
58 int (*tracepoint_module_notify_sym)(struct notifier_block *nb,
59 unsigned long val, struct module *mod);
60
61 tracepoint_module_notify_sym =
62 (void *) kallsyms_lookup_funcptr("tracepoint_module_notify");
63 if (tracepoint_module_notify_sym) {
64 return tracepoint_module_notify_sym(nb, val, mod);
65 } else {
66 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");
67 return -ENOSYS;
68 }
69}
70
71#endif /* CONFIG_MODULE_SIG */
72
73#if defined(CONFIG_MODULE_SIG) && defined(MODULE)
74
75static inline
76int wrapper_lttng_fixup_sig(struct module *mod)
77{
78 int ret = 0;
79
80 /*
81 * This is for module.c confusing force loaded modules with
82 * unsigned modules.
83 */
84 if (!THIS_MODULE->sig_ok &&
85 THIS_MODULE->taints & (1U << TAINT_FORCED_MODULE)) {
86 THIS_MODULE->taints &= ~(1U << TAINT_FORCED_MODULE);
87 ret = wrapper_tracepoint_module_notify(NULL,
88 MODULE_STATE_COMING, mod);
89 THIS_MODULE->taints |= (1U << TAINT_FORCED_MODULE);
90 }
91 return ret;
92}
93
94#else /* #if defined(CONFIG_MODULE_SIG) && defined(MODULE) */
95
96static inline
97int wrapper_lttng_fixup_sig(struct module *mod)
98{
99 return 0;
100}
101
102#endif /*#else #if defined(CONFIG_MODULE_SIG) && defined(MODULE) */
103
104#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,19,0))
105static inline struct tracepoint *lttng_tracepoint_ptr_deref(tracepoint_ptr_t *p)
106{
107 return tracepoint_ptr_deref(p);
108}
109#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,19,0)) */
110static inline struct tracepoint *lttng_tracepoint_ptr_deref(struct tracepoint * const *p)
111{
112 return *p;
113}
114#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,19,0)) */
115
116#endif /* _LTTNG_WRAPPER_TRACEPOINT_H */
This page took 0.024075 seconds and 4 git commands to generate.