2 # Check if we have a pwritev2 libc call (Linux)
4 AC_DEFUN([AC_HAVE_PWRITEV2],
5 [ AC_MSG_CHECKING([for pwritev2])
11 pwritev2(0, 0, 0, 0, 0);
16 AC_SUBST(have_pwritev2)
20 # Check if we have a copy_file_range system call (Linux)
22 AC_DEFUN([AC_HAVE_COPY_FILE_RANGE],
23 [ AC_MSG_CHECKING([for copy_file_range])
27 #include <sys/syscall.h>
30 syscall(__NR_copy_file_range, 0, 0, 0, 0, 0, 0);
32 ], have_copy_file_range=yes
35 AC_SUBST(have_copy_file_range)
39 # Check if we need to override the system struct fsxattr with
40 # the internal definition. This /only/ happens if the system
41 # actually defines struct fsxattr /and/ the system definition
42 # is missing certain fields.
44 AC_DEFUN([AC_NEED_INTERNAL_FSXATTR],
46 AC_CHECK_TYPE(struct fsxattr,
48 AC_CHECK_MEMBER(struct fsxattr.fsx_cowextsize,
50 need_internal_fsxattr=yes,
51 [#include <linux/fs.h>]
54 [#include <linux/fs.h>]
56 AC_SUBST(need_internal_fsxattr)
60 # Check if we need to override the system struct fscrypt_add_key_arg
61 # with the internal definition. This /only/ happens if the system
62 # actually defines struct fscrypt_add_key_arg /and/ the system
63 # definition is missing certain fields.
65 AC_DEFUN([AC_NEED_INTERNAL_FSCRYPT_ADD_KEY_ARG],
67 AC_CHECK_TYPE(struct fscrypt_add_key_arg,
69 AC_CHECK_MEMBER(struct fscrypt_add_key_arg.key_id,
71 need_internal_fscrypt_add_key_arg=yes,
72 [#include <linux/fs.h>]
75 [#include <linux/fs.h>]
77 AC_SUBST(need_internal_fscrypt_add_key_arg)
81 # Check if we need to override the system struct fscrypt_policy_v2
82 # with the internal definition. This /only/ happens if the system
83 # actually defines struct fscrypt_policy_v2 /and/ the system
84 # definition is missing certain fields.
86 AC_DEFUN([AC_NEED_INTERNAL_FSCRYPT_POLICY_V2],
88 AC_CHECK_TYPE(struct fscrypt_policy_v2,
90 AC_CHECK_MEMBER(struct fscrypt_policy_v2.log2_data_unit_size,
92 need_internal_fscrypt_policy_v2=yes,
93 [#include <linux/fs.h>]
96 [#include <linux/fs.h>]
98 AC_SUBST(need_internal_fscrypt_policy_v2)
102 # Check if we have a FS_IOC_GETFSMAP ioctl (Linux)
104 AC_DEFUN([AC_HAVE_GETFSMAP],
105 [ AC_MSG_CHECKING([for GETFSMAP])
109 #include <sys/syscall.h>
111 #include <linux/fs.h>
112 #include <linux/fsmap.h>
114 unsigned long x = FS_IOC_GETFSMAP;
115 struct fsmap_head fh;
120 AC_SUBST(have_getfsmap)
123 AC_DEFUN([AC_HAVE_STATFS_FLAGS],
125 AC_CHECK_TYPE(struct statfs,
127 AC_CHECK_MEMBER(struct statfs.f_flags,
128 have_statfs_flags=yes,,
129 [#include <sys/vfs.h>]
132 [#include <sys/vfs.h>]
134 AC_SUBST(have_statfs_flags)
138 # Check if we have MAP_SYNC defines (Linux)
140 AC_DEFUN([AC_HAVE_MAP_SYNC],
141 [ AC_MSG_CHECKING([for MAP_SYNC])
144 #include <sys/mman.h>
146 int flags = MAP_SYNC | MAP_SHARED_VALIDATE;
151 AC_SUBST(have_map_sync)
155 # Check if we have a mallinfo libc call
157 AC_DEFUN([AC_HAVE_MALLINFO],
158 [ AC_MSG_CHECKING([for mallinfo ])
163 struct mallinfo test;
165 test.arena = 0; test.hblkhd = 0; test.uordblks = 0; test.fordblks = 0;
171 AC_SUBST(have_mallinfo)
175 # Check if we have a mallinfo2 libc call
177 AC_DEFUN([AC_HAVE_MALLINFO2],
178 [ AC_MSG_CHECKING([for mallinfo2 ])
183 struct mallinfo2 test;
185 test.arena = 0; test.hblkhd = 0; test.uordblks = 0; test.fordblks = 0;
188 ], have_mallinfo2=yes
191 AC_SUBST(have_mallinfo2)
195 # Check if we have a openat call
197 AC_DEFUN([AC_HAVE_OPENAT],
198 [ AC_CHECK_DECL([openat],
201 [#include <sys/types.h>
202 #include <sys/stat.h>
205 AC_SUBST(have_openat)
209 # Check if we have a fstatat call
211 AC_DEFUN([AC_HAVE_FSTATAT],
212 [ AC_CHECK_DECL([fstatat],
216 #include <sys/types.h>
217 #include <sys/stat.h>
218 #include <unistd.h>])
219 AC_SUBST(have_fstatat)
223 # Check if we have the SG_IO ioctl
225 AC_DEFUN([AC_HAVE_SG_IO],
226 [ AC_MSG_CHECKING([for struct sg_io_hdr ])
230 #include <sys/ioctl.h>
232 struct sg_io_hdr hdr;
233 ioctl(0, SG_IO, &hdr);
242 # Check if we have the HDIO_GETGEO ioctl
244 AC_DEFUN([AC_HAVE_HDIO_GETGEO],
245 [ AC_MSG_CHECKING([for struct hd_geometry ])
248 #include <linux/hdreg.h>
249 #include <sys/ioctl.h>
251 struct hd_geometry hdr;
252 ioctl(0, HDIO_GETGEO, &hdr);
254 ], have_hdio_getgeo=yes
257 AC_SUBST(have_hdio_getgeo)
260 AC_DEFUN([AC_PACKAGE_CHECK_LTO],
261 [ AC_MSG_CHECKING([if C compiler supports LTO])
263 OLD_LDFLAGS="$LDFLAGS"
264 LTO_FLAGS="-flto -ffat-lto-objects"
265 CFLAGS="$CFLAGS $LTO_FLAGS"
266 LDFLAGS="$LDFLAGS $LTO_FLAGS"
267 AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
268 [AC_MSG_RESULT([yes])]
269 [lto_cflags=$LTO_FLAGS]
270 [lto_ldflags=$LTO_FLAGS]
271 [AC_PATH_PROG(gcc_ar, gcc-ar,,)]
272 [AC_PATH_PROG(gcc_ranlib, gcc-ranlib,,)],
273 [AC_MSG_RESULT([no])])
274 if test -x "$gcc_ar" && test -x "$gcc_ranlib"; then
277 CFLAGS="${OLD_CFLAGS}"
278 LDFLAGS="${OLD_LDFLAGS}"
283 AC_SUBST(lto_ldflags)