]>
Commit | Line | Data |
---|---|---|
f8149110 | 1 | # |
0bba1a49 | 2 | # Check if we have a working madvise system call |
f8149110 | 3 | # |
0bba1a49 NS |
4 | AC_DEFUN([AC_HAVE_MADVISE], |
5 | [ AC_MSG_CHECKING([for madvise ]) | |
69d66277 DC |
6 | AC_COMPILE_IFELSE( |
7 | [ AC_LANG_PROGRAM([[ | |
0bba1a49 | 8 | #define _GNU_SOURCE |
0bba1a49 | 9 | #include <sys/mman.h> |
69d66277 DC |
10 | ]], [[ |
11 | posix_madvise(0, 0, MADV_NORMAL); | |
12 | ]]) | |
0bba1a49 NS |
13 | ], have_madvise=yes |
14 | AC_MSG_RESULT(yes), | |
15 | AC_MSG_RESULT(no)) | |
16 | AC_SUBST(have_madvise) | |
17 | ]) | |
18 | ||
f8149110 | 19 | # |
0bba1a49 | 20 | # Check if we have a working mincore system call |
f8149110 | 21 | # |
0bba1a49 NS |
22 | AC_DEFUN([AC_HAVE_MINCORE], |
23 | [ AC_MSG_CHECKING([for mincore ]) | |
69d66277 DC |
24 | AC_COMPILE_IFELSE( |
25 | [ AC_LANG_PROGRAM([[ | |
0bba1a49 | 26 | #define _GNU_SOURCE |
0bba1a49 | 27 | #include <sys/mman.h> |
69d66277 DC |
28 | ]], [[ |
29 | mincore(0, 0, 0); | |
30 | ]]) | |
0bba1a49 NS |
31 | ], have_mincore=yes |
32 | AC_MSG_RESULT(yes), | |
33 | AC_MSG_RESULT(no)) | |
34 | AC_SUBST(have_mincore) | |
35 | ]) | |
36 | ||
f8149110 | 37 | # |
0bba1a49 | 38 | # Check if we have a working sendfile system call |
f8149110 | 39 | # |
0bba1a49 NS |
40 | AC_DEFUN([AC_HAVE_SENDFILE], |
41 | [ AC_MSG_CHECKING([for sendfile ]) | |
69d66277 DC |
42 | AC_COMPILE_IFELSE( |
43 | [ AC_LANG_PROGRAM([[ | |
0bba1a49 | 44 | #define _GNU_SOURCE |
0bba1a49 | 45 | #include <sys/sendfile.h> |
69d66277 DC |
46 | ]], [[ |
47 | sendfile(0, 0, 0, 0); | |
48 | ]]) | |
0bba1a49 NS |
49 | ], have_sendfile=yes |
50 | AC_MSG_RESULT(yes), | |
51 | AC_MSG_RESULT(no)) | |
52 | AC_SUBST(have_sendfile) | |
53 | ]) | |
cfe6e3f0 | 54 | |
c0b5232a ES |
55 | # |
56 | # Check if we have a fallocate libc call (Linux) | |
57 | # | |
58 | AC_DEFUN([AC_HAVE_FALLOCATE], | |
59 | [ AC_MSG_CHECKING([for fallocate]) | |
69d66277 DC |
60 | AC_LINK_IFELSE( |
61 | [ AC_LANG_PROGRAM([[ | |
c17c73e2 | 62 | #define _GNU_SOURCE |
c17c73e2 | 63 | #include <fcntl.h> |
c0b5232a | 64 | #include <linux/falloc.h> |
69d66277 DC |
65 | ]], [[ |
66 | fallocate(0, 0, 0, 0); | |
67 | ]]) | |
c0b5232a ES |
68 | ], have_fallocate=yes |
69 | AC_MSG_RESULT(yes), | |
70 | AC_MSG_RESULT(no)) | |
71 | AC_SUBST(have_fallocate) | |
72 | ]) | |
8f0e0912 CH |
73 | |
74 | # | |
75 | # Check if we have the fiemap ioctl (Linux) | |
76 | # | |
77 | AC_DEFUN([AC_HAVE_FIEMAP], | |
2912da5d | 78 | [ AC_MSG_CHECKING([for fiemap]) |
69d66277 DC |
79 | AC_LINK_IFELSE( |
80 | [ AC_LANG_PROGRAM([[ | |
2912da5d | 81 | #define _GNU_SOURCE |
2912da5d NS |
82 | #include <linux/fs.h> |
83 | #include <linux/fiemap.h> | |
d6642ab8 | 84 | #include <sys/ioctl.h> |
69d66277 DC |
85 | ]], [[ |
86 | struct fiemap *fiemap; | |
87 | ioctl(0, FS_IOC_FIEMAP, (unsigned long)fiemap); | |
88 | ]]) | |
2912da5d NS |
89 | ], have_fiemap=yes |
90 | AC_MSG_RESULT(yes), | |
91 | AC_MSG_RESULT(no)) | |
8f0e0912 CH |
92 | AC_SUBST(have_fiemap) |
93 | ]) | |
197d5828 ES |
94 | |
95 | # | |
96 | # Check if we have a preadv libc call (Linux) | |
97 | # | |
98 | AC_DEFUN([AC_HAVE_PREADV], | |
99 | [ AC_MSG_CHECKING([for preadv]) | |
69d66277 DC |
100 | AC_LINK_IFELSE( |
101 | [ AC_LANG_PROGRAM([[ | |
197d5828 | 102 | #define _BSD_SOURCE |
c1436573 | 103 | #define _DEFAULT_SOURCE |
197d5828 | 104 | #include <sys/uio.h> |
69d66277 DC |
105 | ]], [[ |
106 | preadv(0, 0, 0, 0); | |
107 | ]]) | |
197d5828 ES |
108 | ], have_preadv=yes |
109 | AC_MSG_RESULT(yes), | |
110 | AC_MSG_RESULT(no)) | |
111 | AC_SUBST(have_preadv) | |
112 | ]) | |
113 | ||
c5deeac9 GR |
114 | # |
115 | # Check if we have a pwritev2 libc call (Linux) | |
116 | # | |
117 | AC_DEFUN([AC_HAVE_PWRITEV2], | |
118 | [ AC_MSG_CHECKING([for pwritev2]) | |
69d66277 DC |
119 | AC_LINK_IFELSE( |
120 | [ AC_LANG_PROGRAM([[ | |
d6642ab8 | 121 | #define _GNU_SOURCE |
c5deeac9 | 122 | #include <sys/uio.h> |
69d66277 DC |
123 | ]], [[ |
124 | pwritev2(0, 0, 0, 0, 0); | |
125 | ]]) | |
c5deeac9 GR |
126 | ], have_pwritev2=yes |
127 | AC_MSG_RESULT(yes), | |
128 | AC_MSG_RESULT(no)) | |
129 | AC_SUBST(have_pwritev2) | |
130 | ]) | |
131 | ||
628e112a AS |
132 | # |
133 | # Check if we have a copy_file_range system call (Linux) | |
134 | # | |
135 | AC_DEFUN([AC_HAVE_COPY_FILE_RANGE], | |
136 | [ AC_MSG_CHECKING([for copy_file_range]) | |
69d66277 DC |
137 | AC_LINK_IFELSE( |
138 | [ AC_LANG_PROGRAM([[ | |
628e112a AS |
139 | #define _GNU_SOURCE |
140 | #include <sys/syscall.h> | |
141 | #include <unistd.h> | |
69d66277 DC |
142 | ]], [[ |
143 | syscall(__NR_copy_file_range, 0, 0, 0, 0, 0, 0); | |
144 | ]]) | |
628e112a AS |
145 | ], have_copy_file_range=yes |
146 | AC_MSG_RESULT(yes), | |
147 | AC_MSG_RESULT(no)) | |
148 | AC_SUBST(have_copy_file_range) | |
149 | ]) | |
150 | ||
197d5828 ES |
151 | # |
152 | # Check if we have a sync_file_range libc call (Linux) | |
153 | # | |
154 | AC_DEFUN([AC_HAVE_SYNC_FILE_RANGE], | |
155 | [ AC_MSG_CHECKING([for sync_file_range]) | |
69d66277 DC |
156 | AC_LINK_IFELSE( |
157 | [ AC_LANG_PROGRAM([[ | |
197d5828 | 158 | #define _GNU_SOURCE |
197d5828 | 159 | #include <fcntl.h> |
69d66277 DC |
160 | ]], [[ |
161 | sync_file_range(0, 0, 0, 0); | |
162 | ]]) | |
197d5828 ES |
163 | ], have_sync_file_range=yes |
164 | AC_MSG_RESULT(yes), | |
165 | AC_MSG_RESULT(no)) | |
166 | AC_SUBST(have_sync_file_range) | |
167 | ]) | |
168 | ||
c7dd81c7 ES |
169 | # |
170 | # Check if we have a syncfs libc call (Linux) | |
171 | # | |
172 | AC_DEFUN([AC_HAVE_SYNCFS], | |
173 | [ AC_MSG_CHECKING([for syncfs]) | |
69d66277 DC |
174 | AC_LINK_IFELSE( |
175 | [ AC_LANG_PROGRAM([[ | |
c7dd81c7 | 176 | #define _GNU_SOURCE |
c7dd81c7 | 177 | #include <unistd.h> |
69d66277 DC |
178 | ]], [[ |
179 | syncfs(0); | |
180 | ]]) | |
eb24bcff | 181 | ], have_syncfs=yes |
c7dd81c7 ES |
182 | AC_MSG_RESULT(yes), |
183 | AC_MSG_RESULT(no)) | |
184 | AC_SUBST(have_syncfs) | |
185 | ]) | |
186 | ||
3bc05641 BF |
187 | # |
188 | # Check if we have a readdir libc call | |
189 | # | |
190 | AC_DEFUN([AC_HAVE_READDIR], | |
191 | [ AC_MSG_CHECKING([for readdir]) | |
69d66277 DC |
192 | AC_LINK_IFELSE( |
193 | [ AC_LANG_PROGRAM([[ | |
3bc05641 | 194 | #include <dirent.h> |
69d66277 DC |
195 | ]], [[ |
196 | readdir(0); | |
197 | ]]) | |
3bc05641 BF |
198 | ], have_readdir=yes |
199 | AC_MSG_RESULT(yes), | |
200 | AC_MSG_RESULT(no)) | |
201 | AC_SUBST(have_readdir) | |
202 | ]) | |
203 | ||
5121281b JT |
204 | # |
205 | # Check if we have a flc call (Mac OS X) | |
206 | # | |
207 | AC_DEFUN([AC_HAVE_FLS], | |
208 | [ AC_CHECK_DECL([fls], | |
209 | have_fls=yes, | |
210 | [], | |
211 | [#include <string.h>] | |
212 | ) | |
213 | AC_SUBST(have_fls) | |
214 | ]) | |
215 | ||
c14c7b79 | 216 | # |
f5629402 | 217 | # Check if we have a fsetxattr call |
c14c7b79 JT |
218 | # |
219 | AC_DEFUN([AC_HAVE_FSETXATTR], | |
220 | [ AC_CHECK_DECL([fsetxattr], | |
221 | have_fsetxattr=yes, | |
222 | [], | |
223 | [#include <sys/types.h> | |
f5629402 | 224 | #include <sys/xattr.h>] |
c14c7b79 JT |
225 | ) |
226 | AC_SUBST(have_fsetxattr) | |
227 | ]) | |
228 | ||
a49984b3 JT |
229 | # |
230 | # Check if we have a mremap call (not on Mac OS X) | |
231 | # | |
232 | AC_DEFUN([AC_HAVE_MREMAP], | |
233 | [ AC_CHECK_DECL([mremap], | |
234 | have_mremap=yes, | |
235 | [], | |
236 | [#define _GNU_SOURCE | |
237 | #include <sys/mman.h>] | |
238 | ) | |
239 | AC_SUBST(have_mremap) | |
240 | ]) | |
6529e656 DW |
241 | |
242 | # | |
243 | # Check if we need to override the system struct fsxattr with | |
244 | # the internal definition. This /only/ happens if the system | |
245 | # actually defines struct fsxattr /and/ the system definition | |
246 | # is missing certain fields. | |
247 | # | |
248 | AC_DEFUN([AC_NEED_INTERNAL_FSXATTR], | |
249 | [ | |
1e51132f DW |
250 | AC_CHECK_TYPE(struct fsxattr, |
251 | [ | |
252 | AC_CHECK_MEMBER(struct fsxattr.fsx_cowextsize, | |
253 | , | |
254 | need_internal_fsxattr=yes, | |
255 | [#include <linux/fs.h>] | |
256 | ) | |
257 | ],, | |
258 | [#include <linux/fs.h>] | |
259 | ) | |
6529e656 DW |
260 | AC_SUBST(need_internal_fsxattr) |
261 | ]) | |
71956d72 | 262 | |
dfe209d8 EB |
263 | # |
264 | # Check if we need to override the system struct fscrypt_add_key_arg | |
265 | # with the internal definition. This /only/ happens if the system | |
266 | # actually defines struct fscrypt_add_key_arg /and/ the system | |
267 | # definition is missing certain fields. | |
268 | # | |
269 | AC_DEFUN([AC_NEED_INTERNAL_FSCRYPT_ADD_KEY_ARG], | |
270 | [ | |
271 | AC_CHECK_TYPE(struct fscrypt_add_key_arg, | |
272 | [ | |
273 | AC_CHECK_MEMBER(struct fscrypt_add_key_arg.key_id, | |
274 | , | |
275 | need_internal_fscrypt_add_key_arg=yes, | |
276 | [#include <linux/fs.h>] | |
277 | ) | |
278 | ],, | |
279 | [#include <linux/fs.h>] | |
280 | ) | |
281 | AC_SUBST(need_internal_fscrypt_add_key_arg) | |
282 | ]) | |
283 | ||
e97caf71 EB |
284 | # |
285 | # Check if we need to override the system struct fscrypt_policy_v2 | |
286 | # with the internal definition. This /only/ happens if the system | |
287 | # actually defines struct fscrypt_policy_v2 /and/ the system | |
288 | # definition is missing certain fields. | |
289 | # | |
290 | AC_DEFUN([AC_NEED_INTERNAL_FSCRYPT_POLICY_V2], | |
291 | [ | |
292 | AC_CHECK_TYPE(struct fscrypt_policy_v2, | |
293 | [ | |
294 | AC_CHECK_MEMBER(struct fscrypt_policy_v2.log2_data_unit_size, | |
295 | , | |
296 | need_internal_fscrypt_policy_v2=yes, | |
297 | [#include <linux/fs.h>] | |
298 | ) | |
299 | ],, | |
300 | [#include <linux/fs.h>] | |
301 | ) | |
302 | AC_SUBST(need_internal_fscrypt_policy_v2) | |
303 | ]) | |
304 | ||
71956d72 DW |
305 | # |
306 | # Check if we have a FS_IOC_GETFSMAP ioctl (Linux) | |
307 | # | |
308 | AC_DEFUN([AC_HAVE_GETFSMAP], | |
309 | [ AC_MSG_CHECKING([for GETFSMAP]) | |
69d66277 DC |
310 | AC_LINK_IFELSE( |
311 | [ AC_LANG_PROGRAM([[ | |
71956d72 DW |
312 | #define _GNU_SOURCE |
313 | #include <sys/syscall.h> | |
314 | #include <unistd.h> | |
315 | #include <linux/fs.h> | |
316 | #include <linux/fsmap.h> | |
69d66277 DC |
317 | ]], [[ |
318 | unsigned long x = FS_IOC_GETFSMAP; | |
319 | struct fsmap_head fh; | |
320 | ]]) | |
71956d72 DW |
321 | ], have_getfsmap=yes |
322 | AC_MSG_RESULT(yes), | |
323 | AC_MSG_RESULT(no)) | |
324 | AC_SUBST(have_getfsmap) | |
325 | ]) | |
ce9adab0 JM |
326 | |
327 | AC_DEFUN([AC_HAVE_STATFS_FLAGS], | |
328 | [ | |
329 | AC_CHECK_TYPE(struct statfs, | |
330 | [ | |
331 | AC_CHECK_MEMBER(struct statfs.f_flags, | |
332 | have_statfs_flags=yes,, | |
333 | [#include <sys/vfs.h>] | |
334 | ) | |
335 | ],, | |
336 | [#include <sys/vfs.h>] | |
337 | ) | |
338 | AC_SUBST(have_statfs_flags) | |
339 | ]) | |
dad79683 RZ |
340 | |
341 | # | |
342 | # Check if we have MAP_SYNC defines (Linux) | |
343 | # | |
344 | AC_DEFUN([AC_HAVE_MAP_SYNC], | |
345 | [ AC_MSG_CHECKING([for MAP_SYNC]) | |
69d66277 DC |
346 | AC_COMPILE_IFELSE( |
347 | [ AC_LANG_PROGRAM([[ | |
28965957 | 348 | #include <sys/mman.h> |
69d66277 DC |
349 | ]], [[ |
350 | int flags = MAP_SYNC | MAP_SHARED_VALIDATE; | |
351 | ]]) | |
dad79683 RZ |
352 | ], have_map_sync=yes |
353 | AC_MSG_RESULT(yes), | |
354 | AC_MSG_RESULT(no)) | |
355 | AC_SUBST(have_map_sync) | |
356 | ]) | |
173a0283 DW |
357 | |
358 | # | |
359 | # Check if we have a mallinfo libc call | |
360 | # | |
361 | AC_DEFUN([AC_HAVE_MALLINFO], | |
362 | [ AC_MSG_CHECKING([for mallinfo ]) | |
69d66277 DC |
363 | AC_COMPILE_IFELSE( |
364 | [ AC_LANG_PROGRAM([[ | |
173a0283 | 365 | #include <malloc.h> |
69d66277 DC |
366 | ]], [[ |
367 | struct mallinfo test; | |
173a0283 | 368 | |
69d66277 DC |
369 | test.arena = 0; test.hblkhd = 0; test.uordblks = 0; test.fordblks = 0; |
370 | test = mallinfo(); | |
371 | ]]) | |
173a0283 DW |
372 | ], have_mallinfo=yes |
373 | AC_MSG_RESULT(yes), | |
374 | AC_MSG_RESULT(no)) | |
375 | AC_SUBST(have_mallinfo) | |
376 | ]) | |
b364a9c0 | 377 | |
c74f0468 DW |
378 | # |
379 | # Check if we have a mallinfo2 libc call | |
380 | # | |
381 | AC_DEFUN([AC_HAVE_MALLINFO2], | |
382 | [ AC_MSG_CHECKING([for mallinfo2 ]) | |
1a35c8df DW |
383 | AC_COMPILE_IFELSE( |
384 | [ AC_LANG_PROGRAM([[ | |
c74f0468 | 385 | #include <malloc.h> |
1a35c8df DW |
386 | ]], [[ |
387 | struct mallinfo2 test; | |
c74f0468 | 388 | |
1a35c8df DW |
389 | test.arena = 0; test.hblkhd = 0; test.uordblks = 0; test.fordblks = 0; |
390 | test = mallinfo2(); | |
391 | ]]) | |
c74f0468 DW |
392 | ], have_mallinfo2=yes |
393 | AC_MSG_RESULT(yes), | |
394 | AC_MSG_RESULT(no)) | |
395 | AC_SUBST(have_mallinfo2) | |
396 | ]) | |
397 | ||
b364a9c0 DW |
398 | # |
399 | # Check if we have a openat call | |
400 | # | |
401 | AC_DEFUN([AC_HAVE_OPENAT], | |
402 | [ AC_CHECK_DECL([openat], | |
403 | have_openat=yes, | |
404 | [], | |
405 | [#include <sys/types.h> | |
406 | #include <sys/stat.h> | |
407 | #include <fcntl.h>] | |
408 | ) | |
409 | AC_SUBST(have_openat) | |
410 | ]) | |
411 | ||
412 | # | |
413 | # Check if we have a fstatat call | |
414 | # | |
415 | AC_DEFUN([AC_HAVE_FSTATAT], | |
416 | [ AC_CHECK_DECL([fstatat], | |
417 | have_fstatat=yes, | |
418 | [], | |
419 | [#define _GNU_SOURCE | |
420 | #include <sys/types.h> | |
421 | #include <sys/stat.h> | |
422 | #include <unistd.h>]) | |
423 | AC_SUBST(have_fstatat) | |
424 | ]) | |
03c0cd8f DW |
425 | |
426 | # | |
427 | # Check if we have the SG_IO ioctl | |
428 | # | |
429 | AC_DEFUN([AC_HAVE_SG_IO], | |
430 | [ AC_MSG_CHECKING([for struct sg_io_hdr ]) | |
69d66277 DC |
431 | AC_COMPILE_IFELSE( |
432 | [ AC_LANG_PROGRAM([[ | |
433 | #include <scsi/sg.h> | |
d6642ab8 | 434 | #include <sys/ioctl.h> |
69d66277 DC |
435 | ]], [[ |
436 | struct sg_io_hdr hdr; | |
437 | ioctl(0, SG_IO, &hdr); | |
438 | ]]) | |
03c0cd8f DW |
439 | ], have_sg_io=yes |
440 | AC_MSG_RESULT(yes), | |
441 | AC_MSG_RESULT(no)) | |
442 | AC_SUBST(have_sg_io) | |
443 | ]) | |
444 | ||
445 | # | |
446 | # Check if we have the HDIO_GETGEO ioctl | |
447 | # | |
448 | AC_DEFUN([AC_HAVE_HDIO_GETGEO], | |
449 | [ AC_MSG_CHECKING([for struct hd_geometry ]) | |
69d66277 DC |
450 | AC_COMPILE_IFELSE( |
451 | [ AC_LANG_PROGRAM([[ | |
d6642ab8 AS |
452 | #include <linux/hdreg.h> |
453 | #include <sys/ioctl.h> | |
69d66277 DC |
454 | ]], [[ |
455 | struct hd_geometry hdr; | |
456 | ioctl(0, HDIO_GETGEO, &hdr); | |
457 | ]]) | |
03c0cd8f DW |
458 | ], have_hdio_getgeo=yes |
459 | AC_MSG_RESULT(yes), | |
460 | AC_MSG_RESULT(no)) | |
461 | AC_SUBST(have_hdio_getgeo) | |
462 | ]) | |
1b0adc71 | 463 | |
e61f1552 DW |
464 | AC_DEFUN([AC_PACKAGE_CHECK_LTO], |
465 | [ AC_MSG_CHECKING([if C compiler supports LTO]) | |
466 | OLD_CFLAGS="$CFLAGS" | |
467 | OLD_LDFLAGS="$LDFLAGS" | |
468 | LTO_FLAGS="-flto -ffat-lto-objects" | |
469 | CFLAGS="$CFLAGS $LTO_FLAGS" | |
470 | LDFLAGS="$LDFLAGS $LTO_FLAGS" | |
471 | AC_LINK_IFELSE([AC_LANG_PROGRAM([])], | |
472 | [AC_MSG_RESULT([yes])] | |
473 | [lto_cflags=$LTO_FLAGS] | |
474 | [lto_ldflags=$LTO_FLAGS] | |
475 | [AC_PATH_PROG(gcc_ar, gcc-ar,,)] | |
476 | [AC_PATH_PROG(gcc_ranlib, gcc-ranlib,,)], | |
477 | [AC_MSG_RESULT([no])]) | |
478 | if test -x "$gcc_ar" && test -x "$gcc_ranlib"; then | |
479 | have_lto=yes | |
480 | fi | |
481 | CFLAGS="${OLD_CFLAGS}" | |
482 | LDFLAGS="${OLD_LDFLAGS}" | |
483 | AC_SUBST(gcc_ar) | |
484 | AC_SUBST(gcc_ranlib) | |
485 | AC_SUBST(have_lto) | |
486 | AC_SUBST(lto_cflags) | |
487 | AC_SUBST(lto_ldflags) | |
488 | ]) |