Fix: Add missing const to lttng_tracepoint_ptr_deref prototype
[lttng-modules.git] / wrapper / tracepoint.h
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 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35))
18
19 #define DECLARE_EVENT_CLASS(name, proto, args, tstruct, assign, print)
20
21 #endif
22
23 #ifndef HAVE_KABI_2635_TRACEPOINT
24
25 #define kabi_2635_tracepoint_probe_register tracepoint_probe_register
26 #define kabi_2635_tracepoint_probe_unregister tracepoint_probe_unregister
27
28 #endif /* HAVE_KABI_2635_TRACEPOINT */
29
30 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
31
32 #include <lttng-tracepoint.h>
33
34 #define lttng_wrapper_tracepoint_probe_register lttng_tracepoint_probe_register
35 #define lttng_wrapper_tracepoint_probe_unregister lttng_tracepoint_probe_unregister
36
37 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)) */
38
39 #define lttng_wrapper_tracepoint_probe_register kabi_2635_tracepoint_probe_register
40 #define lttng_wrapper_tracepoint_probe_unregister kabi_2635_tracepoint_probe_unregister
41
42 static inline
43 int lttng_tracepoint_init(void)
44 {
45 return 0;
46 }
47
48 static inline
49 void lttng_tracepoint_exit(void)
50 {
51 }
52
53 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)) */
54
55 #ifdef CONFIG_MODULE_SIG
56
57 #include <linux/kallsyms.h>
58 #include <wrapper/kallsyms.h>
59
60 static inline
61 int wrapper_tracepoint_module_notify(struct notifier_block *nb,
62 unsigned long val, struct module *mod)
63 {
64 int (*tracepoint_module_notify_sym)(struct notifier_block *nb,
65 unsigned long val, struct module *mod);
66
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);
71 } else {
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");
73 return -ENOSYS;
74 }
75 }
76
77 #endif /* CONFIG_MODULE_SIG */
78
79 #if defined(CONFIG_MODULE_SIG) && defined(MODULE)
80
81 static inline
82 int wrapper_lttng_fixup_sig(struct module *mod)
83 {
84 int ret = 0;
85
86 /*
87 * This is for module.c confusing force loaded modules with
88 * unsigned modules.
89 */
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);
96 }
97 return ret;
98 }
99
100 #else /* #if defined(CONFIG_MODULE_SIG) && defined(MODULE) */
101
102 static inline
103 int wrapper_lttng_fixup_sig(struct module *mod)
104 {
105 return 0;
106 }
107
108 #endif /*#else #if defined(CONFIG_MODULE_SIG) && defined(MODULE) */
109
110 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,19,0))
111 static inline struct tracepoint *lttng_tracepoint_ptr_deref(tracepoint_ptr_t *p)
112 {
113 return tracepoint_ptr_deref(p);
114 }
115 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,19,0)) */
116 static inline struct tracepoint *lttng_tracepoint_ptr_deref(struct tracepoint * const *p)
117 {
118 return *p;
119 }
120 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,19,0)) */
121
122 #endif /* _LTTNG_WRAPPER_TRACEPOINT_H */
This page took 0.030782 seconds and 4 git commands to generate.