xref: /freebsd/sys/contrib/openzfs/config/kernel-register_sysctl_table.m4 (revision 17aab35a77a1b1bf02fc85bb8ffadccb0ca5006d)
1dnl #
2dnl # Linux 6.5 removes register_sysctl_table
3dnl #
4AC_DEFUN([ZFS_AC_KERNEL_SRC_REGISTER_SYSCTL_TABLE], [
5	ZFS_LINUX_TEST_SRC([has_register_sysctl_table], [
6		#include <linux/sysctl.h>
7
8		static struct ctl_table dummy_table[] = {
9			{}
10		};
11
12    ],[
13		struct ctl_table_header *h
14			__attribute((unused)) = register_sysctl_table(dummy_table);
15    ])
16])
17
18AC_DEFUN([ZFS_AC_KERNEL_REGISTER_SYSCTL_TABLE], [
19	AC_MSG_CHECKING([whether register_sysctl_table exists])
20	ZFS_LINUX_TEST_RESULT([has_register_sysctl_table], [
21		AC_MSG_RESULT([yes])
22		AC_DEFINE(HAVE_REGISTER_SYSCTL_TABLE, 1,
23			[register_sysctl_table exists])
24	],[
25		AC_MSG_RESULT([no])
26	])
27])
28
29dnl #
30dnl # Linux 6.11 register_sysctl() enforces that sysctl tables no longer
31dnl # supply a sentinel end-of-table element. 6.6 introduces
32dnl # register_sysctl_sz() to enable callers to choose, so we use it if
33dnl # available for backward compatibility.
34dnl #
35AC_DEFUN([ZFS_AC_KERNEL_SRC_REGISTER_SYSCTL_SZ], [
36	ZFS_LINUX_TEST_SRC([has_register_sysctl_sz], [
37		#include <linux/sysctl.h>
38	],[
39		struct ctl_table test_table[] __attribute__((unused)) = {{}};
40		register_sysctl_sz("", test_table, 0);
41	])
42])
43
44AC_DEFUN([ZFS_AC_KERNEL_REGISTER_SYSCTL_SZ], [
45	AC_MSG_CHECKING([whether register_sysctl_sz exists])
46	ZFS_LINUX_TEST_RESULT([has_register_sysctl_sz], [
47		AC_MSG_RESULT([yes])
48		AC_DEFINE(HAVE_REGISTER_SYSCTL_SZ, 1,
49			[register_sysctl_sz exists])
50	],[
51		AC_MSG_RESULT([no])
52	])
53])
54
55dnl #
56dnl # Linux 6.11 makes const the ctl_table arg of proc_handler
57dnl #
58AC_DEFUN([ZFS_AC_KERNEL_SRC_PROC_HANDLER_CTL_TABLE_CONST], [
59	ZFS_LINUX_TEST_SRC([has_proc_handler_ctl_table_const], [
60		#include <linux/sysctl.h>
61
62		static int test_handler(
63		    const struct ctl_table *ctl __attribute((unused)),
64		    int write __attribute((unused)),
65		    void *buffer __attribute((unused)),
66		    size_t *lenp __attribute((unused)),
67		    loff_t *ppos __attribute((unused)))
68		{
69			return (0);
70		}
71	], [
72		proc_handler *ph __attribute((unused)) =
73		    &test_handler;
74	])
75])
76
77AC_DEFUN([ZFS_AC_KERNEL_PROC_HANDLER_CTL_TABLE_CONST], [
78	AC_MSG_CHECKING([whether proc_handler ctl_table arg is const])
79	ZFS_LINUX_TEST_RESULT([has_proc_handler_ctl_table_const], [
80		AC_MSG_RESULT([yes])
81		AC_DEFINE(HAVE_PROC_HANDLER_CTL_TABLE_CONST, 1,
82		    [proc_handler ctl_table arg is const])
83	], [
84		AC_MSG_RESULT([no])
85	])
86])
87