Commit | Line | Data |
---|---|---|
3a523f5b MD |
1 | #ifndef _LTTNG_WRAPPER_TRACEPOINT_H |
2 | #define _LTTNG_WRAPPER_TRACEPOINT_H | |
3 | ||
4 | /* | |
5 | * wrapper/tracepoint.h | |
6 | * | |
7 | * wrapper around DECLARE_EVENT_CLASS. | |
8 | * | |
9 | * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
10 | * | |
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. | |
15 | * | |
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. | |
20 | * | |
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 | |
24 | */ | |
25 | ||
26 | #include <linux/version.h> | |
27 | #include <linux/tracepoint.h> | |
dd8d5afb | 28 | #include <linux/module.h> |
3a523f5b MD |
29 | |
30 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)) | |
31 | ||
32 | #define DECLARE_EVENT_CLASS(name, proto, args, tstruct, assign, print) | |
33 | ||
34 | #endif | |
35 | ||
36 | #ifndef HAVE_KABI_2635_TRACEPOINT | |
37 | ||
38 | #define kabi_2635_tracepoint_probe_register tracepoint_probe_register | |
39 | #define kabi_2635_tracepoint_probe_unregister tracepoint_probe_unregister | |
3a523f5b MD |
40 | |
41 | #endif /* HAVE_KABI_2635_TRACEPOINT */ | |
42 | ||
20591cf7 MD |
43 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)) |
44 | ||
5a2f5e92 | 45 | #include <lttng-tracepoint.h> |
20591cf7 MD |
46 | |
47 | #define lttng_wrapper_tracepoint_probe_register lttng_tracepoint_probe_register | |
48 | #define lttng_wrapper_tracepoint_probe_unregister lttng_tracepoint_probe_unregister | |
49 | ||
50 | #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)) */ | |
51 | ||
52 | #define lttng_wrapper_tracepoint_probe_register kabi_2635_tracepoint_probe_register | |
53 | #define lttng_wrapper_tracepoint_probe_unregister kabi_2635_tracepoint_probe_unregister | |
54 | ||
55 | static inline | |
56 | int lttng_tracepoint_init(void) | |
57 | { | |
58 | return 0; | |
59 | } | |
60 | ||
61 | static inline | |
62 | void lttng_tracepoint_exit(void) | |
63 | { | |
64 | } | |
65 | ||
66 | #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)) */ | |
67 | ||
dd8d5afb MD |
68 | #ifdef CONFIG_MODULE_SIG |
69 | ||
70 | #include <linux/kallsyms.h> | |
5a2f5e92 | 71 | #include <wrapper/kallsyms.h> |
dd8d5afb MD |
72 | |
73 | static inline | |
74 | int wrapper_tracepoint_module_notify(struct notifier_block *nb, | |
75 | unsigned long val, struct module *mod) | |
76 | { | |
77 | int (*tracepoint_module_notify_sym)(struct notifier_block *nb, | |
78 | unsigned long val, struct module *mod); | |
79 | ||
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); | |
84 | } else { | |
d16aa9c9 | 85 | printk(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"); |
dd8d5afb MD |
86 | return -ENOSYS; |
87 | } | |
88 | } | |
89 | ||
90 | static inline | |
91 | int wrapper_lttng_fixup_sig(struct module *mod) | |
92 | { | |
93 | int ret = 0; | |
94 | ||
95 | /* | |
96 | * This is for module.c confusing force loaded modules with | |
97 | * unsigned modules. | |
98 | */ | |
99 | if (!THIS_MODULE->sig_ok && | |
100 | THIS_MODULE->taints & (1U << TAINT_FORCED_MODULE)) { | |
101 | THIS_MODULE->taints &= ~(1U << TAINT_FORCED_MODULE); | |
102 | ret = wrapper_tracepoint_module_notify(NULL, | |
103 | MODULE_STATE_COMING, mod); | |
104 | THIS_MODULE->taints |= (1U << TAINT_FORCED_MODULE); | |
105 | } | |
106 | return ret; | |
107 | } | |
108 | ||
109 | #else /* CONFIG_MODULE_SIG */ | |
110 | ||
111 | static inline | |
112 | int wrapper_lttng_fixup_sig(struct module *mod) | |
113 | { | |
114 | return 0; | |
115 | } | |
116 | ||
117 | #endif /* #else CONFIG_MODULE_SIG */ | |
118 | ||
3a523f5b | 119 | #endif /* _LTTNG_WRAPPER_TRACEPOINT_H */ |