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