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