]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - m4/package_libcdev.m4
libxfs: clean up IRELE/iput callsites
[thirdparty/xfsprogs-dev.git] / m4 / package_libcdev.m4
CommitLineData
0bba1a49
NS
1#
2# Check if we have a working fadvise system call
f8149110 3#
0bba1a49
NS
4AC_DEFUN([AC_HAVE_FADVISE],
5 [ AC_MSG_CHECKING([for fadvise ])
6 AC_TRY_COMPILE([
7#define _GNU_SOURCE
0bba1a49
NS
8#include <fcntl.h>
9 ], [
38c187fe 10 posix_fadvise(0, 1, 0, POSIX_FADV_NORMAL);
0bba1a49
NS
11 ], have_fadvise=yes
12 AC_MSG_RESULT(yes),
13 AC_MSG_RESULT(no))
14 AC_SUBST(have_fadvise)
15 ])
16
f8149110 17#
0bba1a49 18# Check if we have a working madvise system call
f8149110 19#
0bba1a49
NS
20AC_DEFUN([AC_HAVE_MADVISE],
21 [ AC_MSG_CHECKING([for madvise ])
22 AC_TRY_COMPILE([
23#define _GNU_SOURCE
0bba1a49
NS
24#include <sys/mman.h>
25 ], [
26 posix_madvise(0, 0, MADV_NORMAL);
27 ], have_madvise=yes
28 AC_MSG_RESULT(yes),
29 AC_MSG_RESULT(no))
30 AC_SUBST(have_madvise)
31 ])
32
f8149110 33#
0bba1a49 34# Check if we have a working mincore system call
f8149110 35#
0bba1a49
NS
36AC_DEFUN([AC_HAVE_MINCORE],
37 [ AC_MSG_CHECKING([for mincore ])
38 AC_TRY_COMPILE([
39#define _GNU_SOURCE
0bba1a49
NS
40#include <sys/mman.h>
41 ], [
42 mincore(0, 0, 0);
43 ], have_mincore=yes
44 AC_MSG_RESULT(yes),
45 AC_MSG_RESULT(no))
46 AC_SUBST(have_mincore)
47 ])
48
f8149110 49#
0bba1a49 50# Check if we have a working sendfile system call
f8149110 51#
0bba1a49
NS
52AC_DEFUN([AC_HAVE_SENDFILE],
53 [ AC_MSG_CHECKING([for sendfile ])
54 AC_TRY_COMPILE([
55#define _GNU_SOURCE
0bba1a49
NS
56#include <sys/sendfile.h>
57 ], [
58 sendfile(0, 0, 0, 0);
59 ], have_sendfile=yes
60 AC_MSG_RESULT(yes),
61 AC_MSG_RESULT(no))
62 AC_SUBST(have_sendfile)
63 ])
cfe6e3f0
NS
64
65#
66# Check if we have a getmntent libc call (IRIX, Linux)
67#
68AC_DEFUN([AC_HAVE_GETMNTENT],
69 [ AC_MSG_CHECKING([for getmntent ])
70 AC_TRY_COMPILE([
71#include <stdio.h>
72#include <mntent.h>
73 ], [
74 getmntent(0);
75 ], have_getmntent=yes
76 AC_MSG_RESULT(yes),
77 AC_MSG_RESULT(no))
78 AC_SUBST(have_getmntent)
79 ])
80
81#
82# Check if we have a getmntinfo libc call (FreeBSD, Mac OS X)
83#
84AC_DEFUN([AC_HAVE_GETMNTINFO],
85 [ AC_MSG_CHECKING([for getmntinfo ])
86 AC_TRY_COMPILE([
87#include <sys/param.h>
88#include <sys/ucred.h>
89#include <sys/mount.h>
90 ], [
91 getmntinfo(0, 0);
92 ], have_getmntinfo=yes
93 AC_MSG_RESULT(yes),
94 AC_MSG_RESULT(no))
95 AC_SUBST(have_getmntinfo)
96 ])
c0b5232a
ES
97
98#
99# Check if we have a fallocate libc call (Linux)
100#
101AC_DEFUN([AC_HAVE_FALLOCATE],
102 [ AC_MSG_CHECKING([for fallocate])
103 AC_TRY_LINK([
c17c73e2 104#define _GNU_SOURCE
c17c73e2 105#include <fcntl.h>
c0b5232a
ES
106#include <linux/falloc.h>
107 ], [
108 fallocate(0, 0, 0, 0);
109 ], have_fallocate=yes
110 AC_MSG_RESULT(yes),
111 AC_MSG_RESULT(no))
112 AC_SUBST(have_fallocate)
113 ])
8f0e0912
CH
114
115#
116# Check if we have the fiemap ioctl (Linux)
117#
118AC_DEFUN([AC_HAVE_FIEMAP],
2912da5d
NS
119 [ AC_MSG_CHECKING([for fiemap])
120 AC_TRY_LINK([
121#define _GNU_SOURCE
2912da5d
NS
122#include <linux/fs.h>
123#include <linux/fiemap.h>
124 ], [
125 struct fiemap *fiemap;
126 ioctl(0, FS_IOC_FIEMAP, (unsigned long)fiemap);
127 ], have_fiemap=yes
128 AC_MSG_RESULT(yes),
129 AC_MSG_RESULT(no))
8f0e0912
CH
130 AC_SUBST(have_fiemap)
131 ])
197d5828
ES
132
133#
134# Check if we have a preadv libc call (Linux)
135#
136AC_DEFUN([AC_HAVE_PREADV],
137 [ AC_MSG_CHECKING([for preadv])
138 AC_TRY_LINK([
197d5828 139#define _BSD_SOURCE
c1436573 140#define _DEFAULT_SOURCE
197d5828
ES
141#include <sys/uio.h>
142 ], [
143 preadv(0, 0, 0, 0);
144 ], have_preadv=yes
145 AC_MSG_RESULT(yes),
146 AC_MSG_RESULT(no))
147 AC_SUBST(have_preadv)
148 ])
149
c5deeac9
GR
150#
151# Check if we have a pwritev2 libc call (Linux)
152#
153AC_DEFUN([AC_HAVE_PWRITEV2],
154 [ AC_MSG_CHECKING([for pwritev2])
155 AC_TRY_LINK([
156#define _BSD_SOURCE
157#include <sys/uio.h>
158 ], [
159 pwritev2(0, 0, 0, 0, 0);
160 ], have_pwritev2=yes
161 AC_MSG_RESULT(yes),
162 AC_MSG_RESULT(no))
163 AC_SUBST(have_pwritev2)
164 ])
165
628e112a
AS
166#
167# Check if we have a copy_file_range system call (Linux)
168#
169AC_DEFUN([AC_HAVE_COPY_FILE_RANGE],
170 [ AC_MSG_CHECKING([for copy_file_range])
171 AC_TRY_LINK([
172#define _GNU_SOURCE
173#include <sys/syscall.h>
174#include <unistd.h>
175 ], [
176 syscall(__NR_copy_file_range, 0, 0, 0, 0, 0, 0);
177 ], have_copy_file_range=yes
178 AC_MSG_RESULT(yes),
179 AC_MSG_RESULT(no))
180 AC_SUBST(have_copy_file_range)
181 ])
182
197d5828
ES
183#
184# Check if we have a sync_file_range libc call (Linux)
185#
186AC_DEFUN([AC_HAVE_SYNC_FILE_RANGE],
187 [ AC_MSG_CHECKING([for sync_file_range])
188 AC_TRY_LINK([
189#define _GNU_SOURCE
197d5828
ES
190#include <fcntl.h>
191 ], [
192 sync_file_range(0, 0, 0, 0);
193 ], have_sync_file_range=yes
194 AC_MSG_RESULT(yes),
195 AC_MSG_RESULT(no))
196 AC_SUBST(have_sync_file_range)
197 ])
198
c7dd81c7
ES
199#
200# Check if we have a syncfs libc call (Linux)
201#
202AC_DEFUN([AC_HAVE_SYNCFS],
203 [ AC_MSG_CHECKING([for syncfs])
204 AC_TRY_LINK([
205#define _GNU_SOURCE
c7dd81c7
ES
206#include <unistd.h>
207 ], [
208 syncfs(0);
eb24bcff 209 ], have_syncfs=yes
c7dd81c7
ES
210 AC_MSG_RESULT(yes),
211 AC_MSG_RESULT(no))
212 AC_SUBST(have_syncfs)
213 ])
214
3bc05641
BF
215#
216# Check if we have a readdir libc call
217#
218AC_DEFUN([AC_HAVE_READDIR],
219 [ AC_MSG_CHECKING([for readdir])
220 AC_TRY_LINK([
221#include <dirent.h>
222 ], [
223 readdir(0);
224 ], have_readdir=yes
225 AC_MSG_RESULT(yes),
226 AC_MSG_RESULT(no))
227 AC_SUBST(have_readdir)
228 ])
229
5121281b
JT
230#
231# Check if we have a flc call (Mac OS X)
232#
233AC_DEFUN([AC_HAVE_FLS],
234 [ AC_CHECK_DECL([fls],
235 have_fls=yes,
236 [],
237 [#include <string.h>]
238 )
239 AC_SUBST(have_fls)
240 ])
241
c14c7b79
JT
242#
243# Check if we have a fsetxattr call (Mac OS X)
244#
245AC_DEFUN([AC_HAVE_FSETXATTR],
246 [ AC_CHECK_DECL([fsetxattr],
247 have_fsetxattr=yes,
248 [],
249 [#include <sys/types.h>
250 #include <attr/xattr.h>]
251 )
252 AC_SUBST(have_fsetxattr)
253 ])
254
5ae294ea
JT
255#
256# Check if there is mntent.h
257#
258AC_DEFUN([AC_HAVE_MNTENT],
259 [ AC_CHECK_HEADERS(mntent.h,
260 have_mntent=yes)
261 AC_SUBST(have_mntent)
262 ])
a49984b3
JT
263
264#
265# Check if we have a mremap call (not on Mac OS X)
266#
267AC_DEFUN([AC_HAVE_MREMAP],
268 [ AC_CHECK_DECL([mremap],
269 have_mremap=yes,
270 [],
271 [#define _GNU_SOURCE
272 #include <sys/mman.h>]
273 )
274 AC_SUBST(have_mremap)
275 ])
6529e656
DW
276
277#
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.
282#
283AC_DEFUN([AC_NEED_INTERNAL_FSXATTR],
284 [
1e51132f
DW
285 AC_CHECK_TYPE(struct fsxattr,
286 [
287 AC_CHECK_MEMBER(struct fsxattr.fsx_cowextsize,
288 ,
289 need_internal_fsxattr=yes,
290 [#include <linux/fs.h>]
291 )
292 ],,
293 [#include <linux/fs.h>]
294 )
6529e656
DW
295 AC_SUBST(need_internal_fsxattr)
296 ])
71956d72
DW
297
298#
299# Check if we have a FS_IOC_GETFSMAP ioctl (Linux)
300#
301AC_DEFUN([AC_HAVE_GETFSMAP],
302 [ AC_MSG_CHECKING([for GETFSMAP])
303 AC_TRY_LINK([
304#define _GNU_SOURCE
305#include <sys/syscall.h>
306#include <unistd.h>
307#include <linux/fs.h>
308#include <linux/fsmap.h>
309 ], [
310 unsigned long x = FS_IOC_GETFSMAP;
311 struct fsmap_head fh;
312 ], have_getfsmap=yes
313 AC_MSG_RESULT(yes),
314 AC_MSG_RESULT(no))
315 AC_SUBST(have_getfsmap)
316 ])
ce9adab0
JM
317
318AC_DEFUN([AC_HAVE_STATFS_FLAGS],
319 [
320 AC_CHECK_TYPE(struct statfs,
321 [
322 AC_CHECK_MEMBER(struct statfs.f_flags,
323 have_statfs_flags=yes,,
324 [#include <sys/vfs.h>]
325 )
326 ],,
327 [#include <sys/vfs.h>]
328 )
329 AC_SUBST(have_statfs_flags)
330 ])
dad79683
RZ
331
332#
333# Check if we have MAP_SYNC defines (Linux)
334#
335AC_DEFUN([AC_HAVE_MAP_SYNC],
336 [ AC_MSG_CHECKING([for MAP_SYNC])
337 AC_TRY_COMPILE([
338#include <asm-generic/mman.h>
339#include <asm-generic/mman-common.h>
340 ], [
341 int flags = MAP_SYNC | MAP_SHARED_VALIDATE;
342 ], have_map_sync=yes
343 AC_MSG_RESULT(yes),
344 AC_MSG_RESULT(no))
345 AC_SUBST(have_map_sync)
346 ])
173a0283
DW
347
348#
349# Check if we have a mallinfo libc call
350#
351AC_DEFUN([AC_HAVE_MALLINFO],
352 [ AC_MSG_CHECKING([for mallinfo ])
353 AC_TRY_COMPILE([
354#include <malloc.h>
355 ], [
356 struct mallinfo test;
357
358 test.arena = 0; test.hblkhd = 0; test.uordblks = 0; test.fordblks = 0;
359 test = mallinfo();
360 ], have_mallinfo=yes
361 AC_MSG_RESULT(yes),
362 AC_MSG_RESULT(no))
363 AC_SUBST(have_mallinfo)
364 ])
b364a9c0
DW
365
366#
367# Check if we have a openat call
368#
369AC_DEFUN([AC_HAVE_OPENAT],
370 [ AC_CHECK_DECL([openat],
371 have_openat=yes,
372 [],
373 [#include <sys/types.h>
374 #include <sys/stat.h>
375 #include <fcntl.h>]
376 )
377 AC_SUBST(have_openat)
378 ])
379
380#
381# Check if we have a fstatat call
382#
383AC_DEFUN([AC_HAVE_FSTATAT],
384 [ AC_CHECK_DECL([fstatat],
385 have_fstatat=yes,
386 [],
387 [#define _GNU_SOURCE
388 #include <sys/types.h>
389 #include <sys/stat.h>
390 #include <unistd.h>])
391 AC_SUBST(have_fstatat)
392 ])
03c0cd8f
DW
393
394#
395# Check if we have the SG_IO ioctl
396#
397AC_DEFUN([AC_HAVE_SG_IO],
398 [ AC_MSG_CHECKING([for struct sg_io_hdr ])
399 AC_TRY_COMPILE([#include <scsi/sg.h>],
400 [
401 struct sg_io_hdr hdr;
402 ioctl(0, SG_IO, &hdr);
403 ], have_sg_io=yes
404 AC_MSG_RESULT(yes),
405 AC_MSG_RESULT(no))
406 AC_SUBST(have_sg_io)
407 ])
408
409#
410# Check if we have the HDIO_GETGEO ioctl
411#
412AC_DEFUN([AC_HAVE_HDIO_GETGEO],
413 [ AC_MSG_CHECKING([for struct hd_geometry ])
414 AC_TRY_COMPILE([#include <linux/hdreg.h>],
415 [
416 struct hd_geometry hdr;
417 ioctl(0, HDIO_GETGEO, &hdr);
418 ], have_hdio_getgeo=yes
419 AC_MSG_RESULT(yes),
420 AC_MSG_RESULT(no))
421 AC_SUBST(have_hdio_getgeo)
422 ])
1b0adc71 423
e61f1552
DW
424AC_DEFUN([AC_PACKAGE_CHECK_LTO],
425 [ AC_MSG_CHECKING([if C compiler supports LTO])
426 OLD_CFLAGS="$CFLAGS"
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
439 have_lto=yes
440 fi
441 CFLAGS="${OLD_CFLAGS}"
442 LDFLAGS="${OLD_LDFLAGS}"
443 AC_SUBST(gcc_ar)
444 AC_SUBST(gcc_ranlib)
445 AC_SUBST(have_lto)
446 AC_SUBST(lto_cflags)
447 AC_SUBST(lto_ldflags)
448 ])
449
1b0adc71
DW
450AC_DEFUN([AC_PACKAGE_CHECK_RETPOLINE],
451 [ AC_MSG_CHECKING([if C compiler supports retpoline])
452 OLD_CFLAGS="$CFLAGS"
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
463 have_retpoline=yes
464 fi
465 CFLAGS="${OLD_CFLAGS}"
466 LDFLAGS="${OLD_LDFLAGS}"
467 AC_SUBST(have_retpoline)
468 AC_SUBST(retpoline_cflags)
469 AC_SUBST(retpoline_ldflags)
470 ])