]>
Commit | Line | Data |
---|---|---|
c5deeac9 GR |
1 | # |
2 | # Check if we have a pwritev2 libc call (Linux) | |
3 | # | |
4 | AC_DEFUN([AC_HAVE_PWRITEV2], | |
5 | [ AC_MSG_CHECKING([for pwritev2]) | |
69d66277 DC |
6 | AC_LINK_IFELSE( |
7 | [ AC_LANG_PROGRAM([[ | |
d6642ab8 | 8 | #define _GNU_SOURCE |
c5deeac9 | 9 | #include <sys/uio.h> |
69d66277 DC |
10 | ]], [[ |
11 | pwritev2(0, 0, 0, 0, 0); | |
12 | ]]) | |
c5deeac9 GR |
13 | ], have_pwritev2=yes |
14 | AC_MSG_RESULT(yes), | |
15 | AC_MSG_RESULT(no)) | |
16 | AC_SUBST(have_pwritev2) | |
17 | ]) | |
18 | ||
628e112a AS |
19 | # |
20 | # Check if we have a copy_file_range system call (Linux) | |
21 | # | |
22 | AC_DEFUN([AC_HAVE_COPY_FILE_RANGE], | |
23 | [ AC_MSG_CHECKING([for copy_file_range]) | |
69d66277 DC |
24 | AC_LINK_IFELSE( |
25 | [ AC_LANG_PROGRAM([[ | |
628e112a AS |
26 | #define _GNU_SOURCE |
27 | #include <sys/syscall.h> | |
28 | #include <unistd.h> | |
69d66277 DC |
29 | ]], [[ |
30 | syscall(__NR_copy_file_range, 0, 0, 0, 0, 0, 0); | |
31 | ]]) | |
628e112a AS |
32 | ], have_copy_file_range=yes |
33 | AC_MSG_RESULT(yes), | |
34 | AC_MSG_RESULT(no)) | |
35 | AC_SUBST(have_copy_file_range) | |
36 | ]) | |
37 | ||
c14c7b79 | 38 | # |
f5629402 | 39 | # Check if we have a fsetxattr call |
c14c7b79 JT |
40 | # |
41 | AC_DEFUN([AC_HAVE_FSETXATTR], | |
42 | [ AC_CHECK_DECL([fsetxattr], | |
43 | have_fsetxattr=yes, | |
44 | [], | |
45 | [#include <sys/types.h> | |
f5629402 | 46 | #include <sys/xattr.h>] |
c14c7b79 JT |
47 | ) |
48 | AC_SUBST(have_fsetxattr) | |
49 | ]) | |
50 | ||
a49984b3 JT |
51 | # |
52 | # Check if we have a mremap call (not on Mac OS X) | |
53 | # | |
54 | AC_DEFUN([AC_HAVE_MREMAP], | |
55 | [ AC_CHECK_DECL([mremap], | |
56 | have_mremap=yes, | |
57 | [], | |
58 | [#define _GNU_SOURCE | |
59 | #include <sys/mman.h>] | |
60 | ) | |
61 | AC_SUBST(have_mremap) | |
62 | ]) | |
6529e656 DW |
63 | |
64 | # | |
65 | # Check if we need to override the system struct fsxattr with | |
66 | # the internal definition. This /only/ happens if the system | |
67 | # actually defines struct fsxattr /and/ the system definition | |
68 | # is missing certain fields. | |
69 | # | |
70 | AC_DEFUN([AC_NEED_INTERNAL_FSXATTR], | |
71 | [ | |
1e51132f DW |
72 | AC_CHECK_TYPE(struct fsxattr, |
73 | [ | |
74 | AC_CHECK_MEMBER(struct fsxattr.fsx_cowextsize, | |
75 | , | |
76 | need_internal_fsxattr=yes, | |
77 | [#include <linux/fs.h>] | |
78 | ) | |
79 | ],, | |
80 | [#include <linux/fs.h>] | |
81 | ) | |
6529e656 DW |
82 | AC_SUBST(need_internal_fsxattr) |
83 | ]) | |
71956d72 | 84 | |
dfe209d8 EB |
85 | # |
86 | # Check if we need to override the system struct fscrypt_add_key_arg | |
87 | # with the internal definition. This /only/ happens if the system | |
88 | # actually defines struct fscrypt_add_key_arg /and/ the system | |
89 | # definition is missing certain fields. | |
90 | # | |
91 | AC_DEFUN([AC_NEED_INTERNAL_FSCRYPT_ADD_KEY_ARG], | |
92 | [ | |
93 | AC_CHECK_TYPE(struct fscrypt_add_key_arg, | |
94 | [ | |
95 | AC_CHECK_MEMBER(struct fscrypt_add_key_arg.key_id, | |
96 | , | |
97 | need_internal_fscrypt_add_key_arg=yes, | |
98 | [#include <linux/fs.h>] | |
99 | ) | |
100 | ],, | |
101 | [#include <linux/fs.h>] | |
102 | ) | |
103 | AC_SUBST(need_internal_fscrypt_add_key_arg) | |
104 | ]) | |
105 | ||
e97caf71 EB |
106 | # |
107 | # Check if we need to override the system struct fscrypt_policy_v2 | |
108 | # with the internal definition. This /only/ happens if the system | |
109 | # actually defines struct fscrypt_policy_v2 /and/ the system | |
110 | # definition is missing certain fields. | |
111 | # | |
112 | AC_DEFUN([AC_NEED_INTERNAL_FSCRYPT_POLICY_V2], | |
113 | [ | |
114 | AC_CHECK_TYPE(struct fscrypt_policy_v2, | |
115 | [ | |
116 | AC_CHECK_MEMBER(struct fscrypt_policy_v2.log2_data_unit_size, | |
117 | , | |
118 | need_internal_fscrypt_policy_v2=yes, | |
119 | [#include <linux/fs.h>] | |
120 | ) | |
121 | ],, | |
122 | [#include <linux/fs.h>] | |
123 | ) | |
124 | AC_SUBST(need_internal_fscrypt_policy_v2) | |
125 | ]) | |
126 | ||
71956d72 DW |
127 | # |
128 | # Check if we have a FS_IOC_GETFSMAP ioctl (Linux) | |
129 | # | |
130 | AC_DEFUN([AC_HAVE_GETFSMAP], | |
131 | [ AC_MSG_CHECKING([for GETFSMAP]) | |
69d66277 DC |
132 | AC_LINK_IFELSE( |
133 | [ AC_LANG_PROGRAM([[ | |
71956d72 DW |
134 | #define _GNU_SOURCE |
135 | #include <sys/syscall.h> | |
136 | #include <unistd.h> | |
137 | #include <linux/fs.h> | |
138 | #include <linux/fsmap.h> | |
69d66277 DC |
139 | ]], [[ |
140 | unsigned long x = FS_IOC_GETFSMAP; | |
141 | struct fsmap_head fh; | |
142 | ]]) | |
71956d72 DW |
143 | ], have_getfsmap=yes |
144 | AC_MSG_RESULT(yes), | |
145 | AC_MSG_RESULT(no)) | |
146 | AC_SUBST(have_getfsmap) | |
147 | ]) | |
ce9adab0 JM |
148 | |
149 | AC_DEFUN([AC_HAVE_STATFS_FLAGS], | |
150 | [ | |
151 | AC_CHECK_TYPE(struct statfs, | |
152 | [ | |
153 | AC_CHECK_MEMBER(struct statfs.f_flags, | |
154 | have_statfs_flags=yes,, | |
155 | [#include <sys/vfs.h>] | |
156 | ) | |
157 | ],, | |
158 | [#include <sys/vfs.h>] | |
159 | ) | |
160 | AC_SUBST(have_statfs_flags) | |
161 | ]) | |
dad79683 RZ |
162 | |
163 | # | |
164 | # Check if we have MAP_SYNC defines (Linux) | |
165 | # | |
166 | AC_DEFUN([AC_HAVE_MAP_SYNC], | |
167 | [ AC_MSG_CHECKING([for MAP_SYNC]) | |
69d66277 DC |
168 | AC_COMPILE_IFELSE( |
169 | [ AC_LANG_PROGRAM([[ | |
28965957 | 170 | #include <sys/mman.h> |
69d66277 DC |
171 | ]], [[ |
172 | int flags = MAP_SYNC | MAP_SHARED_VALIDATE; | |
173 | ]]) | |
dad79683 RZ |
174 | ], have_map_sync=yes |
175 | AC_MSG_RESULT(yes), | |
176 | AC_MSG_RESULT(no)) | |
177 | AC_SUBST(have_map_sync) | |
178 | ]) | |
173a0283 DW |
179 | |
180 | # | |
181 | # Check if we have a mallinfo libc call | |
182 | # | |
183 | AC_DEFUN([AC_HAVE_MALLINFO], | |
184 | [ AC_MSG_CHECKING([for mallinfo ]) | |
69d66277 DC |
185 | AC_COMPILE_IFELSE( |
186 | [ AC_LANG_PROGRAM([[ | |
173a0283 | 187 | #include <malloc.h> |
69d66277 DC |
188 | ]], [[ |
189 | struct mallinfo test; | |
173a0283 | 190 | |
69d66277 DC |
191 | test.arena = 0; test.hblkhd = 0; test.uordblks = 0; test.fordblks = 0; |
192 | test = mallinfo(); | |
193 | ]]) | |
173a0283 DW |
194 | ], have_mallinfo=yes |
195 | AC_MSG_RESULT(yes), | |
196 | AC_MSG_RESULT(no)) | |
197 | AC_SUBST(have_mallinfo) | |
198 | ]) | |
b364a9c0 | 199 | |
c74f0468 DW |
200 | # |
201 | # Check if we have a mallinfo2 libc call | |
202 | # | |
203 | AC_DEFUN([AC_HAVE_MALLINFO2], | |
204 | [ AC_MSG_CHECKING([for mallinfo2 ]) | |
1a35c8df DW |
205 | AC_COMPILE_IFELSE( |
206 | [ AC_LANG_PROGRAM([[ | |
c74f0468 | 207 | #include <malloc.h> |
1a35c8df DW |
208 | ]], [[ |
209 | struct mallinfo2 test; | |
c74f0468 | 210 | |
1a35c8df DW |
211 | test.arena = 0; test.hblkhd = 0; test.uordblks = 0; test.fordblks = 0; |
212 | test = mallinfo2(); | |
213 | ]]) | |
c74f0468 DW |
214 | ], have_mallinfo2=yes |
215 | AC_MSG_RESULT(yes), | |
216 | AC_MSG_RESULT(no)) | |
217 | AC_SUBST(have_mallinfo2) | |
218 | ]) | |
219 | ||
b364a9c0 DW |
220 | # |
221 | # Check if we have a openat call | |
222 | # | |
223 | AC_DEFUN([AC_HAVE_OPENAT], | |
224 | [ AC_CHECK_DECL([openat], | |
225 | have_openat=yes, | |
226 | [], | |
227 | [#include <sys/types.h> | |
228 | #include <sys/stat.h> | |
229 | #include <fcntl.h>] | |
230 | ) | |
231 | AC_SUBST(have_openat) | |
232 | ]) | |
233 | ||
234 | # | |
235 | # Check if we have a fstatat call | |
236 | # | |
237 | AC_DEFUN([AC_HAVE_FSTATAT], | |
238 | [ AC_CHECK_DECL([fstatat], | |
239 | have_fstatat=yes, | |
240 | [], | |
241 | [#define _GNU_SOURCE | |
242 | #include <sys/types.h> | |
243 | #include <sys/stat.h> | |
244 | #include <unistd.h>]) | |
245 | AC_SUBST(have_fstatat) | |
246 | ]) | |
03c0cd8f DW |
247 | |
248 | # | |
249 | # Check if we have the SG_IO ioctl | |
250 | # | |
251 | AC_DEFUN([AC_HAVE_SG_IO], | |
252 | [ AC_MSG_CHECKING([for struct sg_io_hdr ]) | |
69d66277 DC |
253 | AC_COMPILE_IFELSE( |
254 | [ AC_LANG_PROGRAM([[ | |
255 | #include <scsi/sg.h> | |
d6642ab8 | 256 | #include <sys/ioctl.h> |
69d66277 DC |
257 | ]], [[ |
258 | struct sg_io_hdr hdr; | |
259 | ioctl(0, SG_IO, &hdr); | |
260 | ]]) | |
03c0cd8f DW |
261 | ], have_sg_io=yes |
262 | AC_MSG_RESULT(yes), | |
263 | AC_MSG_RESULT(no)) | |
264 | AC_SUBST(have_sg_io) | |
265 | ]) | |
266 | ||
267 | # | |
268 | # Check if we have the HDIO_GETGEO ioctl | |
269 | # | |
270 | AC_DEFUN([AC_HAVE_HDIO_GETGEO], | |
271 | [ AC_MSG_CHECKING([for struct hd_geometry ]) | |
69d66277 DC |
272 | AC_COMPILE_IFELSE( |
273 | [ AC_LANG_PROGRAM([[ | |
d6642ab8 AS |
274 | #include <linux/hdreg.h> |
275 | #include <sys/ioctl.h> | |
69d66277 DC |
276 | ]], [[ |
277 | struct hd_geometry hdr; | |
278 | ioctl(0, HDIO_GETGEO, &hdr); | |
279 | ]]) | |
03c0cd8f DW |
280 | ], have_hdio_getgeo=yes |
281 | AC_MSG_RESULT(yes), | |
282 | AC_MSG_RESULT(no)) | |
283 | AC_SUBST(have_hdio_getgeo) | |
284 | ]) | |
1b0adc71 | 285 | |
e61f1552 DW |
286 | AC_DEFUN([AC_PACKAGE_CHECK_LTO], |
287 | [ AC_MSG_CHECKING([if C compiler supports LTO]) | |
288 | OLD_CFLAGS="$CFLAGS" | |
289 | OLD_LDFLAGS="$LDFLAGS" | |
290 | LTO_FLAGS="-flto -ffat-lto-objects" | |
291 | CFLAGS="$CFLAGS $LTO_FLAGS" | |
292 | LDFLAGS="$LDFLAGS $LTO_FLAGS" | |
293 | AC_LINK_IFELSE([AC_LANG_PROGRAM([])], | |
294 | [AC_MSG_RESULT([yes])] | |
295 | [lto_cflags=$LTO_FLAGS] | |
296 | [lto_ldflags=$LTO_FLAGS] | |
297 | [AC_PATH_PROG(gcc_ar, gcc-ar,,)] | |
298 | [AC_PATH_PROG(gcc_ranlib, gcc-ranlib,,)], | |
299 | [AC_MSG_RESULT([no])]) | |
300 | if test -x "$gcc_ar" && test -x "$gcc_ranlib"; then | |
301 | have_lto=yes | |
302 | fi | |
303 | CFLAGS="${OLD_CFLAGS}" | |
304 | LDFLAGS="${OLD_LDFLAGS}" | |
305 | AC_SUBST(gcc_ar) | |
306 | AC_SUBST(gcc_ranlib) | |
307 | AC_SUBST(have_lto) | |
308 | AC_SUBST(lto_cflags) | |
309 | AC_SUBST(lto_ldflags) | |
310 | ]) |