Cleanup duplicated include in wrapper/timer.h
[lttng-modules.git] / include / wrapper / timer.h
... / ...
CommitLineData
1/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
2 *
3 * wrapper/timer.h
4 *
5 * wrapper around linux/timer.h.
6 *
7 * Copyright (C) 2016 Michael Jeanson <mjeanson@efficios.com>
8 */
9
10#ifndef _LTTNG_WRAPPER_TIMER_H
11#define _LTTNG_WRAPPER_TIMER_H
12
13#include <lttng/kernel-version.h>
14#include <linux/timer.h>
15
16/*
17 * In the olden days, pinned timers were initialized normaly with init_timer()
18 * and then modified with mod_timer_pinned().
19 *
20 * Then came kernel 4.8.0 and they had to be initilized as pinned with
21 * init_timer_pinned() and then modified as regular timers with mod_timer().
22 *
23 * Then came kernel 4.15.0 with a new timer API where init_timer() is no more.
24 * It's replaced by timer_setup() where pinned is now part of timer flags.
25 */
26
27
28#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,15,0))
29
30#define LTTNG_TIMER_PINNED TIMER_PINNED
31#define LTTNG_TIMER_FUNC_ARG_TYPE struct timer_list *
32
33#define lttng_mod_timer_pinned(timer, expires) \
34 mod_timer(timer, expires)
35
36#define lttng_from_timer(var, callback_timer, timer_fieldname) \
37 from_timer(var, callback_timer, timer_fieldname)
38
39#define lttng_timer_setup(timer, callback, flags, unused) \
40 timer_setup(timer, callback, flags)
41
42
43#else /* LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,15,0) */
44
45
46# if (LTTNG_RT_VERSION_CODE >= LTTNG_RT_KERNEL_VERSION(4,6,4,8) \
47 || LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,8,0))
48
49#define lttng_init_timer_pinned(timer) \
50 init_timer_pinned(timer)
51
52#define lttng_mod_timer_pinned(timer, expires) \
53 mod_timer(timer, expires)
54
55# else /* LTTNG_RT_VERSION_CODE >= LTTNG_RT_KERNEL_VERSION(4,6,4,8) */
56
57#define lttng_init_timer_pinned(timer) \
58 init_timer(timer)
59
60#define lttng_mod_timer_pinned(timer, expires) \
61 mod_timer_pinned(timer, expires)
62
63# endif /* LTTNG_RT_VERSION_CODE >= LTTNG_RT_KERNEL_VERSION(4,6,4,8) */
64
65
66#define LTTNG_TIMER_PINNED TIMER_PINNED
67#define LTTNG_TIMER_FUNC_ARG_TYPE unsigned long
68
69/* timer_fieldname is unused prior to 4.15. */
70#define lttng_from_timer(var, timer_data, timer_fieldname) \
71 ((typeof(var))timer_data)
72
73static inline void lttng_timer_setup(struct timer_list *timer,
74 void (*function)(LTTNG_TIMER_FUNC_ARG_TYPE),
75 unsigned int flags, void *data)
76{
77 if (flags & LTTNG_TIMER_PINNED)
78 lttng_init_timer_pinned(timer);
79 else
80 init_timer(timer);
81
82 timer->function = function;
83 timer->data = (unsigned long)data;
84}
85
86#endif /* LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,15,0) */
87
88#endif /* _LTTNG_WRAPPER_TIMER_H */
This page took 0.022152 seconds and 4 git commands to generate.