xref: /freebsd/sys/contrib/openzfs/config/kernel-kthread.m4 (revision c5f3a7f62217f20f0c7b2c4fc3fb2646336b0802)
1AC_DEFUN([ZFS_AC_KERNEL_KTHREAD_COMPLETE_AND_EXIT], [
2	dnl #
3	dnl # 5.17 API,
4	dnl # cead18552660702a4a46f58e65188fe5f36e9dfe ("exit: Rename complete_and_exit to kthread_complete_and_exit")
5	dnl #
6	dnl # Also moves the definition from include/linux/kernel.h to include/linux/kthread.h
7	dnl #
8	AC_MSG_CHECKING([whether kthread_complete_and_exit() is available])
9	ZFS_LINUX_TEST_RESULT([kthread_complete_and_exit], [
10		AC_MSG_RESULT(yes)
11		AC_DEFINE(SPL_KTHREAD_COMPLETE_AND_EXIT, kthread_complete_and_exit, [kthread_complete_and_exit() available])
12	], [
13		AC_MSG_RESULT(no)
14		AC_DEFINE(SPL_KTHREAD_COMPLETE_AND_EXIT, complete_and_exit, [using complete_and_exit() instead])
15	])
16])
17
18AC_DEFUN([ZFS_AC_KERNEL_KTHREAD_DEQUEUE_SIGNAL], [
19	dnl #
20	dnl # 5.17 API: enum pid_type * as new 4th dequeue_signal() argument,
21	dnl # 5768d8906bc23d512b1a736c1e198aa833a6daa4 ("signal: Requeue signals in the appropriate queue")
22	dnl #
23	dnl # int dequeue_signal(struct task_struct *task, sigset_t *mask, kernel_siginfo_t *info);
24	dnl # int dequeue_signal(struct task_struct *task, sigset_t *mask, kernel_siginfo_t *info, enum pid_type *type);
25	dnl #
26	dnl # 6.12 API: first arg struct_task* removed
27	dnl # int dequeue_signal(sigset_t *mask, kernel_siginfo_t *info, enum pid_type *type);
28	dnl #
29	AC_MSG_CHECKING([whether dequeue_signal() takes 4 arguments])
30	ZFS_LINUX_TEST_RESULT([kthread_dequeue_signal_4arg], [
31		AC_MSG_RESULT(yes)
32		AC_DEFINE(HAVE_DEQUEUE_SIGNAL_4ARG, 1,
33		    [dequeue_signal() takes 4 arguments])
34	], [
35		AC_MSG_RESULT(no)
36		AC_MSG_CHECKING([whether dequeue_signal() a task argument])
37		ZFS_LINUX_TEST_RESULT([kthread_dequeue_signal_3arg_task], [
38			AC_MSG_RESULT(yes)
39			AC_DEFINE(HAVE_DEQUEUE_SIGNAL_3ARG_TASK, 1,
40			    [dequeue_signal() takes a task argument])
41		], [
42			AC_MSG_RESULT(no)
43		])
44	])
45])
46
47AC_DEFUN([ZFS_AC_KERNEL_SRC_KTHREAD_COMPLETE_AND_EXIT], [
48	ZFS_LINUX_TEST_SRC([kthread_complete_and_exit], [
49		#include <linux/kthread.h>
50	], [
51		struct completion *completion = NULL;
52		long code = 0;
53
54		kthread_complete_and_exit(completion, code);
55	])
56])
57
58AC_DEFUN([ZFS_AC_KERNEL_SRC_KTHREAD_DEQUEUE_SIGNAL], [
59	ZFS_LINUX_TEST_SRC([kthread_dequeue_signal_3arg_task], [
60		#include <linux/sched/signal.h>
61	], [
62		struct task_struct *task = NULL;
63		sigset_t *mask = NULL;
64		kernel_siginfo_t *info = NULL;
65		int error __attribute__ ((unused));
66
67		error = dequeue_signal(task, mask, info);
68	])
69
70	ZFS_LINUX_TEST_SRC([kthread_dequeue_signal_4arg], [
71		#include <linux/sched/signal.h>
72	], [
73		struct task_struct *task = NULL;
74		sigset_t *mask = NULL;
75		kernel_siginfo_t *info = NULL;
76		enum pid_type *type = NULL;
77		int error __attribute__ ((unused));
78
79		error = dequeue_signal(task, mask, info, type);
80	])
81])
82
83AC_DEFUN([ZFS_AC_KERNEL_KTHREAD], [
84	ZFS_AC_KERNEL_KTHREAD_COMPLETE_AND_EXIT
85	ZFS_AC_KERNEL_KTHREAD_DEQUEUE_SIGNAL
86])
87
88AC_DEFUN([ZFS_AC_KERNEL_SRC_KTHREAD], [
89	ZFS_AC_KERNEL_SRC_KTHREAD_COMPLETE_AND_EXIT
90	ZFS_AC_KERNEL_SRC_KTHREAD_DEQUEUE_SIGNAL
91])
92