xref: /freebsd/sys/contrib/openzfs/config/kernel-kthread.m4 (revision b64c5a0ace59af62eff52bfe110a521dc73c937b)
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 # prehistory:
21	dnl #     int dequeue_signal(struct task_struct *task, sigset_t *mask,
22	dnl #         siginfo_t *info)
23	dnl #
24	dnl # 4.20: kernel_siginfo_t introduced, replaces siginfo_t
25	dnl #     int dequeue_signal(struct task_struct *task, sigset_t *mask,
26	dnl           kernel_siginfo_t *info)
27	dnl #
28	dnl # 5.17: enum pid_type introduced as 4th arg
29	dnl #     int dequeue_signal(struct task_struct *task, sigset_t *mask,
30	dnl #         kernel_siginfo_t *info, enum pid_type *type)
31	dnl #
32	dnl # 6.12: first arg struct_task* removed
33	dnl #     int dequeue_signal(sigset_t *mask, kernel_siginfo_t *info,
34	dnl #         enum pid_type *type)
35	dnl #
36	AC_MSG_CHECKING([whether dequeue_signal() takes 4 arguments])
37	ZFS_LINUX_TEST_RESULT([kthread_dequeue_signal_4arg], [
38		AC_MSG_RESULT(yes)
39		AC_DEFINE(HAVE_DEQUEUE_SIGNAL_4ARG, 1,
40		    [dequeue_signal() takes 4 arguments])
41	], [
42		AC_MSG_RESULT(no)
43		AC_MSG_CHECKING([whether 3-arg dequeue_signal() takes a type argument])
44		ZFS_LINUX_TEST_RESULT([kthread_dequeue_signal_3arg_type], [
45			AC_MSG_RESULT(yes)
46			AC_DEFINE(HAVE_DEQUEUE_SIGNAL_3ARG_TYPE, 1,
47			    [3-arg dequeue_signal() takes a type argument])
48		], [
49			AC_MSG_RESULT(no)
50		])
51	])
52])
53
54AC_DEFUN([ZFS_AC_KERNEL_SRC_KTHREAD_COMPLETE_AND_EXIT], [
55	ZFS_LINUX_TEST_SRC([kthread_complete_and_exit], [
56		#include <linux/kthread.h>
57	], [
58		struct completion *completion = NULL;
59		long code = 0;
60
61		kthread_complete_and_exit(completion, code);
62	])
63])
64
65AC_DEFUN([ZFS_AC_KERNEL_SRC_KTHREAD_DEQUEUE_SIGNAL], [
66	ZFS_LINUX_TEST_SRC([kthread_dequeue_signal_4arg], [
67		#include <linux/sched/signal.h>
68	], [
69		struct task_struct *task = NULL;
70		sigset_t *mask = NULL;
71		kernel_siginfo_t *info = NULL;
72		enum pid_type *type = NULL;
73		int error __attribute__ ((unused));
74
75		error = dequeue_signal(task, mask, info, type);
76	])
77
78	ZFS_LINUX_TEST_SRC([kthread_dequeue_signal_3arg_type], [
79		#include <linux/sched/signal.h>
80	], [
81		sigset_t *mask = NULL;
82		kernel_siginfo_t *info = NULL;
83		enum pid_type *type = NULL;
84		int error __attribute__ ((unused));
85
86		error = dequeue_signal(mask, info, type);
87	])
88])
89
90AC_DEFUN([ZFS_AC_KERNEL_KTHREAD], [
91	ZFS_AC_KERNEL_KTHREAD_COMPLETE_AND_EXIT
92	ZFS_AC_KERNEL_KTHREAD_DEQUEUE_SIGNAL
93])
94
95AC_DEFUN([ZFS_AC_KERNEL_SRC_KTHREAD], [
96	ZFS_AC_KERNEL_SRC_KTHREAD_COMPLETE_AND_EXIT
97	ZFS_AC_KERNEL_SRC_KTHREAD_DEQUEUE_SIGNAL
98])
99