2 # Check if we have a working fadvise system call
4 AC_DEFUN([AC_HAVE_FADVISE],
5 [ AC_MSG_CHECKING([for fadvise ])
10 posix_fadvise(0, 1, 0, POSIX_FADV_NORMAL);
14 AC_SUBST(have_fadvise)
18 # Check if we have a working madvise system call
20 AC_DEFUN([AC_HAVE_MADVISE],
21 [ AC_MSG_CHECKING([for madvise ])
26 posix_madvise(0, 0, MADV_NORMAL);
30 AC_SUBST(have_madvise)
34 # Check if we have a working mincore system call
36 AC_DEFUN([AC_HAVE_MINCORE],
37 [ AC_MSG_CHECKING([for mincore ])
46 AC_SUBST(have_mincore)
50 # Check if we have a working sendfile system call
52 AC_DEFUN([AC_HAVE_SENDFILE],
53 [ AC_MSG_CHECKING([for sendfile ])
56 #include <sys/sendfile.h>
62 AC_SUBST(have_sendfile)
66 # Check if we have a getmntent libc call (Linux)
68 AC_DEFUN([AC_HAVE_GETMNTENT],
69 [ AC_MSG_CHECKING([for getmntent ])
78 AC_SUBST(have_getmntent)
82 # Check if we have a getmntinfo libc call (FreeBSD, Mac OS X)
84 AC_DEFUN([AC_HAVE_GETMNTINFO],
85 [ AC_MSG_CHECKING([for getmntinfo ])
87 #include <sys/param.h>
88 #include <sys/ucred.h>
89 #include <sys/mount.h>
92 ], have_getmntinfo=yes
95 AC_SUBST(have_getmntinfo)
99 # Check if we have a fallocate libc call (Linux)
101 AC_DEFUN([AC_HAVE_FALLOCATE],
102 [ AC_MSG_CHECKING([for fallocate])
106 #include <linux/falloc.h>
108 fallocate(0, 0, 0, 0);
109 ], have_fallocate=yes
112 AC_SUBST(have_fallocate)
116 # Check if we have the fiemap ioctl (Linux)
118 AC_DEFUN([AC_HAVE_FIEMAP],
119 [ AC_MSG_CHECKING([for fiemap])
122 #include <linux/fs.h>
123 #include <linux/fiemap.h>
125 struct fiemap *fiemap;
126 ioctl(0, FS_IOC_FIEMAP, (unsigned long)fiemap);
130 AC_SUBST(have_fiemap)
134 # Check if we have a preadv libc call (Linux)
136 AC_DEFUN([AC_HAVE_PREADV],
137 [ AC_MSG_CHECKING([for preadv])
140 #define _DEFAULT_SOURCE
147 AC_SUBST(have_preadv)
151 # Check if we have a pwritev2 libc call (Linux)
153 AC_DEFUN([AC_HAVE_PWRITEV2],
154 [ AC_MSG_CHECKING([for pwritev2])
159 pwritev2(0, 0, 0, 0, 0);
163 AC_SUBST(have_pwritev2)
167 # Check if we have a copy_file_range system call (Linux)
169 AC_DEFUN([AC_HAVE_COPY_FILE_RANGE],
170 [ AC_MSG_CHECKING([for copy_file_range])
173 #include <sys/syscall.h>
176 syscall(__NR_copy_file_range, 0, 0, 0, 0, 0, 0);
177 ], have_copy_file_range=yes
180 AC_SUBST(have_copy_file_range)
184 # Check if we have a sync_file_range libc call (Linux)
186 AC_DEFUN([AC_HAVE_SYNC_FILE_RANGE],
187 [ AC_MSG_CHECKING([for sync_file_range])
192 sync_file_range(0, 0, 0, 0);
193 ], have_sync_file_range=yes
196 AC_SUBST(have_sync_file_range)
200 # Check if we have a syncfs libc call (Linux)
202 AC_DEFUN([AC_HAVE_SYNCFS],
203 [ AC_MSG_CHECKING([for syncfs])
212 AC_SUBST(have_syncfs)
216 # Check if we have a readdir libc call
218 AC_DEFUN([AC_HAVE_READDIR],
219 [ AC_MSG_CHECKING([for readdir])
227 AC_SUBST(have_readdir)
231 # Check if we have a flc call (Mac OS X)
233 AC_DEFUN([AC_HAVE_FLS],
234 [ AC_CHECK_DECL([fls],
237 [#include <string.h>]
243 # Check if we have a fsetxattr call (Mac OS X)
245 AC_DEFUN([AC_HAVE_FSETXATTR],
246 [ AC_CHECK_DECL([fsetxattr],
249 [#include <sys/types.h>
250 #include <attr/xattr.h>]
252 AC_SUBST(have_fsetxattr)
256 # Check if there is mntent.h
258 AC_DEFUN([AC_HAVE_MNTENT],
259 [ AC_CHECK_HEADERS(mntent.h,
261 AC_SUBST(have_mntent)
265 # Check if we have a mremap call (not on Mac OS X)
267 AC_DEFUN([AC_HAVE_MREMAP],
268 [ AC_CHECK_DECL([mremap],
272 #include <sys/mman.h>]
274 AC_SUBST(have_mremap)
278 # Check if we need to override the system struct fsxattr with
279 # the internal definition. This /only/ happens if the system
280 # actually defines struct fsxattr /and/ the system definition
281 # is missing certain fields.
283 AC_DEFUN([AC_NEED_INTERNAL_FSXATTR],
285 AC_CHECK_TYPE(struct fsxattr,
287 AC_CHECK_MEMBER(struct fsxattr.fsx_cowextsize,
289 need_internal_fsxattr=yes,
290 [#include <linux/fs.h>]
293 [#include <linux/fs.h>]
295 AC_SUBST(need_internal_fsxattr)
299 # Check if we have a FS_IOC_GETFSMAP ioctl (Linux)
301 AC_DEFUN([AC_HAVE_GETFSMAP],
302 [ AC_MSG_CHECKING([for GETFSMAP])
305 #include <sys/syscall.h>
307 #include <linux/fs.h>
308 #include <linux/fsmap.h>
310 unsigned long x = FS_IOC_GETFSMAP;
311 struct fsmap_head fh;
315 AC_SUBST(have_getfsmap)
318 AC_DEFUN([AC_HAVE_STATFS_FLAGS],
320 AC_CHECK_TYPE(struct statfs,
322 AC_CHECK_MEMBER(struct statfs.f_flags,
323 have_statfs_flags=yes,,
324 [#include <sys/vfs.h>]
327 [#include <sys/vfs.h>]
329 AC_SUBST(have_statfs_flags)
333 # Check if we have MAP_SYNC defines (Linux)
335 AC_DEFUN([AC_HAVE_MAP_SYNC],
336 [ AC_MSG_CHECKING([for MAP_SYNC])
338 #include <asm-generic/mman.h>
339 #include <asm-generic/mman-common.h>
341 int flags = MAP_SYNC | MAP_SHARED_VALIDATE;
345 AC_SUBST(have_map_sync)
349 # Check if we have a mallinfo libc call
351 AC_DEFUN([AC_HAVE_MALLINFO],
352 [ AC_MSG_CHECKING([for mallinfo ])
356 struct mallinfo test;
358 test.arena = 0; test.hblkhd = 0; test.uordblks = 0; test.fordblks = 0;
363 AC_SUBST(have_mallinfo)
367 # Check if we have a openat call
369 AC_DEFUN([AC_HAVE_OPENAT],
370 [ AC_CHECK_DECL([openat],
373 [#include <sys/types.h>
374 #include <sys/stat.h>
377 AC_SUBST(have_openat)
381 # Check if we have a fstatat call
383 AC_DEFUN([AC_HAVE_FSTATAT],
384 [ AC_CHECK_DECL([fstatat],
388 #include <sys/types.h>
389 #include <sys/stat.h>
390 #include <unistd.h>])
391 AC_SUBST(have_fstatat)
395 # Check if we have the SG_IO ioctl
397 AC_DEFUN([AC_HAVE_SG_IO],
398 [ AC_MSG_CHECKING([for struct sg_io_hdr ])
399 AC_TRY_COMPILE([#include <scsi/sg.h>],
401 struct sg_io_hdr hdr;
402 ioctl(0, SG_IO, &hdr);
410 # Check if we have the HDIO_GETGEO ioctl
412 AC_DEFUN([AC_HAVE_HDIO_GETGEO],
413 [ AC_MSG_CHECKING([for struct hd_geometry ])
414 AC_TRY_COMPILE([#include <linux/hdreg.h>],
416 struct hd_geometry hdr;
417 ioctl(0, HDIO_GETGEO, &hdr);
418 ], have_hdio_getgeo=yes
421 AC_SUBST(have_hdio_getgeo)
424 AC_DEFUN([AC_PACKAGE_CHECK_LTO],
425 [ AC_MSG_CHECKING([if C compiler supports LTO])
427 OLD_LDFLAGS="$LDFLAGS"
428 LTO_FLAGS="-flto -ffat-lto-objects"
429 CFLAGS="$CFLAGS $LTO_FLAGS"
430 LDFLAGS="$LDFLAGS $LTO_FLAGS"
431 AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
432 [AC_MSG_RESULT([yes])]
433 [lto_cflags=$LTO_FLAGS]
434 [lto_ldflags=$LTO_FLAGS]
435 [AC_PATH_PROG(gcc_ar, gcc-ar,,)]
436 [AC_PATH_PROG(gcc_ranlib, gcc-ranlib,,)],
437 [AC_MSG_RESULT([no])])
438 if test -x "$gcc_ar" && test -x "$gcc_ranlib"; then
441 CFLAGS="${OLD_CFLAGS}"
442 LDFLAGS="${OLD_LDFLAGS}"
447 AC_SUBST(lto_ldflags)
450 AC_DEFUN([AC_PACKAGE_CHECK_RETPOLINE],
451 [ AC_MSG_CHECKING([if C compiler supports retpoline])
453 OLD_LDFLAGS="$LDFLAGS"
454 RETPOLINE_FLAGS="-mindirect-branch=thunk"
455 CFLAGS="$CFLAGS $RETPOLINE_FLAGS"
456 LDFLAGS="$LDFLAGS $RETPOLINE_FLAGS"
457 AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
458 [AC_MSG_RESULT([yes])]
459 [retpoline_cflags=$RETPOLINE_FLAGS]
460 [retpoline_ldflags=$RETPOLINE_FLAGS],
461 [AC_MSG_RESULT([no])])
462 if test -n "$retpoline_cflags"; then
465 CFLAGS="${OLD_CFLAGS}"
466 LDFLAGS="${OLD_LDFLAGS}"
467 AC_SUBST(have_retpoline)
468 AC_SUBST(retpoline_cflags)
469 AC_SUBST(retpoline_ldflags)