Fix compile error on kernel 3.0.101 with CONFIG_PERF_EVENTS
[lttng-modules.git] / wrapper / perf.h
... / ...
CommitLineData
1#ifndef _LTTNG_WRAPPER_PERF_H
2#define _LTTNG_WRAPPER_PERF_H
3
4/*
5 * wrapper/perf.h
6 *
7 * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; only
12 * version 2.1 of the License.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24#include <linux/perf_event.h>
25
26#ifdef CONFIG_PERF_EVENTS
27
28#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
29static inline struct perf_event *
30wrapper_perf_event_create_kernel_counter(struct perf_event_attr *attr,
31 int cpu,
32 struct task_struct *task,
33 perf_overflow_handler_t callback)
34{
35 return perf_event_create_kernel_counter(attr, cpu, task, callback, NULL);
36}
37#else /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)) */
38
39#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
40static inline struct perf_event *
41wrapper_perf_event_create_kernel_counter(struct perf_event_attr *attr,
42 int cpu,
43 struct task_struct *task,
44 perf_overflow_handler_t callback)
45{
46 return perf_event_create_kernel_counter(attr, cpu, task, callback);
47}
48#else /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) */
49static inline struct perf_event *
50wrapper_perf_event_create_kernel_counter(struct perf_event_attr *attr,
51 int cpu,
52 struct task_struct *task,
53 perf_overflow_handler_t callback)
54{
55 pid_t pid;
56
57 if (!task)
58 pid = -1;
59 else
60 pid = task->pid;
61
62 return perf_event_create_kernel_counter(attr, cpu, pid, callback);
63}
64
65#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) */
66
67#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36))
68#define local64_read(l) atomic64_read(l)
69#endif
70
71#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)) */
72
73#endif /* CONFIG_PERF_EVENTS */
74
75#endif /* _LTTNG_WRAPPER_PERF_H */
This page took 0.022725 seconds and 4 git commands to generate.