Debian Codegraph @

runtime/linux/timer.h

raw
1 /* -*- linux-c -*-
2 * Kernel Timer Functions
3 * Copyright (C) 2012 Red Hat Inc.
4 *
5 * This file is part of systemtap, and is free software. You can
6 * redistribute it and/or modify it under the terms of the GNU General
7 * Public License (GPL); either version 2, or (at your option) any
8 * later version.
9 */
10
11 #ifndef _LINUX_TIMER_H_
12 #define _LINUX_TIMER_H_
13
14 // If we're on kernels < 2.6.17, then hrtimers are not supported.
15 #include <linux/hrtimer.h>
16
17 static unsigned long stap_hrtimer_resolution = 0;
18
19 struct stap_hrtimer_probe {
20 struct hrtimer hrtimer;
21 const struct stap_probe * probe;
22 int64_t intrv;
23 int64_t rnd;
24 unsigned enabled;
25 };
26
27 // The function signature changed in 2.6.21.
28 #ifdef STAPCONF_HRTIMER_REL
29 typedef int hrtimer_return_t;
30 #else
31 typedef enum hrtimer_restart hrtimer_return_t;
32 #endif
33
34
35 // autoconf: add get/set expires if missing (pre 2.6.28-rc1)
36 #ifndef STAPCONF_HRTIMER_GETSET_EXPIRES
37 #define hrtimer_get_expires(timer) ((timer)->expires)
38 #define hrtimer_set_expires(timer, time) (void)((timer)->expires = (time))
39 #endif
40
41 // autoconf: adapt to HRTIMER_REL -> HRTIMER_MODE_REL renaming near 2.6.21
42 #ifdef STAPCONF_HRTIMER_REL
43 #define HRTIMER_MODE_REL HRTIMER_REL
44 #endif
45
46 #ifdef STAPCONF_HRTIMER_INIT
47 #define STP_HRTIMER_SETUP(timer, func, clock_id, mode) \
48 do { \
49 hrtimer_init((timer), (clock_id), (mode)); \
50 (*timer).function = (func); \
51 }while(0)
52 #else
53 #define STP_HRTIMER_SETUP(timer, func, clock_id, mode) \
54 hrtimer_setup((timer), (func), (clock_id), (mode))
55 #endif
56
57 #endif /* _LINUX_TIMER_H_ */