48e256c86b49ffe3e3d4e3ca30a0ea93855f05c6
[lttng-modules.git] / wrapper / perf.h
1 /* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1)
2 *
3 * wrapper/perf.h
4 *
5 * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
6 */
7
8 #ifndef _LTTNG_WRAPPER_PERF_H
9 #define _LTTNG_WRAPPER_PERF_H
10
11 #include <linux/perf_event.h>
12
13 #ifdef CONFIG_PERF_EVENTS
14
15 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
16 static inline struct perf_event *
17 wrapper_perf_event_create_kernel_counter(struct perf_event_attr *attr,
18 int cpu,
19 struct task_struct *task,
20 perf_overflow_handler_t callback)
21 {
22 return perf_event_create_kernel_counter(attr, cpu, task, callback, NULL);
23 }
24 #else /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)) */
25
26 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
27 static inline struct perf_event *
28 wrapper_perf_event_create_kernel_counter(struct perf_event_attr *attr,
29 int cpu,
30 struct task_struct *task,
31 perf_overflow_handler_t callback)
32 {
33 return perf_event_create_kernel_counter(attr, cpu, task, callback);
34 }
35 #else /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) */
36 static inline struct perf_event *
37 wrapper_perf_event_create_kernel_counter(struct perf_event_attr *attr,
38 int cpu,
39 struct task_struct *task,
40 perf_overflow_handler_t callback)
41 {
42 pid_t pid;
43
44 if (!task)
45 pid = -1;
46 else
47 pid = task->pid;
48
49 return perf_event_create_kernel_counter(attr, cpu, pid, callback);
50 }
51
52 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) */
53
54 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36))
55 #define local64_read(l) atomic64_read(l)
56 #endif
57
58 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)) */
59
60 #endif /* CONFIG_PERF_EVENTS */
61
62 #endif /* _LTTNG_WRAPPER_PERF_H */
This page took 0.030373 seconds and 3 git commands to generate.