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 syncfs libc call (Linux)
60 AC_DEFUN([AC_HAVE_SYNCFS],
61 [ AC_MSG_CHECKING([for syncfs])
76 # Check if we have a fsetxattr call
78 AC_DEFUN([AC_HAVE_FSETXATTR],
79 [ AC_CHECK_DECL([fsetxattr],
82 [#include <sys/types.h>
83 #include <sys/xattr.h>]
85 AC_SUBST(have_fsetxattr)
89 # Check if we have a mremap call (not on Mac OS X)
91 AC_DEFUN([AC_HAVE_MREMAP],
92 [ AC_CHECK_DECL([mremap],
96 #include <sys/mman.h>]
102 # Check if we need to override the system struct fsxattr with
103 # the internal definition. This /only/ happens if the system
104 # actually defines struct fsxattr /and/ the system definition
105 # is missing certain fields.
107 AC_DEFUN([AC_NEED_INTERNAL_FSXATTR],
109 AC_CHECK_TYPE(struct fsxattr,
111 AC_CHECK_MEMBER(struct fsxattr.fsx_cowextsize,
113 need_internal_fsxattr=yes,
114 [#include <linux/fs.h>]
117 [#include <linux/fs.h>]
119 AC_SUBST(need_internal_fsxattr)
123 # Check if we need to override the system struct fscrypt_add_key_arg
124 # with the internal definition. This /only/ happens if the system
125 # actually defines struct fscrypt_add_key_arg /and/ the system
126 # definition is missing certain fields.
128 AC_DEFUN([AC_NEED_INTERNAL_FSCRYPT_ADD_KEY_ARG],
130 AC_CHECK_TYPE(struct fscrypt_add_key_arg,
132 AC_CHECK_MEMBER(struct fscrypt_add_key_arg.key_id,
134 need_internal_fscrypt_add_key_arg=yes,
135 [#include <linux/fs.h>]
138 [#include <linux/fs.h>]
140 AC_SUBST(need_internal_fscrypt_add_key_arg)
144 # Check if we need to override the system struct fscrypt_policy_v2
145 # with the internal definition. This /only/ happens if the system
146 # actually defines struct fscrypt_policy_v2 /and/ the system
147 # definition is missing certain fields.
149 AC_DEFUN([AC_NEED_INTERNAL_FSCRYPT_POLICY_V2],
151 AC_CHECK_TYPE(struct fscrypt_policy_v2,
153 AC_CHECK_MEMBER(struct fscrypt_policy_v2.log2_data_unit_size,
155 need_internal_fscrypt_policy_v2=yes,
156 [#include <linux/fs.h>]
159 [#include <linux/fs.h>]
161 AC_SUBST(need_internal_fscrypt_policy_v2)
165 # Check if we have a FS_IOC_GETFSMAP ioctl (Linux)
167 AC_DEFUN([AC_HAVE_GETFSMAP],
168 [ AC_MSG_CHECKING([for GETFSMAP])
172 #include <sys/syscall.h>
174 #include <linux/fs.h>
175 #include <linux/fsmap.h>
177 unsigned long x = FS_IOC_GETFSMAP;
178 struct fsmap_head fh;
183 AC_SUBST(have_getfsmap)
186 AC_DEFUN([AC_HAVE_STATFS_FLAGS],
188 AC_CHECK_TYPE(struct statfs,
190 AC_CHECK_MEMBER(struct statfs.f_flags,
191 have_statfs_flags=yes,,
192 [#include <sys/vfs.h>]
195 [#include <sys/vfs.h>]
197 AC_SUBST(have_statfs_flags)
201 # Check if we have MAP_SYNC defines (Linux)
203 AC_DEFUN([AC_HAVE_MAP_SYNC],
204 [ AC_MSG_CHECKING([for MAP_SYNC])
207 #include <sys/mman.h>
209 int flags = MAP_SYNC | MAP_SHARED_VALIDATE;
214 AC_SUBST(have_map_sync)
218 # Check if we have a mallinfo libc call
220 AC_DEFUN([AC_HAVE_MALLINFO],
221 [ AC_MSG_CHECKING([for mallinfo ])
226 struct mallinfo test;
228 test.arena = 0; test.hblkhd = 0; test.uordblks = 0; test.fordblks = 0;
234 AC_SUBST(have_mallinfo)
238 # Check if we have a mallinfo2 libc call
240 AC_DEFUN([AC_HAVE_MALLINFO2],
241 [ AC_MSG_CHECKING([for mallinfo2 ])
246 struct mallinfo2 test;
248 test.arena = 0; test.hblkhd = 0; test.uordblks = 0; test.fordblks = 0;
251 ], have_mallinfo2=yes
254 AC_SUBST(have_mallinfo2)
258 # Check if we have a openat call
260 AC_DEFUN([AC_HAVE_OPENAT],
261 [ AC_CHECK_DECL([openat],
264 [#include <sys/types.h>
265 #include <sys/stat.h>
268 AC_SUBST(have_openat)
272 # Check if we have a fstatat call
274 AC_DEFUN([AC_HAVE_FSTATAT],
275 [ AC_CHECK_DECL([fstatat],
279 #include <sys/types.h>
280 #include <sys/stat.h>
281 #include <unistd.h>])
282 AC_SUBST(have_fstatat)
286 # Check if we have the SG_IO ioctl
288 AC_DEFUN([AC_HAVE_SG_IO],
289 [ AC_MSG_CHECKING([for struct sg_io_hdr ])
293 #include <sys/ioctl.h>
295 struct sg_io_hdr hdr;
296 ioctl(0, SG_IO, &hdr);
305 # Check if we have the HDIO_GETGEO ioctl
307 AC_DEFUN([AC_HAVE_HDIO_GETGEO],
308 [ AC_MSG_CHECKING([for struct hd_geometry ])
311 #include <linux/hdreg.h>
312 #include <sys/ioctl.h>
314 struct hd_geometry hdr;
315 ioctl(0, HDIO_GETGEO, &hdr);
317 ], have_hdio_getgeo=yes
320 AC_SUBST(have_hdio_getgeo)
323 AC_DEFUN([AC_PACKAGE_CHECK_LTO],
324 [ AC_MSG_CHECKING([if C compiler supports LTO])
326 OLD_LDFLAGS="$LDFLAGS"
327 LTO_FLAGS="-flto -ffat-lto-objects"
328 CFLAGS="$CFLAGS $LTO_FLAGS"
329 LDFLAGS="$LDFLAGS $LTO_FLAGS"
330 AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
331 [AC_MSG_RESULT([yes])]
332 [lto_cflags=$LTO_FLAGS]
333 [lto_ldflags=$LTO_FLAGS]
334 [AC_PATH_PROG(gcc_ar, gcc-ar,,)]
335 [AC_PATH_PROG(gcc_ranlib, gcc-ranlib,,)],
336 [AC_MSG_RESULT([no])])
337 if test -x "$gcc_ar" && test -x "$gcc_ranlib"; then
340 CFLAGS="${OLD_CFLAGS}"
341 LDFLAGS="${OLD_LDFLAGS}"
346 AC_SUBST(lto_ldflags)