xref: /freebsd/sys/contrib/openzfs/config/kernel-vfs-iov_iter.m4 (revision 3ff01b231dfa83d518854c63e7c9cd1debd1139e)
1dnl #
2dnl # Check for available iov_iter functionality.
3dnl #
4AC_DEFUN([ZFS_AC_KERNEL_SRC_VFS_IOV_ITER], [
5	ZFS_LINUX_TEST_SRC([iov_iter_types], [
6		#include <linux/fs.h>
7		#include <linux/uio.h>
8	],[
9		int type __attribute__ ((unused)) =
10		    ITER_IOVEC | ITER_KVEC | ITER_BVEC | ITER_PIPE;
11	])
12
13	ZFS_LINUX_TEST_SRC([iov_iter_advance], [
14		#include <linux/fs.h>
15		#include <linux/uio.h>
16	],[
17		struct iov_iter iter = { 0 };
18		size_t advance = 512;
19
20		iov_iter_advance(&iter, advance);
21	])
22
23	ZFS_LINUX_TEST_SRC([iov_iter_revert], [
24		#include <linux/fs.h>
25		#include <linux/uio.h>
26	],[
27		struct iov_iter iter = { 0 };
28		size_t revert = 512;
29
30		iov_iter_revert(&iter, revert);
31	])
32
33	ZFS_LINUX_TEST_SRC([iov_iter_fault_in_readable], [
34		#include <linux/fs.h>
35		#include <linux/uio.h>
36	],[
37		struct iov_iter iter = { 0 };
38		size_t size = 512;
39		int error __attribute__ ((unused));
40
41		error = iov_iter_fault_in_readable(&iter, size);
42	])
43
44	ZFS_LINUX_TEST_SRC([iov_iter_count], [
45		#include <linux/fs.h>
46		#include <linux/uio.h>
47	],[
48		struct iov_iter iter = { 0 };
49		size_t bytes __attribute__ ((unused));
50
51		bytes = iov_iter_count(&iter);
52	])
53
54	ZFS_LINUX_TEST_SRC([copy_to_iter], [
55		#include <linux/fs.h>
56		#include <linux/uio.h>
57	],[
58		struct iov_iter iter = { 0 };
59		char buf[512] = { 0 };
60		size_t size = 512;
61		size_t bytes __attribute__ ((unused));
62
63		bytes = copy_to_iter((const void *)&buf, size, &iter);
64	])
65
66	ZFS_LINUX_TEST_SRC([copy_from_iter], [
67		#include <linux/fs.h>
68		#include <linux/uio.h>
69	],[
70		struct iov_iter iter = { 0 };
71		char buf[512] = { 0 };
72		size_t size = 512;
73		size_t bytes __attribute__ ((unused));
74
75		bytes = copy_from_iter((void *)&buf, size, &iter);
76	])
77])
78
79AC_DEFUN([ZFS_AC_KERNEL_VFS_IOV_ITER], [
80	enable_vfs_iov_iter="yes"
81
82	AC_MSG_CHECKING([whether iov_iter types are available])
83	ZFS_LINUX_TEST_RESULT([iov_iter_types], [
84		AC_MSG_RESULT(yes)
85		AC_DEFINE(HAVE_IOV_ITER_TYPES, 1,
86		    [iov_iter types are available])
87	],[
88		AC_MSG_RESULT(no)
89		enable_vfs_iov_iter="no"
90	])
91
92	AC_MSG_CHECKING([whether iov_iter_advance() is available])
93	ZFS_LINUX_TEST_RESULT([iov_iter_advance], [
94		AC_MSG_RESULT(yes)
95		AC_DEFINE(HAVE_IOV_ITER_ADVANCE, 1,
96		    [iov_iter_advance() is available])
97	],[
98		AC_MSG_RESULT(no)
99		enable_vfs_iov_iter="no"
100	])
101
102	AC_MSG_CHECKING([whether iov_iter_revert() is available])
103	ZFS_LINUX_TEST_RESULT([iov_iter_revert], [
104		AC_MSG_RESULT(yes)
105		AC_DEFINE(HAVE_IOV_ITER_REVERT, 1,
106		    [iov_iter_revert() is available])
107	],[
108		AC_MSG_RESULT(no)
109		enable_vfs_iov_iter="no"
110	])
111
112	AC_MSG_CHECKING([whether iov_iter_fault_in_readable() is available])
113	ZFS_LINUX_TEST_RESULT([iov_iter_fault_in_readable], [
114		AC_MSG_RESULT(yes)
115		AC_DEFINE(HAVE_IOV_ITER_FAULT_IN_READABLE, 1,
116		    [iov_iter_fault_in_readable() is available])
117	],[
118		AC_MSG_RESULT(no)
119		enable_vfs_iov_iter="no"
120	])
121
122	AC_MSG_CHECKING([whether iov_iter_count() is available])
123	ZFS_LINUX_TEST_RESULT([iov_iter_count], [
124		AC_MSG_RESULT(yes)
125		AC_DEFINE(HAVE_IOV_ITER_COUNT, 1,
126		    [iov_iter_count() is available])
127	],[
128		AC_MSG_RESULT(no)
129		enable_vfs_iov_iter="no"
130	])
131
132	AC_MSG_CHECKING([whether copy_to_iter() is available])
133	ZFS_LINUX_TEST_RESULT([copy_to_iter], [
134		AC_MSG_RESULT(yes)
135		AC_DEFINE(HAVE_COPY_TO_ITER, 1,
136		    [copy_to_iter() is available])
137	],[
138		AC_MSG_RESULT(no)
139		enable_vfs_iov_iter="no"
140	])
141
142	AC_MSG_CHECKING([whether copy_from_iter() is available])
143	ZFS_LINUX_TEST_RESULT([copy_from_iter], [
144		AC_MSG_RESULT(yes)
145		AC_DEFINE(HAVE_COPY_FROM_ITER, 1,
146		    [copy_from_iter() is available])
147	],[
148		AC_MSG_RESULT(no)
149		enable_vfs_iov_iter="no"
150	])
151
152	dnl #
153	dnl # As of the 4.9 kernel support is provided for iovecs, kvecs,
154	dnl # bvecs and pipes in the iov_iter structure.  As long as the
155	dnl # other support interfaces are all available the iov_iter can
156	dnl # be correctly used in the uio structure.
157	dnl #
158	AS_IF([test "x$enable_vfs_iov_iter" = "xyes"], [
159		AC_DEFINE(HAVE_VFS_IOV_ITER, 1,
160		    [All required iov_iter interfaces are available])
161	])
162])
163