]> granicus.if.org Git - zfs/blob - config/kernel-timer.m4
b0e1afa153ab2e7c6e826abd2ef9c9aebf3ef4a3
[zfs] / config / kernel-timer.m4
1 dnl # 4.14-rc3 API change
2 dnl # https://lwn.net/Articles/735887/
3 dnl #
4 dnl # Check if timer_list.func get passed a timer_list or an unsigned long
5 dnl # (older kernels).  Also sanity check the from_timer() and timer_setup()
6 dnl # macros are available as well, since they will be used in the same newer
7 dnl # kernels that support the new timer_list.func signature.
8 dnl #
9 dnl # Also check for the existance of flags in struct timer_list, they were
10 dnl # added in 4.1-rc8 via 0eeda71bc30d.
11
12 AC_DEFUN([ZFS_AC_KERNEL_TIMER_SETUP], [
13         AC_MSG_CHECKING([whether timer_setup() is available])
14         tmp_flags="$EXTRA_KCFLAGS"
15         EXTRA_KCFLAGS="-Werror"
16
17         ZFS_LINUX_TRY_COMPILE([
18                 #include <linux/timer.h>
19
20                 struct my_task_timer {
21                         struct timer_list timer;
22                         int data;
23                 };
24
25                 void task_expire(struct timer_list *tl)
26                 {
27                         struct my_task_timer *task_timer = from_timer(task_timer, tl, timer);
28                         task_timer->data = 42;
29                 }
30         ],[
31                 struct my_task_timer task_timer;
32                 timer_setup(&task_timer.timer, task_expire, 0);
33         ],[
34                 AC_MSG_RESULT(yes)
35                 AC_DEFINE(HAVE_KERNEL_TIMER_SETUP, 1,
36                     [timer_setup() is available])
37         ],[
38                 AC_MSG_RESULT(no)
39         ])
40
41         AC_MSG_CHECKING([whether timer function expects timer_list])
42
43         ZFS_LINUX_TRY_COMPILE([
44                 #include <linux/timer.h>
45                 void task_expire(struct timer_list *tl) {}
46         ],[
47                 struct timer_list tl;
48                 tl.function = task_expire;
49         ],[
50                 AC_MSG_RESULT(yes)
51                 AC_DEFINE(HAVE_KERNEL_TIMER_FUNCTION_TIMER_LIST, 1,
52                     [timer_list.function gets a timer_list])
53         ],[
54                 AC_MSG_RESULT(no)
55         ])
56
57         AC_MSG_CHECKING([whether struct timer_list has flags])
58
59         ZFS_LINUX_TRY_COMPILE([
60                 #include <linux/timer.h>
61         ],[
62                 struct timer_list tl;
63                 tl.flags = 2;
64         ],[
65                 AC_MSG_RESULT(yes)
66                 AC_DEFINE(HAVE_KERNEL_TIMER_LIST_FLAGS, 1,
67                     [struct timer_list has a flags member])
68         ],[
69                 AC_MSG_RESULT(no)
70         ])
71
72         EXTRA_KCFLAGS="$tmp_flags"
73 ])