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