]>
Commit | Line | Data |
---|---|---|
197d5828 ES |
1 | # |
2 | # Check if we have a preadv libc call (Linux) | |
3 | # | |
4 | AC_DEFUN([AC_HAVE_PREADV], | |
5 | [ AC_MSG_CHECKING([for preadv]) | |
69d66277 DC |
6 | AC_LINK_IFELSE( |
7 | [ AC_LANG_PROGRAM([[ | |
197d5828 | 8 | #define _BSD_SOURCE |
c1436573 | 9 | #define _DEFAULT_SOURCE |
197d5828 | 10 | #include <sys/uio.h> |
69d66277 DC |
11 | ]], [[ |
12 | preadv(0, 0, 0, 0); | |
13 | ]]) | |
197d5828 ES |
14 | ], have_preadv=yes |
15 | AC_MSG_RESULT(yes), | |
16 | AC_MSG_RESULT(no)) | |
17 | AC_SUBST(have_preadv) | |
18 | ]) | |
19 | ||
c5deeac9 GR |
20 | # |
21 | # Check if we have a pwritev2 libc call (Linux) | |
22 | # | |
23 | AC_DEFUN([AC_HAVE_PWRITEV2], | |
24 | [ AC_MSG_CHECKING([for pwritev2]) | |
69d66277 DC |
25 | AC_LINK_IFELSE( |
26 | [ AC_LANG_PROGRAM([[ | |
d6642ab8 | 27 | #define _GNU_SOURCE |
c5deeac9 | 28 | #include <sys/uio.h> |
69d66277 DC |
29 | ]], [[ |
30 | pwritev2(0, 0, 0, 0, 0); | |
31 | ]]) | |
c5deeac9 GR |
32 | ], have_pwritev2=yes |
33 | AC_MSG_RESULT(yes), | |
34 | AC_MSG_RESULT(no)) | |
35 | AC_SUBST(have_pwritev2) | |
36 | ]) | |
37 | ||
628e112a AS |
38 | # |
39 | # Check if we have a copy_file_range system call (Linux) | |
40 | # | |
41 | AC_DEFUN([AC_HAVE_COPY_FILE_RANGE], | |
42 | [ AC_MSG_CHECKING([for copy_file_range]) | |
69d66277 DC |
43 | AC_LINK_IFELSE( |
44 | [ AC_LANG_PROGRAM([[ | |
628e112a AS |
45 | #define _GNU_SOURCE |
46 | #include <sys/syscall.h> | |
47 | #include <unistd.h> | |
69d66277 DC |
48 | ]], [[ |
49 | syscall(__NR_copy_file_range, 0, 0, 0, 0, 0, 0); | |
50 | ]]) | |
628e112a AS |
51 | ], have_copy_file_range=yes |
52 | AC_MSG_RESULT(yes), | |
53 | AC_MSG_RESULT(no)) | |
54 | AC_SUBST(have_copy_file_range) | |
55 | ]) | |
56 | ||
c14c7b79 | 57 | # |
f5629402 | 58 | # Check if we have a fsetxattr call |
c14c7b79 JT |
59 | # |
60 | AC_DEFUN([AC_HAVE_FSETXATTR], | |
61 | [ AC_CHECK_DECL([fsetxattr], | |
62 | have_fsetxattr=yes, | |
63 | [], | |
64 | [#include <sys/types.h> | |
f5629402 | 65 | #include <sys/xattr.h>] |
c14c7b79 JT |
66 | ) |
67 | AC_SUBST(have_fsetxattr) | |
68 | ]) | |
69 | ||
a49984b3 JT |
70 | # |
71 | # Check if we have a mremap call (not on Mac OS X) | |
72 | # | |
73 | AC_DEFUN([AC_HAVE_MREMAP], | |
74 | [ AC_CHECK_DECL([mremap], | |
75 | have_mremap=yes, | |
76 | [], | |
77 | [#define _GNU_SOURCE | |
78 | #include <sys/mman.h>] | |
79 | ) | |
80 | AC_SUBST(have_mremap) | |
81 | ]) | |
6529e656 DW |
82 | |
83 | # | |
84 | # Check if we need to override the system struct fsxattr with | |
85 | # the internal definition. This /only/ happens if the system | |
86 | # actually defines struct fsxattr /and/ the system definition | |
87 | # is missing certain fields. | |
88 | # | |
89 | AC_DEFUN([AC_NEED_INTERNAL_FSXATTR], | |
90 | [ | |
1e51132f DW |
91 | AC_CHECK_TYPE(struct fsxattr, |
92 | [ | |
93 | AC_CHECK_MEMBER(struct fsxattr.fsx_cowextsize, | |
94 | , | |
95 | need_internal_fsxattr=yes, | |
96 | [#include <linux/fs.h>] | |
97 | ) | |
98 | ],, | |
99 | [#include <linux/fs.h>] | |
100 | ) | |
6529e656 DW |
101 | AC_SUBST(need_internal_fsxattr) |
102 | ]) | |
71956d72 | 103 | |
dfe209d8 EB |
104 | # |
105 | # Check if we need to override the system struct fscrypt_add_key_arg | |
106 | # with the internal definition. This /only/ happens if the system | |
107 | # actually defines struct fscrypt_add_key_arg /and/ the system | |
108 | # definition is missing certain fields. | |
109 | # | |
110 | AC_DEFUN([AC_NEED_INTERNAL_FSCRYPT_ADD_KEY_ARG], | |
111 | [ | |
112 | AC_CHECK_TYPE(struct fscrypt_add_key_arg, | |
113 | [ | |
114 | AC_CHECK_MEMBER(struct fscrypt_add_key_arg.key_id, | |
115 | , | |
116 | need_internal_fscrypt_add_key_arg=yes, | |
117 | [#include <linux/fs.h>] | |
118 | ) | |
119 | ],, | |
120 | [#include <linux/fs.h>] | |
121 | ) | |
122 | AC_SUBST(need_internal_fscrypt_add_key_arg) | |
123 | ]) | |
124 | ||
e97caf71 EB |
125 | # |
126 | # Check if we need to override the system struct fscrypt_policy_v2 | |
127 | # with the internal definition. This /only/ happens if the system | |
128 | # actually defines struct fscrypt_policy_v2 /and/ the system | |
129 | # definition is missing certain fields. | |
130 | # | |
131 | AC_DEFUN([AC_NEED_INTERNAL_FSCRYPT_POLICY_V2], | |
132 | [ | |
133 | AC_CHECK_TYPE(struct fscrypt_policy_v2, | |
134 | [ | |
135 | AC_CHECK_MEMBER(struct fscrypt_policy_v2.log2_data_unit_size, | |
136 | , | |
137 | need_internal_fscrypt_policy_v2=yes, | |
138 | [#include <linux/fs.h>] | |
139 | ) | |
140 | ],, | |
141 | [#include <linux/fs.h>] | |
142 | ) | |
143 | AC_SUBST(need_internal_fscrypt_policy_v2) | |
144 | ]) | |
145 | ||
71956d72 DW |
146 | # |
147 | # Check if we have a FS_IOC_GETFSMAP ioctl (Linux) | |
148 | # | |
149 | AC_DEFUN([AC_HAVE_GETFSMAP], | |
150 | [ AC_MSG_CHECKING([for GETFSMAP]) | |
69d66277 DC |
151 | AC_LINK_IFELSE( |
152 | [ AC_LANG_PROGRAM([[ | |
71956d72 DW |
153 | #define _GNU_SOURCE |
154 | #include <sys/syscall.h> | |
155 | #include <unistd.h> | |
156 | #include <linux/fs.h> | |
157 | #include <linux/fsmap.h> | |
69d66277 DC |
158 | ]], [[ |
159 | unsigned long x = FS_IOC_GETFSMAP; | |
160 | struct fsmap_head fh; | |
161 | ]]) | |
71956d72 DW |
162 | ], have_getfsmap=yes |
163 | AC_MSG_RESULT(yes), | |
164 | AC_MSG_RESULT(no)) | |
165 | AC_SUBST(have_getfsmap) | |
166 | ]) | |
ce9adab0 JM |
167 | |
168 | AC_DEFUN([AC_HAVE_STATFS_FLAGS], | |
169 | [ | |
170 | AC_CHECK_TYPE(struct statfs, | |
171 | [ | |
172 | AC_CHECK_MEMBER(struct statfs.f_flags, | |
173 | have_statfs_flags=yes,, | |
174 | [#include <sys/vfs.h>] | |
175 | ) | |
176 | ],, | |
177 | [#include <sys/vfs.h>] | |
178 | ) | |
179 | AC_SUBST(have_statfs_flags) | |
180 | ]) | |
dad79683 RZ |
181 | |
182 | # | |
183 | # Check if we have MAP_SYNC defines (Linux) | |
184 | # | |
185 | AC_DEFUN([AC_HAVE_MAP_SYNC], | |
186 | [ AC_MSG_CHECKING([for MAP_SYNC]) | |
69d66277 DC |
187 | AC_COMPILE_IFELSE( |
188 | [ AC_LANG_PROGRAM([[ | |
28965957 | 189 | #include <sys/mman.h> |
69d66277 DC |
190 | ]], [[ |
191 | int flags = MAP_SYNC | MAP_SHARED_VALIDATE; | |
192 | ]]) | |
dad79683 RZ |
193 | ], have_map_sync=yes |
194 | AC_MSG_RESULT(yes), | |
195 | AC_MSG_RESULT(no)) | |
196 | AC_SUBST(have_map_sync) | |
197 | ]) | |
173a0283 DW |
198 | |
199 | # | |
200 | # Check if we have a mallinfo libc call | |
201 | # | |
202 | AC_DEFUN([AC_HAVE_MALLINFO], | |
203 | [ AC_MSG_CHECKING([for mallinfo ]) | |
69d66277 DC |
204 | AC_COMPILE_IFELSE( |
205 | [ AC_LANG_PROGRAM([[ | |
173a0283 | 206 | #include <malloc.h> |
69d66277 DC |
207 | ]], [[ |
208 | struct mallinfo test; | |
173a0283 | 209 | |
69d66277 DC |
210 | test.arena = 0; test.hblkhd = 0; test.uordblks = 0; test.fordblks = 0; |
211 | test = mallinfo(); | |
212 | ]]) | |
173a0283 DW |
213 | ], have_mallinfo=yes |
214 | AC_MSG_RESULT(yes), | |
215 | AC_MSG_RESULT(no)) | |
216 | AC_SUBST(have_mallinfo) | |
217 | ]) | |
b364a9c0 | 218 | |
c74f0468 DW |
219 | # |
220 | # Check if we have a mallinfo2 libc call | |
221 | # | |
222 | AC_DEFUN([AC_HAVE_MALLINFO2], | |
223 | [ AC_MSG_CHECKING([for mallinfo2 ]) | |
1a35c8df DW |
224 | AC_COMPILE_IFELSE( |
225 | [ AC_LANG_PROGRAM([[ | |
c74f0468 | 226 | #include <malloc.h> |
1a35c8df DW |
227 | ]], [[ |
228 | struct mallinfo2 test; | |
c74f0468 | 229 | |
1a35c8df DW |
230 | test.arena = 0; test.hblkhd = 0; test.uordblks = 0; test.fordblks = 0; |
231 | test = mallinfo2(); | |
232 | ]]) | |
c74f0468 DW |
233 | ], have_mallinfo2=yes |
234 | AC_MSG_RESULT(yes), | |
235 | AC_MSG_RESULT(no)) | |
236 | AC_SUBST(have_mallinfo2) | |
237 | ]) | |
238 | ||
b364a9c0 DW |
239 | # |
240 | # Check if we have a openat call | |
241 | # | |
242 | AC_DEFUN([AC_HAVE_OPENAT], | |
243 | [ AC_CHECK_DECL([openat], | |
244 | have_openat=yes, | |
245 | [], | |
246 | [#include <sys/types.h> | |
247 | #include <sys/stat.h> | |
248 | #include <fcntl.h>] | |
249 | ) | |
250 | AC_SUBST(have_openat) | |
251 | ]) | |
252 | ||
253 | # | |
254 | # Check if we have a fstatat call | |
255 | # | |
256 | AC_DEFUN([AC_HAVE_FSTATAT], | |
257 | [ AC_CHECK_DECL([fstatat], | |
258 | have_fstatat=yes, | |
259 | [], | |
260 | [#define _GNU_SOURCE | |
261 | #include <sys/types.h> | |
262 | #include <sys/stat.h> | |
263 | #include <unistd.h>]) | |
264 | AC_SUBST(have_fstatat) | |
265 | ]) | |
03c0cd8f DW |
266 | |
267 | # | |
268 | # Check if we have the SG_IO ioctl | |
269 | # | |
270 | AC_DEFUN([AC_HAVE_SG_IO], | |
271 | [ AC_MSG_CHECKING([for struct sg_io_hdr ]) | |
69d66277 DC |
272 | AC_COMPILE_IFELSE( |
273 | [ AC_LANG_PROGRAM([[ | |
274 | #include <scsi/sg.h> | |
d6642ab8 | 275 | #include <sys/ioctl.h> |
69d66277 DC |
276 | ]], [[ |
277 | struct sg_io_hdr hdr; | |
278 | ioctl(0, SG_IO, &hdr); | |
279 | ]]) | |
03c0cd8f DW |
280 | ], have_sg_io=yes |
281 | AC_MSG_RESULT(yes), | |
282 | AC_MSG_RESULT(no)) | |
283 | AC_SUBST(have_sg_io) | |
284 | ]) | |
285 | ||
286 | # | |
287 | # Check if we have the HDIO_GETGEO ioctl | |
288 | # | |
289 | AC_DEFUN([AC_HAVE_HDIO_GETGEO], | |
290 | [ AC_MSG_CHECKING([for struct hd_geometry ]) | |
69d66277 DC |
291 | AC_COMPILE_IFELSE( |
292 | [ AC_LANG_PROGRAM([[ | |
d6642ab8 AS |
293 | #include <linux/hdreg.h> |
294 | #include <sys/ioctl.h> | |
69d66277 DC |
295 | ]], [[ |
296 | struct hd_geometry hdr; | |
297 | ioctl(0, HDIO_GETGEO, &hdr); | |
298 | ]]) | |
03c0cd8f DW |
299 | ], have_hdio_getgeo=yes |
300 | AC_MSG_RESULT(yes), | |
301 | AC_MSG_RESULT(no)) | |
302 | AC_SUBST(have_hdio_getgeo) | |
303 | ]) | |
1b0adc71 | 304 | |
e61f1552 DW |
305 | AC_DEFUN([AC_PACKAGE_CHECK_LTO], |
306 | [ AC_MSG_CHECKING([if C compiler supports LTO]) | |
307 | OLD_CFLAGS="$CFLAGS" | |
308 | OLD_LDFLAGS="$LDFLAGS" | |
309 | LTO_FLAGS="-flto -ffat-lto-objects" | |
310 | CFLAGS="$CFLAGS $LTO_FLAGS" | |
311 | LDFLAGS="$LDFLAGS $LTO_FLAGS" | |
312 | AC_LINK_IFELSE([AC_LANG_PROGRAM([])], | |
313 | [AC_MSG_RESULT([yes])] | |
314 | [lto_cflags=$LTO_FLAGS] | |
315 | [lto_ldflags=$LTO_FLAGS] | |
316 | [AC_PATH_PROG(gcc_ar, gcc-ar,,)] | |
317 | [AC_PATH_PROG(gcc_ranlib, gcc-ranlib,,)], | |
318 | [AC_MSG_RESULT([no])]) | |
319 | if test -x "$gcc_ar" && test -x "$gcc_ranlib"; then | |
320 | have_lto=yes | |
321 | fi | |
322 | CFLAGS="${OLD_CFLAGS}" | |
323 | LDFLAGS="${OLD_LDFLAGS}" | |
324 | AC_SUBST(gcc_ar) | |
325 | AC_SUBST(gcc_ranlib) | |
326 | AC_SUBST(have_lto) | |
327 | AC_SUBST(lto_cflags) | |
328 | AC_SUBST(lto_ldflags) | |
329 | ]) |