2 # Check if we have a preadv libc call (Linux)
4 AC_DEFUN([AC_HAVE_PREADV],
5 [ AC_MSG_CHECKING([for preadv])
9 #define _DEFAULT_SOURCE
21 # Check if we have a pwritev2 libc call (Linux)
23 AC_DEFUN([AC_HAVE_PWRITEV2],
24 [ AC_MSG_CHECKING([for pwritev2])
30 pwritev2(0, 0, 0, 0, 0);
35 AC_SUBST(have_pwritev2)
39 # Check if we have a copy_file_range system call (Linux)
41 AC_DEFUN([AC_HAVE_COPY_FILE_RANGE],
42 [ AC_MSG_CHECKING([for copy_file_range])
46 #include <sys/syscall.h>
49 syscall(__NR_copy_file_range, 0, 0, 0, 0, 0, 0);
51 ], have_copy_file_range=yes
54 AC_SUBST(have_copy_file_range)
58 # Check if we have a fsetxattr call
60 AC_DEFUN([AC_HAVE_FSETXATTR],
61 [ AC_CHECK_DECL([fsetxattr],
64 [#include <sys/types.h>
65 #include <sys/xattr.h>]
67 AC_SUBST(have_fsetxattr)
71 # Check if we have a mremap call (not on Mac OS X)
73 AC_DEFUN([AC_HAVE_MREMAP],
74 [ AC_CHECK_DECL([mremap],
78 #include <sys/mman.h>]
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.
89 AC_DEFUN([AC_NEED_INTERNAL_FSXATTR],
91 AC_CHECK_TYPE(struct fsxattr,
93 AC_CHECK_MEMBER(struct fsxattr.fsx_cowextsize,
95 need_internal_fsxattr=yes,
96 [#include <linux/fs.h>]
99 [#include <linux/fs.h>]
101 AC_SUBST(need_internal_fsxattr)
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.
110 AC_DEFUN([AC_NEED_INTERNAL_FSCRYPT_ADD_KEY_ARG],
112 AC_CHECK_TYPE(struct fscrypt_add_key_arg,
114 AC_CHECK_MEMBER(struct fscrypt_add_key_arg.key_id,
116 need_internal_fscrypt_add_key_arg=yes,
117 [#include <linux/fs.h>]
120 [#include <linux/fs.h>]
122 AC_SUBST(need_internal_fscrypt_add_key_arg)
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.
131 AC_DEFUN([AC_NEED_INTERNAL_FSCRYPT_POLICY_V2],
133 AC_CHECK_TYPE(struct fscrypt_policy_v2,
135 AC_CHECK_MEMBER(struct fscrypt_policy_v2.log2_data_unit_size,
137 need_internal_fscrypt_policy_v2=yes,
138 [#include <linux/fs.h>]
141 [#include <linux/fs.h>]
143 AC_SUBST(need_internal_fscrypt_policy_v2)
147 # Check if we have a FS_IOC_GETFSMAP ioctl (Linux)
149 AC_DEFUN([AC_HAVE_GETFSMAP],
150 [ AC_MSG_CHECKING([for GETFSMAP])
154 #include <sys/syscall.h>
156 #include <linux/fs.h>
157 #include <linux/fsmap.h>
159 unsigned long x = FS_IOC_GETFSMAP;
160 struct fsmap_head fh;
165 AC_SUBST(have_getfsmap)
168 AC_DEFUN([AC_HAVE_STATFS_FLAGS],
170 AC_CHECK_TYPE(struct statfs,
172 AC_CHECK_MEMBER(struct statfs.f_flags,
173 have_statfs_flags=yes,,
174 [#include <sys/vfs.h>]
177 [#include <sys/vfs.h>]
179 AC_SUBST(have_statfs_flags)
183 # Check if we have MAP_SYNC defines (Linux)
185 AC_DEFUN([AC_HAVE_MAP_SYNC],
186 [ AC_MSG_CHECKING([for MAP_SYNC])
189 #include <sys/mman.h>
191 int flags = MAP_SYNC | MAP_SHARED_VALIDATE;
196 AC_SUBST(have_map_sync)
200 # Check if we have a mallinfo libc call
202 AC_DEFUN([AC_HAVE_MALLINFO],
203 [ AC_MSG_CHECKING([for mallinfo ])
208 struct mallinfo test;
210 test.arena = 0; test.hblkhd = 0; test.uordblks = 0; test.fordblks = 0;
216 AC_SUBST(have_mallinfo)
220 # Check if we have a mallinfo2 libc call
222 AC_DEFUN([AC_HAVE_MALLINFO2],
223 [ AC_MSG_CHECKING([for mallinfo2 ])
228 struct mallinfo2 test;
230 test.arena = 0; test.hblkhd = 0; test.uordblks = 0; test.fordblks = 0;
233 ], have_mallinfo2=yes
236 AC_SUBST(have_mallinfo2)
240 # Check if we have a openat call
242 AC_DEFUN([AC_HAVE_OPENAT],
243 [ AC_CHECK_DECL([openat],
246 [#include <sys/types.h>
247 #include <sys/stat.h>
250 AC_SUBST(have_openat)
254 # Check if we have a fstatat call
256 AC_DEFUN([AC_HAVE_FSTATAT],
257 [ AC_CHECK_DECL([fstatat],
261 #include <sys/types.h>
262 #include <sys/stat.h>
263 #include <unistd.h>])
264 AC_SUBST(have_fstatat)
268 # Check if we have the SG_IO ioctl
270 AC_DEFUN([AC_HAVE_SG_IO],
271 [ AC_MSG_CHECKING([for struct sg_io_hdr ])
275 #include <sys/ioctl.h>
277 struct sg_io_hdr hdr;
278 ioctl(0, SG_IO, &hdr);
287 # Check if we have the HDIO_GETGEO ioctl
289 AC_DEFUN([AC_HAVE_HDIO_GETGEO],
290 [ AC_MSG_CHECKING([for struct hd_geometry ])
293 #include <linux/hdreg.h>
294 #include <sys/ioctl.h>
296 struct hd_geometry hdr;
297 ioctl(0, HDIO_GETGEO, &hdr);
299 ], have_hdio_getgeo=yes
302 AC_SUBST(have_hdio_getgeo)
305 AC_DEFUN([AC_PACKAGE_CHECK_LTO],
306 [ AC_MSG_CHECKING([if C compiler supports LTO])
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
322 CFLAGS="${OLD_CFLAGS}"
323 LDFLAGS="${OLD_LDFLAGS}"
328 AC_SUBST(lto_ldflags)