io_u: reset ->resid on starting a requeue IO
[fio.git] / configure
CommitLineData
67bf9823
JA
1#!/bin/sh
2#
3# Fio configure script. Heavily influenced by the manual qemu configure
c922e0b0 4# script. Sad this is easier than autoconf and enemies.
67bf9823
JA
5#
6
7# set temporary file name
8if test ! -z "$TMPDIR" ; then
9 TMPDIR1="${TMPDIR}"
10elif test ! -z "$TEMPDIR" ; then
11 TMPDIR1="${TEMPDIR}"
12else
13 TMPDIR1="/tmp"
14fi
15
16TMPC="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}.c"
9ee669fa 17TMPC2="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}-2.c"
67bf9823
JA
18TMPO="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}.o"
19TMPE="${TMPDIR1}/fio-conf-${RANDOM}-$$-${RANDOM}.exe"
20
21# NB: do not call "exit" in the trap handler; this is buggy with some shells;
22# see <1285349658-3122-1-git-send-email-loic.minier@linaro.org>
9ee669fa 23trap "rm -f $TMPC $TMPC2 $TMPO $TMPE" EXIT INT QUIT TERM
67bf9823
JA
24
25rm -rf config.log
26
27config_host_mak="config-host.mak"
4feafb1e
JA
28config_host_h="config-host.h"
29
30rm -rf $config_host_mak
31rm -rf $config_host_h
67bf9823 32
d7145a78
JA
33fatal() {
34 echo $@
35 echo "Configure failed, check config.log and/or the above output"
36 rm -rf $config_host_mak
37 rm -rf $config_host_h
38 exit 1
39}
40
484b0b65
TK
41# Print result for each configuration test
42print_config() {
43 printf "%-30s%s\n" "$1" "$2"
44}
45
44404c5a 46# Default CFLAGS
4c0b3d98 47CFLAGS="-D_GNU_SOURCE -include config-host.h $CFLAGS"
af4862b3 48BUILD_CFLAGS=""
67bf9823
JA
49
50# Print a helpful header at the top of config.log
51echo "# FIO configure log $(date)" >> config.log
52printf "# Configured with:" >> config.log
53printf " '%s'" "$0" "$@" >> config.log
54echo >> config.log
55echo "#" >> config.log
56
7560fe7c
JA
57# Print configure header at the top of $config_host_h
58echo "/*" > $config_host_h
59echo " * Automatically generated by configure - do not modify" >> $config_host_h
60printf " * Configured with:" >> $config_host_h
61printf " * '%s'" "$0" "$@" >> $config_host_h
62echo "" >> $config_host_h
63echo " */" >> $config_host_h
64
67bf9823
JA
65do_cc() {
66 # Run the compiler, capturing its output to the log.
67 echo $cc "$@" >> config.log
68 $cc "$@" >> config.log 2>&1 || return $?
69 # Test passed. If this is an --enable-werror build, rerun
70 # the test with -Werror and bail out if it fails. This
71 # makes warning-generating-errors in configure test code
72 # obvious to developers.
73 if test "$werror" != "yes"; then
74 return 0
75 fi
76 # Don't bother rerunning the compile if we were already using -Werror
77 case "$*" in
78 *-Werror*)
79 return 0
80 ;;
81 esac
82 echo $cc -Werror "$@" >> config.log
83 $cc -Werror "$@" >> config.log 2>&1 && return $?
84 echo "ERROR: configure test passed without -Werror but failed with -Werror."
85 echo "This is probably a bug in the configure script. The failing command"
86 echo "will be at the bottom of config.log."
d7145a78 87 fatal "You can run configure with --disable-werror to bypass this check."
67bf9823
JA
88}
89
90compile_object() {
44f668d7 91 do_cc $CFLAGS -Werror-implicit-function-declaration -c -o $TMPO $TMPC
67bf9823
JA
92}
93
94compile_prog() {
95 local_cflags="$1"
adaa46d8 96 local_ldflags="$2 $LIBS"
67bf9823 97 echo "Compiling test case $3" >> config.log
44f668d7 98 do_cc $CFLAGS -Werror-implicit-function-declaration $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
67bf9823
JA
99}
100
101feature_not_found() {
102 feature=$1
c55d728b 103 packages=$2
67bf9823
JA
104
105 echo "ERROR"
106 echo "ERROR: User requested feature $feature"
c55d728b
JA
107 if test ! -z "$packages" ; then
108 echo "ERROR: That feature needs $packages installed"
109 fi
67bf9823 110 echo "ERROR: configure was not able to find it"
d7145a78 111 fatal "ERROR"
67bf9823
JA
112}
113
114has() {
115 type "$1" >/dev/null 2>&1
116}
117
118check_define() {
119 cat > $TMPC <<EOF
120#if !defined($1)
121#error $1 not defined
122#endif
123int main(void)
124{
125 return 0;
126}
127EOF
128 compile_object
129}
130
4feafb1e
JA
131output_sym() {
132 echo "$1=y" >> $config_host_mak
133 echo "#define $1" >> $config_host_h
134}
135
67bf9823
JA
136targetos=""
137cpu=""
138
91f94d5b 139# default options
47f44635
JA
140show_help="no"
141exit_val=0
ebec2094 142gfio_check="no"
1b10477b 143libhdfs="no"
43f3cec2 144pmemblk="no"
cbb15e42 145devdax="no"
ae0db592 146pmem="no"
d490af7f 147cuda="no"
de26b824 148disable_lex=""
3ee2a3c1 149disable_pmem="no"
a817dc3b 150disable_native="no"
9f75af77 151march_set="no"
247ef2aa 152libiscsi="no"
d643a1e2 153libnbd="no"
e2defc22 154libaio_uring="no"
5a8a6a03 155dynamic_engines="no"
020d54bd 156prefix=/usr/local
91f94d5b 157
cb1125b0
JA
158# parse options
159for opt do
160 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
161 case "$opt" in
020d54bd
JA
162 --prefix=*) prefix="$optarg"
163 ;;
8b156d8e
JA
164 --cpu=*) cpu="$optarg"
165 ;;
c8931876
JA
166 # esx is cross compiled and cannot be detect through simple uname calls
167 --esx)
168 esx="yes"
169 ;;
cb1125b0
JA
170 --cc=*) CC="$optarg"
171 ;;
208e4c8b
JA
172 --extra-cflags=*) CFLAGS="$CFLAGS $optarg"
173 ;;
b7c12794 174 --build-32bit-win) build_32bit_win="yes"
7409711b 175 ;;
a6ab5391
SW
176 --target-win-ver=*) target_win_ver="$optarg"
177 ;;
d2aeedb9
JA
178 --build-static) build_static="yes"
179 ;;
bad7e42c 180 --enable-gfio) gfio_check="yes"
899fab33 181 ;;
44462517
CF
182 --disable-numa) disable_numa="yes"
183 ;;
f678f8d2
MF
184 --disable-rdma) disable_rdma="yes"
185 ;;
d5f9b0ea
IF
186 --disable-rados) disable_rados="yes"
187 ;;
ce18290e
TM
188 --disable-rbd) disable_rbd="yes"
189 ;;
c2f6a13d
LMB
190 --disable-http) disable_http="yes"
191 ;;
ce18290e
TM
192 --disable-gfapi) disable_gfapi="yes"
193 ;;
1b10477b
MM
194 --enable-libhdfs) libhdfs="yes"
195 ;;
a655bbc4
JA
196 --disable-lex) disable_lex="yes"
197 ;;
de26b824
JA
198 --enable-lex) disable_lex="no"
199 ;;
61054f0d
JA
200 --disable-shm) no_shm="yes"
201 ;;
202 --disable-optimizations) disable_opt="yes"
ba40757e 203 ;;
3ee2a3c1
DJ
204 --disable-pmem) disable_pmem="yes"
205 ;;
d490af7f 206 --enable-cuda) cuda="yes"
03553853 207 ;;
a817dc3b
JA
208 --disable-native) disable_native="yes"
209 ;;
a40e7a59
GB
210 --with-ime=*) ime_path="$optarg"
211 ;;
247ef2aa
KZ
212 --enable-libiscsi) libiscsi="yes"
213 ;;
d643a1e2
RJ
214 --enable-libnbd) libnbd="yes"
215 ;;
01fe773d
JD
216 --disable-tcmalloc) disable_tcmalloc="yes"
217 ;;
e2defc22
JA
218 --enable-libaio-uring) libaio_uring="yes"
219 ;;
5a8a6a03
YK
220 --dynamic-libengines) dynamic_engines="yes"
221 ;;
827da4f5 222 --help)
47f44635 223 show_help="yes"
827da4f5 224 ;;
cb1125b0
JA
225 *)
226 echo "Bad option $opt"
47f44635
JA
227 show_help="yes"
228 exit_val=1
cb1125b0
JA
229 esac
230done
231
47f44635 232if test "$show_help" = "yes" ; then
05cef7a0
TK
233 echo "--prefix= Use this directory as installation prefix"
234 echo "--cpu= Specify target CPU if auto-detect fails"
235 echo "--cc= Specify compiler to use"
236 echo "--extra-cflags= Specify extra CFLAGS to pass to compiler"
237 echo "--build-32bit-win Enable 32-bit build on Windows"
a6ab5391 238 echo "--target-win-ver= Minimum version of Windows to target (XP or 7)"
05cef7a0
TK
239 echo "--build-static Build a static fio"
240 echo "--esx Configure build options for esx"
241 echo "--enable-gfio Enable building of gtk gfio"
242 echo "--disable-numa Disable libnuma even if found"
03553853 243 echo "--disable-rdma Disable RDMA support even if found"
e75a6fac
JH
244 echo "--disable-rados Disable Rados support even if found"
245 echo "--disable-rbd Disable Rados Block Device even if found"
246 echo "--disable-http Disable HTTP support even if found"
05cef7a0
TK
247 echo "--disable-gfapi Disable gfapi"
248 echo "--enable-libhdfs Enable hdfs support"
249 echo "--disable-lex Disable use of lex/yacc for math"
250 echo "--disable-pmem Disable pmem based engines even if found"
251 echo "--enable-lex Enable use of lex/yacc for math"
252 echo "--disable-shm Disable SHM support"
61054f0d 253 echo "--disable-optimizations Don't enable compiler optimizations"
03553853 254 echo "--enable-cuda Enable GPUDirect RDMA support"
a817dc3b 255 echo "--disable-native Don't build for native host"
a40e7a59 256 echo "--with-ime= Install path for DDN's Infinite Memory Engine"
247ef2aa 257 echo "--enable-libiscsi Enable iscsi support"
d643a1e2 258 echo "--enable-libnbd Enable libnbd (NBD engine) support"
01fe773d 259 echo "--disable-tcmalloc Disable tcmalloc support"
e2defc22 260 echo "--enable-libaio-uring Enable libaio emulated over io_uring"
5a8a6a03 261 echo "--dynamic-libengines Lib-based ioengines as dynamic libraries"
b7a99316 262 exit $exit_val
47f44635
JA
263fi
264
47986339 265cross_prefix=${cross_prefix-${CROSS_COMPILE}}
b73af738
SW
266# Preferred compiler (can be overriden later after we know the platform):
267# ${CC} (if set)
268# ${cross_prefix}gcc (if cross-prefix specified)
269# gcc if available
270# clang if available
271if test -z "${CC}${cross_prefix}"; then
272 if has gcc; then
273 cc=gcc
274 elif has clang; then
275 cc=clang
276 fi
277else
278 cc="${CC-${cross_prefix}gcc}"
279fi
47986339 280
6d0e9f83
AC
281if check_define __ANDROID__ ; then
282 targetos="Android"
283elif check_define __linux__ ; then
67bf9823 284 targetos="Linux"
67bf9823
JA
285elif check_define __OpenBSD__ ; then
286 targetos='OpenBSD'
89556808
BVA
287elif check_define __NetBSD__ ; then
288 targetos='NetBSD'
67bf9823
JA
289elif check_define __sun__ ; then
290 targetos='SunOS'
7cb024f8 291 CFLAGS="$CFLAGS -D_REENTRANT"
b24f59ab
SH
292elif check_define _WIN32 ; then
293 targetos='CYGWIN'
67bf9823
JA
294else
295 targetos=`uname -s`
296fi
297
53cd4eee
AC
298echo "# Automatically generated by configure - do not modify" > $config_host_mak
299printf "# Configured with:" >> $config_host_mak
300printf " '%s'" "$0" "$@" >> $config_host_mak
301echo >> $config_host_mak
302echo "CONFIG_TARGET_OS=$targetos" >> $config_host_mak
303
61054f0d
JA
304if test "$no_shm" = "yes" ; then
305 output_sym "CONFIG_NO_SHM"
306fi
307
308if test "$disable_opt" = "yes" ; then
309 output_sym "CONFIG_FIO_NO_OPT"
310fi
311
67bf9823
JA
312# Some host OSes need non-standard checks for which CPU to use.
313# Note that these checks are broken for cross-compilation: if you're
314# cross-compiling to one of these OSes then you'll need to specify
315# the correct CPU with the --cpu option.
316case $targetos in
26532556 317AIX|OpenBSD|NetBSD)
de26b824 318 # Unless explicitly enabled, turn off lex.
baa78fdc 319 # OpenBSD will hit syntax error when enabled.
de26b824
JA
320 if test -z "$disable_lex" ; then
321 disable_lex="yes"
daf705b5
JA
322 else
323 force_no_lex_o="yes"
de26b824
JA
324 fi
325 ;;
f22dd97a
RC
326FreeBSD)
327 CFLAGS="$CFLAGS -I/usr/local/include"
328 LDFLAGS="$LDFLAGS -L/usr/local/lib"
329 ;;
67bf9823
JA
330Darwin)
331 # on Leopard most of the system is 32-bit, so we have to ask the kernel if
332 # we can run 64-bit userspace code.
333 # If the user didn't specify a CPU explicitly and the kernel says this is
334 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual
335 # detection code.
336 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
337 cpu="x86_64"
338 fi
ccf2d89d
SW
339 # Error at compile time linking of weak/partial symbols if possible...
340cat > $TMPC <<EOF
341int main(void)
342{
343 return 0;
344}
345EOF
346 if compile_prog "" "-Wl,-no_weak_imports" "disable weak symbols"; then
347 echo "Disabling weak symbols"
348 LDFLAGS="$LDFLAGS -Wl,-no_weak_imports"
349 fi
67bf9823
JA
350 ;;
351SunOS)
352 # `uname -m` returns i86pc even on an x86_64 box, so default based on isainfo
353 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
354 cpu="x86_64"
355 fi
adaa46d8 356 LIBS="-lnsl -lsocket"
cfd94f79
JA
357 ;;
358CYGWIN*)
ca205a75
TK
359 # We still force some options, so keep this message here.
360 echo "Forcing some known good options on Windows"
b73af738 361 if test -z "${CC}${cross_prefix}"; then
7409711b 362 if test ! -z "$build_32bit_win" && test "$build_32bit_win" = "yes"; then
b73af738 363 cc="i686-w64-mingw32-gcc"
7409711b 364 else
b73af738 365 cc="x86_64-w64-mingw32-gcc"
7409711b 366 fi
4578d01f 367 fi
a6ab5391
SW
368
369 target_win_ver=$(echo "$target_win_ver" | tr '[:lower:]' '[:upper:]')
370 if test -z "$target_win_ver"; then
371 # Default Windows API target
372 target_win_ver="7"
373 fi
374 if test "$target_win_ver" = "XP"; then
375 output_sym "CONFIG_WINDOWS_XP"
376 elif test "$target_win_ver" = "7"; then
377 output_sym "CONFIG_WINDOWS_7"
378 CFLAGS="$CFLAGS -D_WIN32_WINNT=0x0601"
7409711b 379 else
a6ab5391 380 fatal "Unknown target Windows version"
7409711b 381 fi
a6ab5391 382
ca205a75
TK
383 # We need this to be output_sym'd here because this is Windows specific.
384 # The regular configure path never sets this config.
4feafb1e 385 output_sym "CONFIG_WINDOWSAIO"
ca205a75
TK
386 # We now take the regular configuration path without having exit 0 here.
387 # Flags below are still necessary mostly for MinGW.
12ed4fc8 388 build_static="yes"
ca205a75
TK
389 rusage_thread="yes"
390 fdatasync="yes"
391 clock_gettime="yes" # clock_monotonic probe has dependency on this
392 clock_monotonic="yes"
ca205a75 393 sched_idle="yes"
6d0e9f83 394 ;;
67bf9823
JA
395esac
396
b73af738
SW
397# Now we know the target platform we can have another guess at the preferred
398# compiler when it wasn't explictly set
399if test -z "${CC}${cross_prefix}"; then
400 if test "$targetos" = "FreeBSD" || test "$targetos" = "Darwin"; then
401 if has clang; then
402 cc=clang
403 fi
404 fi
405fi
406if test -z "$cc"; then
407 echo "configure: failed to find compiler"
408 exit 1
409fi
410
67bf9823
JA
411if test ! -z "$cpu" ; then
412 # command line argument
413 :
414elif check_define __i386__ ; then
415 cpu="i386"
416elif check_define __x86_64__ ; then
417 cpu="x86_64"
418elif check_define __sparc__ ; then
419 if check_define __arch64__ ; then
420 cpu="sparc64"
421 else
422 cpu="sparc"
423 fi
424elif check_define _ARCH_PPC ; then
425 if check_define _ARCH_PPC64 ; then
426 cpu="ppc64"
427 else
428 cpu="ppc"
429 fi
430elif check_define __mips__ ; then
431 cpu="mips"
432elif check_define __ia64__ ; then
433 cpu="ia64"
434elif check_define __s390__ ; then
435 if check_define __s390x__ ; then
436 cpu="s390x"
437 else
438 cpu="s390"
439 fi
440elif check_define __arm__ ; then
441 cpu="arm"
214e2d56 442elif check_define __aarch64__ ; then
443 cpu="aarch64"
67bf9823
JA
444elif check_define __hppa__ ; then
445 cpu="hppa"
446else
447 cpu=`uname -m`
448fi
449
450# Normalise host CPU name and set ARCH.
451case "$cpu" in
452 ia64|ppc|ppc64|s390|s390x|sparc64)
453 cpu="$cpu"
454 ;;
455 i386|i486|i586|i686|i86pc|BePC)
95ef38ab 456 cpu="x86"
67bf9823
JA
457 ;;
458 x86_64|amd64)
459 cpu="x86_64"
460 ;;
461 armv*b|armv*l|arm)
462 cpu="arm"
463 ;;
214e2d56 464 aarch64)
465 cpu="arm64"
466 ;;
67bf9823
JA
467 hppa|parisc|parisc64)
468 cpu="hppa"
469 ;;
470 mips*)
471 cpu="mips"
472 ;;
473 sparc|sun4[cdmuv])
474 cpu="sparc"
475 ;;
476 *)
8b156d8e 477 echo "Unknown CPU"
67bf9823
JA
478 ;;
479esac
480
1a17cfdb
AC
481##########################################
482# check cross compile
483
ca205a75
TK
484if test "$cross_compile" != "yes" ; then
485 cross_compile="no"
486fi
1a17cfdb
AC
487cat > $TMPC <<EOF
488int main(void)
489{
490 return 0;
491}
492EOF
493if compile_prog "" "" "cross"; then
494 $TMPE 2>/dev/null || cross_compile="yes"
495else
496 fatal "compile test failed"
497fi
498
0dcebdf4
JA
499##########################################
500# check endianness
ca205a75
TK
501if test "$bigendian" != "yes" ; then
502 bigendian="no"
503fi
1a17cfdb
AC
504if test "$cross_compile" = "no" ; then
505 cat > $TMPC <<EOF
0dcebdf4
JA
506#include <inttypes.h>
507int main(void)
508{
509 volatile uint32_t i=0x01234567;
510 return (*((uint8_t*)(&i))) == 0x67;
511}
512EOF
1a17cfdb
AC
513 if compile_prog "" "" "endian"; then
514 $TMPE && bigendian="yes"
515 fi
516else
517 # If we're cross compiling, try our best to work it out and rely on the
518 # run-time check to fail if we get it wrong.
519 cat > $TMPC <<EOF
520#include <endian.h>
521int main(void)
522{
523#if __BYTE_ORDER != __BIG_ENDIAN
524# error "Unknown endianness"
525#endif
526}
527EOF
528 compile_prog "" "" "endian" && bigendian="yes"
529 check_define "__ARMEB__" && bigendian="yes"
530 check_define "__MIPSEB__" && bigendian="yes"
0dcebdf4
JA
531fi
532
533
484b0b65
TK
534print_config "Operating system" "$targetos"
535print_config "CPU" "$cpu"
536print_config "Big endian" "$bigendian"
a6ab5391
SW
537if test ! -z "$target_win_ver"; then
538 print_config "Target Windows version" "$target_win_ver"
539fi
484b0b65
TK
540print_config "Compiler" "$cc"
541print_config "Cross compile" "$cross_compile"
67bf9823
JA
542echo
543
d2aeedb9
JA
544##########################################
545# See if we need to build a static build
546if test "$build_static" = "yes" ; then
547 CFLAGS="$CFLAGS -ffunction-sections -fdata-sections"
548 LDFLAGS="$LDFLAGS -static -Wl,--gc-sections"
549else
550 build_static="no"
551fi
484b0b65 552print_config "Static build" "$build_static"
d2aeedb9 553
bb012314
SW
554##########################################
555# check for C11 atomics support
556cat > $TMPC <<EOF
557#include <stdatomic.h>
558int main(void)
559{
560 _Atomic unsigned v;
561 atomic_load(&v);
562 return 0;
563}
564EOF
565if ! compile_prog "" "" "C11 atomics"; then
566 echo
567 echo "Your compiler doesn't support C11 atomics. gcc 4.9/clang 3.6 are the"
568 echo "minimum versions with it - perhaps your compiler is too old?"
569 fatal "C11 atomics support not found"
570fi
571
572
67bf9823
JA
573##########################################
574# check for wordsize
575wordsize="0"
576cat > $TMPC <<EOF
142429e5
AC
577#include <limits.h>
578#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
67bf9823
JA
579int main(void)
580{
142429e5 581 BUILD_BUG_ON(sizeof(long)*CHAR_BIT != WORDSIZE);
67bf9823
JA
582 return 0;
583}
584EOF
142429e5
AC
585if compile_prog "-DWORDSIZE=32" "" "wordsize"; then
586 wordsize="32"
587elif compile_prog "-DWORDSIZE=64" "" "wordsize"; then
588 wordsize="64"
589else
590 fatal "Unknown wordsize"
67bf9823 591fi
484b0b65 592print_config "Wordsize" "$wordsize"
67bf9823 593
a9bca4aa
JA
594##########################################
595# zlib probe
ca205a75
TK
596if test "$zlib" != "yes" ; then
597 zlib="no"
598fi
a9bca4aa 599cat > $TMPC <<EOF
804a1e05 600#include <zlib.h>
a9bca4aa
JA
601int main(void)
602{
603 z_stream stream;
604 if (inflateInit(&stream) != Z_OK)
605 return 1;
606 return 0;
607}
608EOF
609if compile_prog "" "-lz" "zlib" ; then
610 zlib=yes
611 LIBS="-lz $LIBS"
a9bca4aa 612fi
484b0b65 613print_config "zlib" "$zlib"
a9bca4aa 614
67bf9823
JA
615##########################################
616# linux-aio probe
ca205a75
TK
617if test "$libaio" != "yes" ; then
618 libaio="no"
619fi
7c77ebef 620if test "$esx" != "yes" ; then
621 cat > $TMPC <<EOF
67bf9823
JA
622#include <libaio.h>
623#include <stddef.h>
624int main(void)
625{
626 io_setup(0, NULL);
627 return 0;
628}
629EOF
d490af7f
SW
630 if test "$libaio_uring" = "yes"; then
631 if compile_prog "" "-luring" "libaio io_uring" ; then
632 libaio=yes
633 LIBS="-luring $LIBS"
634 else
635 feature_not_found "libaio io_uring" ""
636 fi
e2defc22 637 elif compile_prog "" "-laio" "libaio" ; then
7c77ebef 638 libaio=yes
e2defc22 639 libaio_uring=no
7c77ebef 640 else
641 if test "$libaio" = "yes" ; then
642 feature_not_found "linux AIO" "libaio-dev or libaio-devel"
643 fi
644 libaio=no
e2defc22 645 libaio_uring=no
67bf9823 646 fi
7d42e66e
KK
647
648 cat > $TMPC <<EOF
649#include <libaio.h>
650#include <stddef.h>
651int main(void)
652{
653 io_prep_preadv2(NULL, 0, NULL, 0, 0, 0);
654 io_prep_pwritev2(NULL, 0, NULL, 0, 0, 0);
655 return 0;
656}
657EOF
658 if compile_prog "" "" "libaio rw flags" ; then
659 libaio_rw_flags=yes
660 else
661 libaio_rw_flags=no
662 fi
67bf9823 663fi
484b0b65 664print_config "Linux AIO support" "$libaio"
7d42e66e 665print_config "Linux AIO support rw flags" "$libaio_rw_flags"
e2defc22 666print_config "Linux AIO over io_uring" "$libaio_uring"
67bf9823
JA
667
668##########################################
669# posix aio probe
ca205a75
TK
670if test "$posix_aio" != "yes" ; then
671 posix_aio="no"
672fi
673if test "$posix_aio_lrt" != "yes" ; then
674 posix_aio_lrt="no"
675fi
67bf9823
JA
676cat > $TMPC <<EOF
677#include <aio.h>
678int main(void)
679{
680 struct aiocb cb;
681 aio_read(&cb);
682 return 0;
683}
684EOF
685if compile_prog "" "" "posixaio" ; then
686 posix_aio="yes"
09c81e13 687elif compile_prog "" "-lrt" "posixaio -lrt"; then
67bf9823
JA
688 posix_aio="yes"
689 posix_aio_lrt="yes"
690 LIBS="-lrt $LIBS"
691fi
484b0b65
TK
692print_config "POSIX AIO support" "$posix_aio"
693print_config "POSIX AIO support needs -lrt" "$posix_aio_lrt"
67bf9823
JA
694
695##########################################
696# posix aio fsync probe
ca205a75
TK
697if test "$posix_aio_fsync" != "yes" ; then
698 posix_aio_fsync="no"
699fi
67bf9823
JA
700if test "$posix_aio" = "yes" ; then
701 cat > $TMPC <<EOF
702#include <fcntl.h>
703#include <aio.h>
704int main(void)
705{
706 struct aiocb cb;
707 return aio_fsync(O_SYNC, &cb);
708 return 0;
709}
710EOF
711 if compile_prog "" "$LIBS" "posix_aio_fsync" ; then
712 posix_aio_fsync=yes
713 fi
714fi
484b0b65 715print_config "POSIX AIO fsync" "$posix_aio_fsync"
67bf9823 716
06eac6b2
SW
717##########################################
718# POSIX pshared attribute probe
d418fa90
TK
719if test "$posix_pshared" != "yes" ; then
720 posix_pshared="no"
721fi
06eac6b2
SW
722cat > $TMPC <<EOF
723#include <unistd.h>
724int main(void)
725{
726#if defined(_POSIX_THREAD_PROCESS_SHARED) && ((_POSIX_THREAD_PROCESS_SHARED + 0) > 0)
727# if defined(__CYGWIN__)
728# error "_POSIX_THREAD_PROCESS_SHARED is buggy on Cygwin"
729# elif defined(__APPLE__)
730# include <AvailabilityMacros.h>
731# include <TargetConditionals.h>
732# if TARGET_OS_MAC && MAC_OS_X_VERSION_MIN_REQUIRED < 1070
733# error "_POSIX_THREAD_PROCESS_SHARED is buggy/unsupported prior to OSX 10.7"
734# endif
735# endif
736#else
737# error "_POSIX_THREAD_PROCESS_SHARED is unsupported"
738#endif
739 return 0;
740}
741EOF
742if compile_prog "" "$LIBS" "posix_pshared" ; then
743 posix_pshared=yes
744fi
484b0b65 745print_config "POSIX pshared support" "$posix_pshared"
06eac6b2 746
78b66d32
BVA
747##########################################
748# POSIX pthread_condattr_setclock() probe
749if test "$pthread_condattr_setclock" != "yes" ; then
750 pthread_condattr_setclock="no"
751fi
752cat > $TMPC <<EOF
753#include <pthread.h>
754int main(void)
755{
756 pthread_condattr_t condattr;
757 pthread_condattr_setclock(&condattr, CLOCK_MONOTONIC);
758 return 0;
759}
760EOF
761if compile_prog "" "$LIBS" "pthread_condattr_setclock" ; then
762 pthread_condattr_setclock=yes
a9bf436e
BVA
763elif compile_prog "" "$LIBS -lpthread" "pthread_condattr_setclock" ; then
764 pthread_condattr_setclock=yes
765 LIBS="$LIBS -lpthread"
78b66d32 766fi
a9bf436e 767print_config "pthread_condattr_setclock()" "$pthread_condattr_setclock"
78b66d32 768
c31092b8
BVA
769##########################################
770# pthread_sigmask() probe
771if test "$pthread_sigmask" != "yes" ; then
772 pthread_sigmask="no"
773fi
774cat > $TMPC <<EOF
775#include <stddef.h> /* NULL */
776#include <signal.h> /* pthread_sigmask() */
777int main(void)
778{
779 return pthread_sigmask(0, NULL, NULL);
780}
781EOF
782if compile_prog "" "$LIBS" "pthread_sigmask" ; then
783 pthread_sigmask=yes
784elif compile_prog "" "$LIBS -lpthread" "pthread_sigmask" ; then
785 pthread_sigmask=yes
786 LIBS="$LIBS -lpthread"
787fi
788print_config "pthread_sigmask()" "$pthread_sigmask"
789
67bf9823
JA
790##########################################
791# solaris aio probe
ca205a75
TK
792if test "$solaris_aio" != "yes" ; then
793 solaris_aio="no"
794fi
67bf9823
JA
795cat > $TMPC <<EOF
796#include <sys/types.h>
797#include <sys/asynch.h>
798#include <unistd.h>
799int main(void)
800{
801 aio_result_t res;
802 return aioread(0, NULL, 0, 0, SEEK_SET, &res);
803 return 0;
804}
805EOF
806if compile_prog "" "-laio" "solarisaio" ; then
807 solaris_aio=yes
808 LIBS="-laio $LIBS"
809fi
484b0b65 810print_config "Solaris AIO support" "$solaris_aio"
67bf9823
JA
811
812##########################################
f5cd2907 813# __sync_fetch_and_add test
ca205a75
TK
814if test "$sfaa" != "yes" ; then
815 sfaa="no"
816fi
67bf9823 817cat > $TMPC << EOF
958886d8
JA
818#include <inttypes.h>
819static int sfaa(uint64_t *ptr)
67bf9823 820{
9c639a76 821 return __sync_fetch_and_add(ptr, 0);
67bf9823
JA
822}
823
824int main(int argc, char **argv)
825{
958886d8 826 uint64_t val = 42;
67bf9823
JA
827 sfaa(&val);
828 return val;
829}
830EOF
831if compile_prog "" "" "__sync_fetch_and_add()" ; then
832 sfaa="yes"
833fi
484b0b65 834print_config "__sync_fetch_and_add" "$sfaa"
67bf9823 835
a250edd0
JA
836##########################################
837# __sync_synchronize() test
838if test "$sync_sync" != "yes" ; then
839 sync_sync="no"
840fi
841cat > $TMPC << EOF
842#include <inttypes.h>
843
844int main(int argc, char **argv)
845{
846 __sync_synchronize();
847 return 0;
848}
849EOF
850if compile_prog "" "" "__sync_synchronize()" ; then
851 sync_sync="yes"
852fi
853print_config "__sync_synchronize" "$sync_sync"
854
855##########################################
856# __sync_val_compare_and_swap() test
857if test "$cmp_swap" != "yes" ; then
858 cmp_swap="no"
859fi
860cat > $TMPC << EOF
861#include <inttypes.h>
862
863int main(int argc, char **argv)
864{
865 int x = 0;
866 return __sync_val_compare_and_swap(&x, 1, 2);
867}
868EOF
869if compile_prog "" "" "__sync_val_compare_and_swap()" ; then
870 cmp_swap="yes"
871fi
872print_config "__sync_val_compare_and_swap" "$cmp_swap"
873
67bf9823
JA
874##########################################
875# libverbs probe
ca205a75
TK
876if test "$libverbs" != "yes" ; then
877 libverbs="no"
878fi
67bf9823 879cat > $TMPC << EOF
eb3bfdd8 880#include <infiniband/verbs.h>
67bf9823
JA
881int main(int argc, char **argv)
882{
883 struct ibv_pd *pd = ibv_alloc_pd(NULL);
40dae137 884 return pd != NULL;
67bf9823
JA
885}
886EOF
f678f8d2 887if test "$disable_rdma" != "yes" && compile_prog "" "-libverbs" "libverbs" ; then
67bf9823 888 libverbs="yes"
67bf9823 889fi
484b0b65 890print_config "libverbs" "$libverbs"
67bf9823
JA
891
892##########################################
893# rdmacm probe
ca205a75
TK
894if test "$rdmacm" != "yes" ; then
895 rdmacm="no"
896fi
67bf9823
JA
897cat > $TMPC << EOF
898#include <stdio.h>
899#include <rdma/rdma_cma.h>
900int main(int argc, char **argv)
901{
902 rdma_destroy_qp(NULL);
903 return 0;
904}
905EOF
f678f8d2 906if test "$disable_rdma" != "yes" && compile_prog "" "-lrdmacm" "rdma"; then
67bf9823 907 rdmacm="yes"
67bf9823 908fi
484b0b65 909print_config "rdmacm" "$rdmacm"
67bf9823 910
44e8e956
BVA
911##########################################
912# asprintf() and vasprintf() probes
913if test "$have_asprintf" != "yes" ; then
914 have_asprintf="no"
915fi
916cat > $TMPC << EOF
917#include <stdio.h>
918
919int main(int argc, char **argv)
920{
921 return asprintf(NULL, "%s", "str") == 0;
922}
923EOF
924if compile_prog "" "" "have_asprintf"; then
925 have_asprintf="yes"
926fi
927print_config "asprintf()" "$have_asprintf"
928
929if test "$have_vasprintf" != "yes" ; then
930 have_vasprintf="no"
931fi
932cat > $TMPC << EOF
933#include <stdio.h>
934
935int main(int argc, char **argv)
936{
849ac4b2
RP
937 va_list ap;
938 return vasprintf(NULL, "%s", ap) == 0;
44e8e956
BVA
939}
940EOF
941if compile_prog "" "" "have_vasprintf"; then
942 have_vasprintf="yes"
943fi
944print_config "vasprintf()" "$have_vasprintf"
945
67bf9823
JA
946##########################################
947# Linux fallocate probe
ca205a75
TK
948if test "$linux_fallocate" != "yes" ; then
949 linux_fallocate="no"
950fi
67bf9823
JA
951cat > $TMPC << EOF
952#include <stdio.h>
aa6738a5 953#include <fcntl.h>
67bf9823
JA
954#include <linux/falloc.h>
955int main(int argc, char **argv)
956{
957 int r = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 1024);
958 return r;
959}
960EOF
961if compile_prog "" "" "linux_fallocate"; then
962 linux_fallocate="yes"
963fi
484b0b65 964print_config "Linux fallocate" "$linux_fallocate"
67bf9823
JA
965
966##########################################
967# POSIX fadvise probe
ca205a75
TK
968if test "$posix_fadvise" != "yes" ; then
969 posix_fadvise="no"
970fi
67bf9823
JA
971cat > $TMPC << EOF
972#include <stdio.h>
973#include <fcntl.h>
974int main(int argc, char **argv)
975{
976 int r = posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
977 return r;
978}
979EOF
980if compile_prog "" "" "posix_fadvise"; then
981 posix_fadvise="yes"
982fi
484b0b65 983print_config "POSIX fadvise" "$posix_fadvise"
67bf9823
JA
984
985##########################################
986# POSIX fallocate probe
ca205a75
TK
987if test "$posix_fallocate" != "yes" ; then
988 posix_fallocate="no"
989fi
67bf9823
JA
990cat > $TMPC << EOF
991#include <stdio.h>
992#include <fcntl.h>
993int main(int argc, char **argv)
994{
995 int r = posix_fallocate(0, 0, 1024);
996 return r;
997}
998EOF
999if compile_prog "" "" "posix_fallocate"; then
1000 posix_fallocate="yes"
1001fi
484b0b65 1002print_config "POSIX fallocate" "$posix_fallocate"
67bf9823
JA
1003
1004##########################################
1005# sched_set/getaffinity 2 or 3 argument test
ca205a75
TK
1006if test "$linux_2arg_affinity" != "yes" ; then
1007 linux_2arg_affinity="no"
1008fi
1009if test "$linux_3arg_affinity" != "yes" ; then
1010 linux_3arg_affinity="no"
1011fi
67bf9823 1012cat > $TMPC << EOF
67bf9823
JA
1013#include <sched.h>
1014int main(int argc, char **argv)
1015{
1016 cpu_set_t mask;
1017 return sched_setaffinity(0, sizeof(mask), &mask);
1018}
1019EOF
1020if compile_prog "" "" "sched_setaffinity(,,)"; then
1021 linux_3arg_affinity="yes"
1022else
1023 cat > $TMPC << EOF
67bf9823
JA
1024#include <sched.h>
1025int main(int argc, char **argv)
1026{
1027 cpu_set_t mask;
1028 return sched_setaffinity(0, &mask);
1029}
1030EOF
1031 if compile_prog "" "" "sched_setaffinity(,)"; then
1032 linux_2arg_affinity="yes"
1033 fi
1034fi
484b0b65
TK
1035print_config "sched_setaffinity(3 arg)" "$linux_3arg_affinity"
1036print_config "sched_setaffinity(2 arg)" "$linux_2arg_affinity"
67bf9823
JA
1037
1038##########################################
1039# clock_gettime probe
ca205a75
TK
1040if test "$clock_gettime" != "yes" ; then
1041 clock_gettime="no"
1042fi
67bf9823
JA
1043cat > $TMPC << EOF
1044#include <stdio.h>
1045#include <time.h>
1046int main(int argc, char **argv)
1047{
1048 return clock_gettime(0, NULL);
1049}
1050EOF
1051if compile_prog "" "" "clock_gettime"; then
1052 clock_gettime="yes"
1053elif compile_prog "" "-lrt" "clock_gettime"; then
1054 clock_gettime="yes"
1055 LIBS="-lrt $LIBS"
1056fi
484b0b65 1057print_config "clock_gettime" "$clock_gettime"
67bf9823
JA
1058
1059##########################################
1060# CLOCK_MONOTONIC probe
ca205a75
TK
1061if test "$clock_monotonic" != "yes" ; then
1062 clock_monotonic="no"
1063fi
67bf9823
JA
1064if test "$clock_gettime" = "yes" ; then
1065 cat > $TMPC << EOF
1066#include <stdio.h>
1067#include <time.h>
1068int main(int argc, char **argv)
1069{
1070 return clock_gettime(CLOCK_MONOTONIC, NULL);
1071}
1072EOF
1073 if compile_prog "" "$LIBS" "clock monotonic"; then
1074 clock_monotonic="yes"
1075 fi
1076fi
484b0b65 1077print_config "CLOCK_MONOTONIC" "$clock_monotonic"
67bf9823 1078
c544f604
SN
1079##########################################
1080# CLOCK_MONOTONIC_RAW probe
ca205a75
TK
1081if test "$clock_monotonic_raw" != "yes" ; then
1082 clock_monotonic_raw="no"
1083fi
c544f604
SN
1084if test "$clock_gettime" = "yes" ; then
1085 cat > $TMPC << EOF
1086#include <stdio.h>
1087#include <time.h>
1088int main(int argc, char **argv)
1089{
1090 return clock_gettime(CLOCK_MONOTONIC_RAW, NULL);
1091}
1092EOF
1093 if compile_prog "" "$LIBS" "clock monotonic"; then
1094 clock_monotonic_raw="yes"
1095 fi
1096fi
484b0b65 1097print_config "CLOCK_MONOTONIC_RAW" "$clock_monotonic_raw"
c544f604 1098
67bf9823
JA
1099##########################################
1100# CLOCK_MONOTONIC_PRECISE probe
ca205a75
TK
1101if test "$clock_monotonic_precise" != "yes" ; then
1102 clock_monotonic_precise="no"
1103fi
67bf9823
JA
1104if test "$clock_gettime" = "yes" ; then
1105 cat > $TMPC << EOF
1106#include <stdio.h>
1107#include <time.h>
1108int main(int argc, char **argv)
1109{
1110 return clock_gettime(CLOCK_MONOTONIC_PRECISE, NULL);
1111}
1112EOF
1113 if compile_prog "" "$LIBS" "clock monotonic precise"; then
1114 clock_monotonic_precise="yes"
1115 fi
1116fi
484b0b65 1117print_config "CLOCK_MONOTONIC_PRECISE" "$clock_monotonic_precise"
67bf9823 1118
25f8227d
JA
1119##########################################
1120# clockid_t probe
ca205a75
TK
1121if test "$clockid_t" != "yes" ; then
1122 clockid_t="no"
1123fi
25f8227d 1124cat > $TMPC << EOF
25f8227d 1125#include <time.h>
209c37b4 1126#include <string.h>
25f8227d
JA
1127int main(int argc, char **argv)
1128{
ccf2d89d 1129 volatile clockid_t cid;
7fcad9e1 1130 memset((void*)&cid, 0, sizeof(cid));
ccf2d89d 1131 return 0;
25f8227d
JA
1132}
1133EOF
1134if compile_prog "" "$LIBS" "clockid_t"; then
1135 clockid_t="yes"
1136fi
484b0b65 1137print_config "clockid_t" "$clockid_t"
25f8227d 1138
67bf9823
JA
1139##########################################
1140# gettimeofday() probe
ca205a75
TK
1141if test "$gettimeofday" != "yes" ; then
1142 gettimeofday="no"
1143fi
67bf9823
JA
1144cat > $TMPC << EOF
1145#include <sys/time.h>
1146#include <stdio.h>
1147int main(int argc, char **argv)
1148{
1149 struct timeval tv;
1150 return gettimeofday(&tv, NULL);
1151}
1152EOF
1153if compile_prog "" "" "gettimeofday"; then
1154 gettimeofday="yes"
1155fi
484b0b65 1156print_config "gettimeofday" "$gettimeofday"
67bf9823
JA
1157
1158##########################################
1159# fdatasync() probe
ca205a75
TK
1160if test "$fdatasync" != "yes" ; then
1161 fdatasync="no"
1162fi
67bf9823
JA
1163cat > $TMPC << EOF
1164#include <stdio.h>
1165#include <unistd.h>
1166int main(int argc, char **argv)
1167{
1168 return fdatasync(0);
1169}
1170EOF
1171if compile_prog "" "" "fdatasync"; then
1172 fdatasync="yes"
1173fi
484b0b65 1174print_config "fdatasync" "$fdatasync"
67bf9823 1175
52a552e2
BVA
1176##########################################
1177# pipe() probe
1178if test "$pipe" != "yes" ; then
1179 pipe="no"
1180fi
1181cat > $TMPC << EOF
1182#include <unistd.h>
1183int main(int argc, char **argv)
1184{
1185 int fd[2];
1186 return pipe(fd);
1187}
1188EOF
1189if compile_prog "" "" "pipe"; then
1190 pipe="yes"
1191fi
1192print_config "pipe()" "$pipe"
1193
1194##########################################
1195# pipe2() probe
1196if test "$pipe2" != "yes" ; then
1197 pipe2="no"
1198fi
1199cat > $TMPC << EOF
1200#include <unistd.h>
1201int main(int argc, char **argv)
1202{
1203 int fd[2];
1204 return pipe2(fd, 0);
1205}
1206EOF
1207if compile_prog "" "" "pipe2"; then
1208 pipe2="yes"
1209fi
1210print_config "pipe2()" "$pipe2"
1211
15eca9aa
BVA
1212##########################################
1213# pread() probe
1214if test "$pread" != "yes" ; then
1215 pread="no"
1216fi
1217cat > $TMPC << EOF
1218#include <unistd.h>
1219int main(int argc, char **argv)
1220{
1221 return pread(0, NULL, 0, 0);
1222}
1223EOF
1224if compile_prog "" "" "pread"; then
1225 pread="yes"
1226fi
1227print_config "pread()" "$pread"
1228
67bf9823
JA
1229##########################################
1230# sync_file_range() probe
ca205a75
TK
1231if test "$sync_file_range" != "yes" ; then
1232 sync_file_range="no"
1233fi
67bf9823
JA
1234cat > $TMPC << EOF
1235#include <stdio.h>
1236#include <unistd.h>
67bf9823
JA
1237#include <fcntl.h>
1238#include <linux/fs.h>
1239int main(int argc, char **argv)
1240{
1241 unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE |
1242 SYNC_FILE_RANGE_WAIT_AFTER;
1243 return sync_file_range(0, 0, 0, flags);
1244}
1245EOF
1246if compile_prog "" "" "sync_file_range"; then
1247 sync_file_range="yes"
1248fi
484b0b65 1249print_config "sync_file_range" "$sync_file_range"
67bf9823
JA
1250
1251##########################################
1252# ext4 move extent probe
ca205a75
TK
1253if test "$ext4_me" != "yes" ; then
1254 ext4_me="no"
1255fi
67bf9823
JA
1256cat > $TMPC << EOF
1257#include <fcntl.h>
1258#include <sys/ioctl.h>
1259int main(int argc, char **argv)
1260{
1261 struct move_extent me;
1262 return ioctl(0, EXT4_IOC_MOVE_EXT, &me);
1263}
1264EOF
c7165b8d
JA
1265if compile_prog "" "" "ext4 move extent" ; then
1266 ext4_me="yes"
1267elif test $targetos = "Linux" ; then
1268 # On Linux, just default to it on and let it error at runtime if we really
1269 # don't have it. None of my updated systems have it defined, but it does
1270 # work. Takes a while to bubble back.
67bf9823
JA
1271 ext4_me="yes"
1272fi
484b0b65 1273print_config "EXT4 move extent" "$ext4_me"
67bf9823
JA
1274
1275##########################################
1276# splice probe
ca205a75
TK
1277if test "$linux_splice" != "yes" ; then
1278 linux_splice="no"
1279fi
67bf9823 1280cat > $TMPC << EOF
67bf9823
JA
1281#include <stdio.h>
1282#include <fcntl.h>
1283int main(int argc, char **argv)
1284{
1285 return splice(0, NULL, 0, NULL, 0, SPLICE_F_NONBLOCK);
1286}
1287EOF
1288if compile_prog "" "" "linux splice"; then
1289 linux_splice="yes"
1290fi
484b0b65 1291print_config "Linux splice(2)" "$linux_splice"
67bf9823
JA
1292
1293##########################################
1294# GUASI probe
ca205a75
TK
1295if test "$guasi" != "yes" ; then
1296 guasi="no"
1297fi
67bf9823
JA
1298cat > $TMPC << EOF
1299#include <guasi.h>
1300#include <guasi_syscalls.h>
1301int main(int argc, char **argv)
1302{
1303 guasi_t ctx = guasi_create(0, 0, 0);
1304 return 0;
1305}
1306EOF
1307if compile_prog "" "" "guasi"; then
1308 guasi="yes"
1309fi
484b0b65 1310print_config "GUASI" "$guasi"
67bf9823 1311
67bf9823
JA
1312##########################################
1313# libnuma probe
ca205a75
TK
1314if test "$libnuma" != "yes" ; then
1315 libnuma="no"
1316fi
67bf9823
JA
1317cat > $TMPC << EOF
1318#include <numa.h>
1319int main(int argc, char **argv)
1320{
1321 return numa_available();
1322}
1323EOF
44462517 1324if test "$disable_numa" != "yes" && compile_prog "" "-lnuma" "libnuma"; then
67bf9823
JA
1325 libnuma="yes"
1326 LIBS="-lnuma $LIBS"
1327fi
484b0b65 1328print_config "libnuma" "$libnuma"
67bf9823 1329
50206d9b 1330##########################################
ca205a75 1331# libnuma 2.x version API, initialize with "no" only if $libnuma is set to "yes"
50206d9b
JA
1332if test "$libnuma" = "yes" ; then
1333libnuma_v2="no"
1334cat > $TMPC << EOF
1335#include <numa.h>
1336int main(int argc, char **argv)
1337{
1338 struct bitmask *mask = numa_parse_nodestring(NULL);
61bde962 1339 return mask->size == 0;
50206d9b
JA
1340}
1341EOF
1342if compile_prog "" "" "libnuma api"; then
1343 libnuma_v2="yes"
1344fi
484b0b65 1345print_config "libnuma v2" "$libnuma_v2"
50206d9b
JA
1346fi
1347
67bf9823
JA
1348##########################################
1349# strsep() probe
ca205a75
TK
1350if test "$strsep" != "yes" ; then
1351 strsep="no"
1352fi
67bf9823
JA
1353cat > $TMPC << EOF
1354#include <string.h>
1355int main(int argc, char **argv)
1356{
ae156be6
JA
1357 static char *string = "This is a string";
1358 strsep(&string, "needle");
67bf9823
JA
1359 return 0;
1360}
1361EOF
1362if compile_prog "" "" "strsep"; then
1363 strsep="yes"
1364fi
484b0b65 1365print_config "strsep" "$strsep"
67bf9823 1366
9ad8da82
JA
1367##########################################
1368# strcasestr() probe
ca205a75
TK
1369if test "$strcasestr" != "yes" ; then
1370 strcasestr="no"
1371fi
9ad8da82
JA
1372cat > $TMPC << EOF
1373#include <string.h>
1374int main(int argc, char **argv)
1375{
aa6738a5 1376 return strcasestr(argv[0], argv[1]) != NULL;
9ad8da82
JA
1377}
1378EOF
1379if compile_prog "" "" "strcasestr"; then
1380 strcasestr="yes"
1381fi
484b0b65 1382print_config "strcasestr" "$strcasestr"
9ad8da82 1383
5ad7be56
KD
1384##########################################
1385# strlcat() probe
ca205a75
TK
1386if test "$strlcat" != "yes" ; then
1387 strlcat="no"
1388fi
5ad7be56
KD
1389cat > $TMPC << EOF
1390#include <string.h>
1391int main(int argc, char **argv)
1392{
1393 static char dst[64];
1394 static char *string = "This is a string";
1395 memset(dst, 0, sizeof(dst));
1396 strlcat(dst, string, sizeof(dst));
1397 return 0;
1398}
1399EOF
1400if compile_prog "" "" "strlcat"; then
1401 strlcat="yes"
1402fi
484b0b65 1403print_config "strlcat" "$strlcat"
5ad7be56 1404
67bf9823
JA
1405##########################################
1406# getopt_long_only() probe
ca205a75
TK
1407if test "$getopt_long_only" != "yes" ; then
1408 getopt_long_only="no"
1409fi
67bf9823
JA
1410cat > $TMPC << EOF
1411#include <unistd.h>
1412#include <stdio.h>
aa6738a5 1413#include <getopt.h>
67bf9823
JA
1414int main(int argc, char **argv)
1415{
d24ff97d 1416 int c = getopt_long_only(argc, argv, "", NULL, NULL);
67bf9823
JA
1417 return c;
1418}
1419EOF
1420if compile_prog "" "" "getopt_long_only"; then
1421 getopt_long_only="yes"
1422fi
484b0b65 1423print_config "getopt_long_only()" "$getopt_long_only"
67bf9823
JA
1424
1425##########################################
1426# inet_aton() probe
ca205a75
TK
1427if test "$inet_aton" != "yes" ; then
1428 inet_aton="no"
1429fi
67bf9823 1430cat > $TMPC << EOF
a932a2cf
BVA
1431#ifdef _WIN32
1432#include <winsock2.h>
1433#else
67bf9823
JA
1434#include <sys/socket.h>
1435#include <arpa/inet.h>
a932a2cf 1436#endif
67bf9823
JA
1437#include <stdio.h>
1438int main(int argc, char **argv)
1439{
1440 struct in_addr in;
1441 return inet_aton(NULL, &in);
1442}
1443EOF
1444if compile_prog "" "" "inet_aton"; then
1445 inet_aton="yes"
1446fi
484b0b65 1447print_config "inet_aton" "$inet_aton"
67bf9823
JA
1448
1449##########################################
1450# socklen_t probe
ca205a75
TK
1451if test "$socklen_t" != "yes" ; then
1452 socklen_t="no"
1453fi
67bf9823 1454cat > $TMPC << EOF
a932a2cf
BVA
1455#ifdef _WIN32
1456#include <winsock2.h>
1457#include <ws2tcpip.h>
1458#else
f6482613 1459#include <sys/socket.h>
a932a2cf 1460#endif
67bf9823
JA
1461int main(int argc, char **argv)
1462{
1463 socklen_t len = 0;
1464 return len;
1465}
1466EOF
1467if compile_prog "" "" "socklen_t"; then
1468 socklen_t="yes"
1469fi
484b0b65 1470print_config "socklen_t" "$socklen_t"
67bf9823
JA
1471
1472##########################################
1473# Whether or not __thread is supported for TLS
ca205a75
TK
1474if test "$tls_thread" != "yes" ; then
1475 tls_thread="no"
1476fi
67bf9823
JA
1477cat > $TMPC << EOF
1478#include <stdio.h>
aa6738a5 1479static __thread int ret;
67bf9823
JA
1480int main(int argc, char **argv)
1481{
1482 return ret;
1483}
1484EOF
1485if compile_prog "" "" "__thread"; then
1486 tls_thread="yes"
1487fi
484b0b65 1488print_config "__thread" "$tls_thread"
67bf9823 1489
91f94d5b 1490##########################################
2639f056 1491# Check if we have required gtk/glib support for gfio
ca205a75
TK
1492if test "$gfio" != "yes" ; then
1493 gfio="no"
1494fi
ebec2094 1495if test "$gfio_check" = "yes" ; then
91f94d5b
JA
1496 cat > $TMPC << EOF
1497#include <glib.h>
1498#include <cairo.h>
1499#include <gtk/gtk.h>
1500int main(void)
1501{
1502 gdk_threads_enter();
91f94d5b 1503 gdk_threads_leave();
b7a99316 1504
ef2b61aa 1505 return GTK_CHECK_VERSION(2, 18, 0) ? 0 : 1; /* 0 on success */
91f94d5b
JA
1506}
1507EOF
4d1bc43e 1508GTK_CFLAGS=$(${cross_prefix}pkg-config --cflags gtk+-2.0 gthread-2.0)
86719845
JA
1509ORG_LDFLAGS=$LDFLAGS
1510LDFLAGS=$(echo $LDFLAGS | sed s/"-static"//g)
91f94d5b
JA
1511if test "$?" != "0" ; then
1512 echo "configure: gtk and gthread not found"
1513 exit 1
1514fi
4d1bc43e 1515GTK_LIBS=$(${cross_prefix}pkg-config --libs gtk+-2.0 gthread-2.0)
91f94d5b
JA
1516if test "$?" != "0" ; then
1517 echo "configure: gtk and gthread not found"
1518 exit 1
1519fi
31ce8438
HG
1520if ! ${cross_prefix}pkg-config --atleast-version 2.18.0 gtk+-2.0; then
1521 echo "GTK found, but need version 2.18 or higher"
1522 gfio="no"
1523else
1524 if compile_prog "$GTK_CFLAGS" "$GTK_LIBS" "gfio" ; then
b7a99316 1525 gfio="yes"
86719845 1526 GFIO_LIBS="$LIBS $GTK_LIBS"
b7a99316
JA
1527 CFLAGS="$CFLAGS $GTK_CFLAGS"
1528 else
31ce8438 1529 echo "Please install gtk and gdk libraries"
b7a99316
JA
1530 gfio="no"
1531 fi
91f94d5b 1532fi
86719845 1533LDFLAGS=$ORG_LDFLAGS
91f94d5b
JA
1534fi
1535
ebec2094 1536if test "$gfio_check" = "yes" ; then
484b0b65 1537 print_config "gtk 2.18 or higher" "$gfio"
ebec2094 1538fi
91f94d5b 1539
bda92394 1540##########################################
44404c5a 1541# Check whether we have getrusage(RUSAGE_THREAD)
ca205a75
TK
1542if test "$rusage_thread" != "yes" ; then
1543 rusage_thread="no"
1544fi
44404c5a
JA
1545cat > $TMPC << EOF
1546#include <sys/time.h>
1547#include <sys/resource.h>
1548int main(int argc, char **argv)
1549{
1550 struct rusage ru;
1551 getrusage(RUSAGE_THREAD, &ru);
1552 return 0;
1553}
1554EOF
1555if compile_prog "" "" "RUSAGE_THREAD"; then
1556 rusage_thread="yes"
1557fi
484b0b65 1558print_config "RUSAGE_THREAD" "$rusage_thread"
44404c5a 1559
7e09a9f1
JA
1560##########################################
1561# Check whether we have SCHED_IDLE
ca205a75
TK
1562if test "$sched_idle" != "yes" ; then
1563 sched_idle="no"
1564fi
7e09a9f1
JA
1565cat > $TMPC << EOF
1566#include <sched.h>
1567int main(int argc, char **argv)
1568{
1569 struct sched_param p;
1570 return sched_setscheduler(0, SCHED_IDLE, &p);
1571}
1572EOF
1573if compile_prog "" "" "SCHED_IDLE"; then
1574 sched_idle="yes"
1575fi
484b0b65 1576print_config "SCHED_IDLE" "$sched_idle"
7e09a9f1 1577
1eafa37a
JA
1578##########################################
1579# Check whether we have TCP_NODELAY
ca205a75
TK
1580if test "$tcp_nodelay" != "yes" ; then
1581 tcp_nodelay="no"
1582fi
1eafa37a 1583cat > $TMPC << EOF
a932a2cf
BVA
1584#ifdef _WIN32
1585#include <winsock2.h>
1586#else
1eafa37a
JA
1587#include <stdio.h>
1588#include <sys/types.h>
1589#include <sys/socket.h>
1590#include <netinet/tcp.h>
a932a2cf 1591#endif
1eafa37a
JA
1592int main(int argc, char **argv)
1593{
1594 return getsockopt(0, 0, TCP_NODELAY, NULL, NULL);
1595}
1596EOF
1597if compile_prog "" "" "TCP_NODELAY"; then
1598 tcp_nodelay="yes"
a932a2cf
BVA
1599elif compile_prog "" "-lws2_32" "TCP_NODELAY"; then
1600 tcp_nodelay="yes"
1601 LIBS="$LIBS -lws2_32"
1eafa37a 1602fi
484b0b65 1603print_config "TCP_NODELAY" "$tcp_nodelay"
1eafa37a 1604
1008602c
JA
1605##########################################
1606# Check whether we have SO_SNDBUF
ca205a75
TK
1607if test "$window_size" != "yes" ; then
1608 window_size="no"
1609fi
1008602c 1610cat > $TMPC << EOF
a932a2cf
BVA
1611#ifdef _WIN32
1612#include <winsock2.h>
1613#else
1008602c
JA
1614#include <stdio.h>
1615#include <sys/types.h>
1616#include <sys/socket.h>
1617#include <netinet/tcp.h>
a932a2cf 1618#endif
1008602c
JA
1619int main(int argc, char **argv)
1620{
1621 setsockopt(0, SOL_SOCKET, SO_SNDBUF, NULL, 0);
1622 setsockopt(0, SOL_SOCKET, SO_RCVBUF, NULL, 0);
1623}
1624EOF
1625if compile_prog "" "" "SO_SNDBUF"; then
1626 window_size="yes"
a932a2cf
BVA
1627elif compile_prog "" "-lws2_32" "SO_SNDBUF"; then
1628 window_size="yes"
1629 LIBS="$LIBS -lws2_32"
1008602c 1630fi
484b0b65 1631print_config "Net engine window_size" "$window_size"
1008602c 1632
e5f34d95
JA
1633##########################################
1634# Check whether we have TCP_MAXSEG
ca205a75
TK
1635if test "$mss" != "yes" ; then
1636 mss="no"
1637fi
e5f34d95 1638cat > $TMPC << EOF
a932a2cf
BVA
1639#ifdef _WIN32
1640#include <winsock2.h>
1641#else
e5f34d95
JA
1642#include <stdio.h>
1643#include <sys/types.h>
1644#include <sys/socket.h>
1645#include <netinet/tcp.h>
1646#include <arpa/inet.h>
1647#include <netinet/in.h>
a932a2cf 1648#endif
e5f34d95
JA
1649int main(int argc, char **argv)
1650{
1651 return setsockopt(0, IPPROTO_TCP, TCP_MAXSEG, NULL, 0);
1652}
1653EOF
1654if compile_prog "" "" "TCP_MAXSEG"; then
1655 mss="yes"
a932a2cf
BVA
1656elif compile_prog "" "-lws2_32" "TCP_MAXSEG"; then
1657 mss="yes"
1658 LIBS="$LIBS -lws2_32"
e5f34d95 1659fi
484b0b65 1660print_config "TCP_MAXSEG" "$mss"
e5f34d95 1661
38b9354a
JA
1662##########################################
1663# Check whether we have RLIMIT_MEMLOCK
ca205a75
TK
1664if test "$rlimit_memlock" != "yes" ; then
1665 rlimit_memlock="no"
1666fi
38b9354a
JA
1667cat > $TMPC << EOF
1668#include <sys/time.h>
1669#include <sys/resource.h>
1670int main(int argc, char **argv)
1671{
1672 struct rlimit rl;
1673 return getrlimit(RLIMIT_MEMLOCK, &rl);
1674}
1675EOF
1676if compile_prog "" "" "RLIMIT_MEMLOCK"; then
1677 rlimit_memlock="yes"
1678fi
484b0b65 1679print_config "RLIMIT_MEMLOCK" "$rlimit_memlock"
38b9354a 1680
07fc0acd
JA
1681##########################################
1682# Check whether we have pwritev/preadv
ca205a75
TK
1683if test "$pwritev" != "yes" ; then
1684 pwritev="no"
1685fi
07fc0acd
JA
1686cat > $TMPC << EOF
1687#include <stdio.h>
1688#include <sys/uio.h>
1689int main(int argc, char **argv)
1690{
1691 return pwritev(0, NULL, 1, 0) + preadv(0, NULL, 1, 0);
1692}
1693EOF
1694if compile_prog "" "" "pwritev"; then
1695 pwritev="yes"
1696fi
484b0b65 1697print_config "pwritev/preadv" "$pwritev"
07fc0acd 1698
2cafffbe
JA
1699##########################################
1700# Check whether we have pwritev2/preadv2
ca205a75
TK
1701if test "$pwritev2" != "yes" ; then
1702 pwritev2="no"
1703fi
2cafffbe
JA
1704cat > $TMPC << EOF
1705#include <stdio.h>
1706#include <sys/uio.h>
1707int main(int argc, char **argv)
1708{
1709 return pwritev2(0, NULL, 1, 0, 0) + preadv2(0, NULL, 1, 0, 0);
1710}
1711EOF
1712if compile_prog "" "" "pwritev2"; then
1713 pwritev2="yes"
1714fi
484b0b65 1715print_config "pwritev2/preadv2" "$pwritev2"
2cafffbe 1716
ecad55e9
JA
1717##########################################
1718# Check whether we have the required functions for ipv6
ca205a75
TK
1719if test "$ipv6" != "yes" ; then
1720 ipv6="no"
1721fi
ecad55e9 1722cat > $TMPC << EOF
a932a2cf
BVA
1723#ifdef _WIN32
1724#include <winsock2.h>
1725#include <ws2tcpip.h>
1726#else
ecad55e9
JA
1727#include <sys/types.h>
1728#include <sys/socket.h>
d219028d 1729#include <netinet/in.h>
ecad55e9 1730#include <netdb.h>
a932a2cf 1731#endif
ecad55e9
JA
1732#include <stdio.h>
1733int main(int argc, char **argv)
1734{
1735 struct addrinfo hints;
1736 struct in6_addr addr;
1737 int ret;
1738
1739 ret = getaddrinfo(NULL, NULL, &hints, NULL);
1740 freeaddrinfo(NULL);
1741 printf("%s\n", gai_strerror(ret));
1742 addr = in6addr_any;
1743 return 0;
1744}
1745EOF
1746if compile_prog "" "" "ipv6"; then
1747 ipv6="yes"
1748fi
484b0b65 1749print_config "IPv6 helpers" "$ipv6"
07fc0acd 1750
c2f6a13d
LMB
1751##########################################
1752# check for http
1753if test "$http" != "yes" ; then
1754 http="no"
1755fi
9ee669fa
DD
1756# check for openssl >= 1.1.0, which uses an opaque HMAC_CTX pointer
1757cat > $TMPC << EOF
1758#include <curl/curl.h>
1759#include <openssl/hmac.h>
1760
1761int main(int argc, char **argv)
1762{
1763 CURL *curl;
1764 HMAC_CTX *ctx;
1765
1766 curl = curl_easy_init();
1767 curl_easy_cleanup(curl);
1768
1769 ctx = HMAC_CTX_new();
1770 HMAC_CTX_reset(ctx);
1771 HMAC_CTX_free(ctx);
1772 return 0;
1773}
1774EOF
1775# openssl < 1.1.0 uses the HMAC_CTX type directly
1776cat > $TMPC2 << EOF
1777#include <curl/curl.h>
1778#include <openssl/hmac.h>
1779
1780int main(int argc, char **argv)
1781{
1782 CURL *curl;
1783 HMAC_CTX ctx;
1784
1785 curl = curl_easy_init();
1786 curl_easy_cleanup(curl);
1787
1788 HMAC_CTX_init(&ctx);
1789 HMAC_CTX_cleanup(&ctx);
1790 return 0;
1791}
1792EOF
1793if test "$disable_http" != "yes"; then
1794 HTTP_LIBS="-lcurl -lssl -lcrypto"
1795 if compile_prog "" "$HTTP_LIBS" "curl-new-ssl"; then
b61a5f46 1796 output_sym "CONFIG_HAVE_OPAQUE_HMAC_CTX"
9ee669fa 1797 http="yes"
9ee669fa
DD
1798 elif mv $TMPC2 $TMPC && compile_prog "" "$HTTP_LIBS" "curl-old-ssl"; then
1799 http="yes"
0290c589 1800 fi
c2f6a13d
LMB
1801fi
1802print_config "http engine" "$http"
1803
d5f9b0ea
IF
1804##########################################
1805# check for rados
1806if test "$rados" != "yes" ; then
1807 rados="no"
1808fi
1809cat > $TMPC << EOF
1810#include <rados/librados.h>
1811
1812int main(int argc, char **argv)
1813{
1814 rados_t cluster;
1815 rados_ioctx_t io_ctx;
1816 const char cluster_name[] = "ceph";
1817 const char user_name[] = "client.admin";
1818 const char pool[] = "rados";
1819
1820 /* The rados_create2 signature required was only introduced in ceph 0.65 */
1821 rados_create2(&cluster, cluster_name, user_name, 0);
1822 rados_ioctx_create(cluster, pool, &io_ctx);
1823
1824 return 0;
1825}
1826EOF
1827if test "$disable_rados" != "yes" && compile_prog "" "-lrados" "rados"; then
d5f9b0ea
IF
1828 rados="yes"
1829fi
1830print_config "Rados engine" "$rados"
1831
fc5c0345
DG
1832##########################################
1833# check for rbd
ca205a75
TK
1834if test "$rbd" != "yes" ; then
1835 rbd="no"
1836fi
fc5c0345
DG
1837cat > $TMPC << EOF
1838#include <rbd/librbd.h>
1839
1840int main(int argc, char **argv)
1841{
fc5c0345
DG
1842 rados_t cluster;
1843 rados_ioctx_t io_ctx;
fb9bc6e3
SW
1844 const char cluster_name[] = "ceph";
1845 const char user_name[] = "client.admin";
fc5c0345 1846 const char pool[] = "rbd";
fc5c0345 1847 int major, minor, extra;
fc5c0345 1848
fb9bc6e3
SW
1849 rbd_version(&major, &minor, &extra);
1850 /* The rados_create2 signature required was only introduced in ceph 0.65 */
1851 rados_create2(&cluster, cluster_name, user_name, 0);
fc5c0345 1852 rados_ioctx_create(cluster, pool, &io_ctx);
fb9bc6e3 1853
fc5c0345
DG
1854 return 0;
1855}
1856EOF
ce18290e 1857if test "$disable_rbd" != "yes" && compile_prog "" "-lrbd -lrados" "rbd"; then
fc5c0345
DG
1858 rbd="yes"
1859fi
484b0b65 1860print_config "Rados Block Device engine" "$rbd"
fc5c0345 1861
53b6c979
PL
1862##########################################
1863# check for rbd_poll
ca205a75
TK
1864if test "$rbd_poll" != "yes" ; then
1865 rbd_poll="no"
1866fi
53b6c979
PL
1867if test "$rbd" = "yes"; then
1868cat > $TMPC << EOF
1869#include <rbd/librbd.h>
1870#include <sys/eventfd.h>
1871
1872int main(int argc, char **argv)
1873{
1874 rbd_image_t image;
1875 rbd_completion_t comp;
1876
1877 int fd = eventfd(0, EFD_NONBLOCK);
1878 rbd_set_image_notification(image, fd, EVENT_TYPE_EVENTFD);
1879 rbd_poll_io_events(image, comp, 1);
1880
1881 return 0;
1882}
1883EOF
1884if compile_prog "" "-lrbd -lrados" "rbd"; then
1885 rbd_poll="yes"
1886fi
484b0b65 1887print_config "rbd_poll" "$rbd_poll"
53b6c979
PL
1888fi
1889
903b2812 1890##########################################
6266dd72 1891# check for rbd_invalidate_cache()
ca205a75
TK
1892if test "$rbd_inval" != "yes" ; then
1893 rbd_inval="no"
1894fi
903b2812
JA
1895if test "$rbd" = "yes"; then
1896cat > $TMPC << EOF
1897#include <rbd/librbd.h>
1898
1899int main(int argc, char **argv)
1900{
1901 rbd_image_t image;
1902
1903 return rbd_invalidate_cache(image);
1904}
1905EOF
1906if compile_prog "" "-lrbd -lrados" "rbd"; then
1907 rbd_inval="yes"
1908fi
484b0b65 1909print_config "rbd_invalidate_cache" "$rbd_inval"
903b2812
JA
1910fi
1911
2e802282
JA
1912##########################################
1913# Check whether we have setvbuf
ca205a75
TK
1914if test "$setvbuf" != "yes" ; then
1915 setvbuf="no"
1916fi
2e802282
JA
1917cat > $TMPC << EOF
1918#include <stdio.h>
1919int main(int argc, char **argv)
1920{
1921 FILE *f = NULL;
1922 char buf[80];
1923 setvbuf(f, buf, _IOFBF, sizeof(buf));
1924 return 0;
1925}
1926EOF
1927if compile_prog "" "" "setvbuf"; then
1928 setvbuf="yes"
1929fi
484b0b65 1930print_config "setvbuf" "$setvbuf"
fc5c0345 1931
bda92394 1932##########################################
6e7d7dfb 1933# check for gfapi
ca205a75
TK
1934if test "$gfapi" != "yes" ; then
1935 gfapi="no"
1936fi
6e7d7dfb 1937cat > $TMPC << EOF
1938#include <glusterfs/api/glfs.h>
1939
1940int main(int argc, char **argv)
1941{
6e7d7dfb 1942 glfs_t *g = glfs_new("foo");
1943
1944 return 0;
1945}
1946EOF
ce18290e 1947if test "$disable_gfapi" != "yes" && compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
6e7d7dfb 1948 gfapi="yes"
1949fi
484b0b65 1950print_config "Gluster API engine" "$gfapi"
6e7d7dfb 1951
6fa14b99 1952##########################################
ca205a75 1953# check for gfapi fadvise support, initialize with "no" only if $gfapi is set to "yes"
6876c98c 1954if test "$gfapi" = "yes" ; then
6fa14b99 1955gf_fadvise="no"
1956cat > $TMPC << EOF
1957#include <glusterfs/api/glfs.h>
1958
1959int main(int argc, char **argv)
1960{
1961 struct glfs_fd *fd;
1962 int ret = glfs_fadvise(fd, 0, 0, 1);
1963
1964 return 0;
1965}
1966EOF
6fa14b99 1967if compile_prog "" "-lgfapi -lglusterfs" "gfapi"; then
1968 gf_fadvise="yes"
1969fi
484b0b65 1970print_config "Gluster API use fadvise" "$gf_fadvise"
6876c98c
JA
1971fi
1972
ce4d13ca
JA
1973##########################################
1974# check for newer gfapi
1975if test "$gfapi" = "yes" ; then
1976gf_new="no"
1977cat > $TMPC << EOF
1978#include <glusterfs/api/glfs.h>
1979
1980int main(int argc, char **argv)
1981{
1982 return glfs_fsync(NULL, NULL, NULL) && glfs_ftruncate(NULL, 0, NULL, NULL);
1983}
1984EOF
1985if compile_prog "" "-lgfapi -lglusterfs" "gf new api"; then
1986 gf_new="yes"
1987fi
1988print_config "Gluster new API" "$gf_new"
1989fi
1990
6876c98c
JA
1991##########################################
1992# check for gfapi trim support
ca205a75
TK
1993if test "$gf_trim" != "yes" ; then
1994 gf_trim="no"
1995fi
6876c98c
JA
1996if test "$gfapi" = "yes" ; then
1997cat > $TMPC << EOF
1998#include <glusterfs/api/glfs.h>
1999
2000int main(int argc, char **argv)
2001{
2002 return glfs_discard_async(NULL, 0, 0);
2003}
2004EOF
2005if compile_prog "" "-lgfapi -lglusterfs" "gf trim"; then
2006 gf_trim="yes"
2007fi
484b0b65 2008print_config "Gluster API trim support" "$gf_trim"
6876c98c 2009fi
fc5c0345 2010
81795ce3
CE
2011##########################################
2012# Check if we support stckf on s390
ca205a75
TK
2013if test "$s390_z196_facilities" != "yes" ; then
2014 s390_z196_facilities="no"
2015fi
81795ce3
CE
2016cat > $TMPC << EOF
2017#define STFLE_BITS_Z196 45 /* various z196 facilities ... */
2018int main(int argc, char **argv)
2019{
2020 /* We want just 1 double word to be returned. */
2021 register unsigned long reg0 asm("0") = 0;
2022 unsigned long stfle_bits;
2023 asm volatile(".machine push" "\n\t"
2024 ".machine \"z9-109\"" "\n\t"
2025 "stfle %0" "\n\t"
2026 ".machine pop" "\n"
2027 : "=QS" (stfle_bits), "+d" (reg0)
2028 : : "cc");
2029
2030 if ((stfle_bits & (1UL << (63 - STFLE_BITS_Z196))) != 0)
2031 return 0;
2032 else
2033 return -1;
2034}
2035EOF
2036if compile_prog "" "" "s390_z196_facilities"; then
2037 $TMPE
6a2c9363 2038 if [ $? -eq 0 ]; then
81795ce3
CE
2039 s390_z196_facilities="yes"
2040 fi
2041fi
484b0b65 2042print_config "s390_z196_facilities" "$s390_z196_facilities"
1b10477b
MM
2043
2044##########################################
2045# Check if we have required environment variables configured for libhdfs
2046if test "$libhdfs" = "yes" ; then
2047 hdfs_conf_error=0
2048 if test "$JAVA_HOME" = "" ; then
2049 echo "configure: JAVA_HOME should be defined to jdk/jvm path"
2050 hdfs_conf_error=1
2051 fi
2052 if test "$FIO_LIBHDFS_INCLUDE" = "" ; then
2053 echo "configure: FIO_LIBHDFS_INCLUDE should be defined to libhdfs inlude path"
2054 hdfs_conf_error=1
2055 fi
2056 if test "$FIO_LIBHDFS_LIB" = "" ; then
2057 echo "configure: FIO_LIBHDFS_LIB should be defined to libhdfs library path"
2058 hdfs_conf_error=1
2059 fi
2060 if test "$hdfs_conf_error" = "1" ; then
d490af7f 2061 feature_not_found "libhdfs" ""
1b10477b 2062 fi
247e5436
JA
2063 FIO_HDFS_CPU=$cpu
2064 if test "$FIO_HDFS_CPU" = "x86_64" ; then
2065 FIO_HDFS_CPU="amd64"
2066 fi
1b10477b 2067fi
484b0b65 2068print_config "HDFS engine" "$libhdfs"
1b10477b 2069
b8116a87
DE
2070##########################################
2071# Check whether we have MTD
ca205a75
TK
2072if test "$mtd" != "yes" ; then
2073 mtd="no"
2074fi
b8116a87 2075cat > $TMPC << EOF
0e1c454a 2076#include <string.h>
b8116a87
DE
2077#include <mtd/mtd-user.h>
2078#include <sys/ioctl.h>
2079int main(int argc, char **argv)
2080{
0e1c454a 2081 struct mtd_write_req ops;
b8116a87 2082 struct mtd_info_user info;
0e1c454a 2083 memset(&ops, 0, sizeof(ops));
400cd0ff 2084 info.type = MTD_MLCNANDFLASH;
b8116a87
DE
2085 return ioctl(0, MEMGETINFO, &info);
2086}
2087EOF
2088if compile_prog "" "" "mtd"; then
2089 mtd="yes"
2090fi
484b0b65 2091print_config "MTD" "$mtd"
b8116a87 2092
3ee2a3c1
DJ
2093##########################################
2094# Check whether we have libpmem
ca205a75
TK
2095if test "$libpmem" != "yes" ; then
2096 libpmem="no"
2097fi
3ee2a3c1
DJ
2098cat > $TMPC << EOF
2099#include <libpmem.h>
2100int main(int argc, char **argv)
2101{
2102 int rc;
2103 rc = pmem_is_pmem(0, 0);
2104 return 0;
2105}
2106EOF
2107if compile_prog "" "-lpmem" "libpmem"; then
2108 libpmem="yes"
2109fi
484b0b65 2110print_config "libpmem" "$libpmem"
3ee2a3c1
DJ
2111
2112##########################################
2113# Check whether we have libpmemblk
cf8775b8 2114# libpmem is a prerequisite
ca205a75
TK
2115if test "$libpmemblk" != "yes" ; then
2116 libpmemblk="no"
2117fi
cf8775b8
RE
2118if test "$libpmem" = "yes"; then
2119 cat > $TMPC << EOF
3ee2a3c1
DJ
2120#include <libpmemblk.h>
2121int main(int argc, char **argv)
2122{
cf8775b8
RE
2123 PMEMblkpool *pbp;
2124 pbp = pmemblk_open("", 0);
3ee2a3c1
DJ
2125 return 0;
2126}
2127EOF
cf8775b8
RE
2128 if compile_prog "" "-lpmemblk" "libpmemblk"; then
2129 libpmemblk="yes"
cf8775b8 2130 fi
3ee2a3c1 2131fi
484b0b65 2132print_config "libpmemblk" "$libpmemblk"
3ee2a3c1 2133
cf8775b8 2134# Choose the ioengines
3ee2a3c1 2135if test "$libpmem" = "yes" && test "$disable_pmem" = "no"; then
ae0db592 2136 pmem="yes"
3ee2a3c1
DJ
2137 devdax="yes"
2138 if test "$libpmemblk" = "yes"; then
2139 pmemblk="yes"
2140 fi
2141fi
2142
43f3cec2
BB
2143##########################################
2144# Report whether pmemblk engine is enabled
363a5f65 2145print_config "PMDK pmemblk engine" "$pmemblk"
43f3cec2 2146
cbb15e42
DJ
2147##########################################
2148# Report whether dev-dax engine is enabled
363a5f65 2149print_config "PMDK dev-dax engine" "$devdax"
cbb15e42 2150
ae0db592
TI
2151##########################################
2152# Report whether libpmem engine is enabled
363a5f65 2153print_config "PMDK libpmem engine" "$pmem"
ae0db592 2154
a40e7a59
GB
2155##########################################
2156# Check whether we support DDN's IME
2157if test "$libime" != "yes" ; then
2158 libime="no"
2159fi
2160cat > $TMPC << EOF
2161#include <ime_native.h>
2162int main(int argc, char **argv)
2163{
2164 int rc;
2165 ime_native_init();
2166 rc = ime_native_finalize();
2167 return 0;
2168}
2169EOF
2170if compile_prog "-I${ime_path}/include" "-L${ime_path}/lib -lim_client" "libime"; then
2171 libime="yes"
2172 CFLAGS="-I${ime_path}/include $CFLAGS"
2173 LDFLAGS="-Wl,-rpath ${ime_path}/lib -L${ime_path}/lib $LDFLAGS"
2174 LIBS="-lim_client $LIBS"
2175fi
2176print_config "DDN's Infinite Memory Engine" "$libime"
2177
247ef2aa 2178##########################################
d490af7f
SW
2179# Check if we have libiscsi
2180if test "$libiscsi" != "no" ; then
2181 minimum_libiscsi=1.9.0
2182 if $(pkg-config --atleast-version=$minimum_libiscsi libiscsi); then
247ef2aa
KZ
2183 libiscsi="yes"
2184 libiscsi_cflags=$(pkg-config --cflags libiscsi)
2185 libiscsi_libs=$(pkg-config --libs libiscsi)
2186 else
2187 if test "$libiscsi" = "yes" ; then
d490af7f 2188 feature_not_found "libiscsi" "libiscsi >= $minimum_libiscsi"
247ef2aa
KZ
2189 fi
2190 libiscsi="no"
2191 fi
2192fi
2193print_config "iscsi engine" "$libiscsi"
2194
d643a1e2 2195##########################################
d490af7f
SW
2196# Check if we have libnbd (for NBD support)
2197if test "$libnbd" != "no" ; then
2198 minimum_libnbd=0.9.8
d643a1e2
RJ
2199 if $(pkg-config --atleast-version=$minimum_libnbd libnbd); then
2200 libnbd="yes"
2201 libnbd_cflags=$(pkg-config --cflags libnbd)
2202 libnbd_libs=$(pkg-config --libs libnbd)
2203 else
2204 if test "$libnbd" = "yes" ; then
d490af7f 2205 feature_not_found "libnbd" "libnbd >= $minimum_libnbd"
d643a1e2
RJ
2206 fi
2207 libnbd="no"
2208 fi
2209fi
2210print_config "NBD engine" "$libnbd"
2211
bda92394 2212##########################################
b470a02c
SC
2213# Check if we have lex/yacc available
2214yacc="no"
e7b2c7a3 2215yacc_is_bison="no"
b470a02c
SC
2216lex="no"
2217arith="no"
de26b824 2218if test "$disable_lex" = "no" || test -z "$disable_lex" ; then
cf6dd80e 2219if test "$targetos" != "SunOS" ; then
e7b2c7a3 2220LEX=$(which lex 2> /dev/null)
b470a02c
SC
2221if test -x "$LEX" ; then
2222 lex="yes"
2223fi
7e0049e9 2224YACC=$(which bison 2> /dev/null)
b470a02c
SC
2225if test -x "$YACC" ; then
2226 yacc="yes"
7e0049e9 2227 yacc_is_bison="yes"
e7b2c7a3 2228else
7e0049e9 2229 YACC=$(which yacc 2> /dev/null)
e7b2c7a3
JA
2230 if test -x "$YACC" ; then
2231 yacc="yes"
e7b2c7a3 2232 fi
b470a02c
SC
2233fi
2234if test "$yacc" = "yes" && test "$lex" = "yes" ; then
2235 arith="yes"
2236fi
2237
2238if test "$arith" = "yes" ; then
2239cat > $TMPC << EOF
2240extern int yywrap(void);
2241
2242int main(int argc, char **argv)
2243{
2244 yywrap();
2245 return 0;
2246}
2247EOF
719cda03
JA
2248if compile_prog "" "-ll" "lex"; then
2249 LIBS="-ll $LIBS"
b470a02c
SC
2250else
2251 arith="no"
2252fi
2253fi
cf6dd80e 2254fi
a655bbc4 2255fi
b470a02c 2256
63bda378
JA
2257# Check if lex fails using -o
2258if test "$arith" = "yes" ; then
daf705b5
JA
2259if test "$force_no_lex_o" = "yes" ; then
2260 lex_use_o="no"
2261else
63bda378
JA
2262$LEX -o lex.yy.c exp/expression-parser.l 2> /dev/null
2263if test "$?" = "0" ; then
2264 lex_use_o="yes"
2265else
2266 lex_use_o="no"
2267fi
2268fi
daf705b5 2269fi
63bda378 2270
484b0b65 2271print_config "lex/yacc for arithmetic" "$arith"
b470a02c 2272
aae599ba
JA
2273##########################################
2274# Check whether we have setmntent/getmntent
ca205a75
TK
2275if test "$getmntent" != "yes" ; then
2276 getmntent="no"
2277fi
aae599ba
JA
2278cat > $TMPC << EOF
2279#include <stdio.h>
2280#include <mntent.h>
2281int main(int argc, char **argv)
2282{
2283 FILE *mtab = setmntent(NULL, "r");
2284 struct mntent *mnt = getmntent(mtab);
1581b82a 2285 endmntent(mtab);
aae599ba
JA
2286 return 0;
2287}
2288EOF
2289if compile_prog "" "" "getmntent"; then
2290 getmntent="yes"
2291fi
484b0b65 2292print_config "getmntent" "$getmntent"
aae599ba 2293
e7e136da
TK
2294##########################################
2295# Check whether we have getmntinfo
b765bec0
TK
2296# These are originally added for BSDs, but may also work
2297# on other operating systems with getmntinfo(3).
2298
2299# getmntinfo(3) for FreeBSD/DragonFlyBSD/OpenBSD.
2300# Note that NetBSD needs -Werror to catch warning as error.
ca205a75
TK
2301if test "$getmntinfo" != "yes" ; then
2302 getmntinfo="no"
2303fi
e7e136da
TK
2304cat > $TMPC << EOF
2305#include <stdio.h>
2306#include <sys/param.h>
2307#include <sys/mount.h>
2308int main(int argc, char **argv)
2309{
9ada751d 2310 struct statfs *st;
e7e136da
TK
2311 return getmntinfo(&st, MNT_NOWAIT);
2312}
2313EOF
b765bec0 2314if compile_prog "-Werror" "" "getmntinfo"; then
e7e136da
TK
2315 getmntinfo="yes"
2316fi
484b0b65 2317print_config "getmntinfo" "$getmntinfo"
e7e136da 2318
b765bec0 2319# getmntinfo(3) for NetBSD.
ca205a75
TK
2320if test "$getmntinfo_statvfs" != "yes" ; then
2321 getmntinfo_statvfs="no"
2322fi
b765bec0
TK
2323cat > $TMPC << EOF
2324#include <stdio.h>
2325#include <sys/statvfs.h>
2326int main(int argc, char **argv)
2327{
2328 struct statvfs *st;
2329 return getmntinfo(&st, MNT_NOWAIT);
2330}
2331EOF
2332# Skip the test if the one with statfs arg is detected.
2333if test "$getmntinfo" != "yes" && compile_prog "-Werror" "" "getmntinfo_statvfs"; then
2334 getmntinfo_statvfs="yes"
484b0b65 2335 print_config "getmntinfo_statvfs" "$getmntinfo_statvfs"
b765bec0
TK
2336fi
2337
5018f79f
AH
2338##########################################
2339# Check whether we have _Static_assert
ca205a75
TK
2340if test "$static_assert" != "yes" ; then
2341 static_assert="no"
2342fi
5018f79f
AH
2343cat > $TMPC << EOF
2344#include <assert.h>
94815a5c 2345#include <stdlib.h>
51b4c81e 2346#include <stddef.h>
94815a5c
JA
2347
2348struct foo {
2349 int a, b;
2350};
2351
5018f79f
AH
2352int main(int argc, char **argv)
2353{
94815a5c 2354 _Static_assert(offsetof(struct foo, a) == 0 , "Check");
5018f79f
AH
2355 return 0 ;
2356}
2357EOF
2358if compile_prog "" "" "static_assert"; then
2359 static_assert="yes"
2360fi
484b0b65 2361print_config "Static Assert" "$static_assert"
e39c0676
JA
2362
2363##########################################
2364# Check whether we have bool / stdbool.h
ca205a75
TK
2365if test "$have_bool" != "yes" ; then
2366 have_bool="no"
2367fi
e39c0676
JA
2368cat > $TMPC << EOF
2369#include <stdbool.h>
2370int main(int argc, char **argv)
2371{
2372 bool var = true;
2373 return var != false;
2374}
2375EOF
2376if compile_prog "" "" "bool"; then
2377 have_bool="yes"
2378fi
484b0b65 2379print_config "bool" "$have_bool"
e39c0676 2380
b29c71c4
JA
2381##########################################
2382# Check whether we have strndup()
107ad008 2383strndup="no"
b29c71c4
JA
2384cat > $TMPC << EOF
2385#include <string.h>
2386#include <stdlib.h>
2387int main(int argc, char **argv)
2388{
2389 char *res = strndup("test string", 8);
2390
2391 free(res);
2392 return 0;
2393}
2394EOF
2395if compile_prog "" "" "strndup"; then
2396 strndup="yes"
2397fi
2398print_config "strndup" "$strndup"
2399
214e2d56 2400##########################################
0ffccc21
BVA
2401# <valgrind/drd.h> probe
2402# Note: presence of <valgrind/drd.h> implies that <valgrind/valgrind.h> is
2403# also available but not the other way around.
2404if test "$valgrind_dev" != "yes" ; then
2405 valgrind_dev="no"
2406fi
2407cat > $TMPC << EOF
2408#include <valgrind/drd.h>
2409int main(int argc, char **argv)
2410{
2411 return 0;
2412}
2413EOF
2414if compile_prog "" "" "valgrind_dev"; then
2415 valgrind_dev="yes"
2416fi
2417print_config "Valgrind headers" "$valgrind_dev"
2418
236d23a8 2419if test "$targetos" = "Linux" ; then
a76e1995
BVA
2420##########################################
2421# <linux/blkzoned.h> probe
2422if test "$linux_blkzoned" != "yes" ; then
2423 linux_blkzoned="no"
2424fi
2425cat > $TMPC << EOF
2426#include <linux/blkzoned.h>
2427int main(int argc, char **argv)
2428{
2429 return 0;
2430}
2431EOF
2432if compile_prog "" "" "linux_blkzoned"; then
2433 linux_blkzoned="yes"
2434fi
2435print_config "Zoned block device support" "$linux_blkzoned"
2436
236d23a8
SK
2437##########################################
2438# Check BLK_ZONE_REP_CAPACITY
2439cat > $TMPC << EOF
2440#include <linux/blkzoned.h>
2441int main(void)
2442{
2443 return BLK_ZONE_REP_CAPACITY;
2444}
2445EOF
2446if compile_prog "" "" "blkzoned report capacity"; then
2447 output_sym "CONFIG_HAVE_REP_CAPACITY"
2448 rep_capacity="yes"
2449else
2450 rep_capacity="no"
2451fi
2452print_config "Zoned block device capacity" "$rep_capacity"
2453fi
2454
56a19325
DF
2455##########################################
2456# libzbc probe
2457if test "$libzbc" != "yes" ; then
2458 libzbc="no"
2459fi
2460cat > $TMPC << EOF
2461#include <libzbc/zbc.h>
2462int main(int argc, char **argv)
2463{
2464 struct zbc_device *dev = NULL;
2465
2466 return zbc_open("foo=bar", O_RDONLY, &dev);
2467}
2468EOF
2469if compile_prog "" "-lzbc" "libzbc"; then
2470 libzbcvermaj=$(pkg-config --modversion libzbc | sed 's/\.[0-9]*\.[0-9]*//')
2471 if test "$libzbcvermaj" -ge "5" ; then
2472 libzbc="yes"
56a19325
DF
2473 else
2474 print_config "libzbc engine" "Unsupported libzbc version (version 5 or above required)"
2475 libzbc="no"
2476 fi
2477else
2478 if test "$libzbc" = "yes" ; then
2479 feature_not_found "libzbc" "libzbc or libzbc/zbc.h"
2480 fi
2481 libzbc="no"
2482fi
2483print_config "libzbc engine" "$libzbc"
2484
a76e1995 2485##########################################
214e2d56 2486# check march=armv8-a+crc+crypto
ca205a75
TK
2487if test "$march_armv8_a_crc_crypto" != "yes" ; then
2488 march_armv8_a_crc_crypto="no"
2489fi
214e2d56 2490if test "$cpu" = "arm64" ; then
2491 cat > $TMPC <<EOF
9b153dc2
TT
2492#include <arm_acle.h>
2493#include <arm_neon.h>
58828d07 2494#include <sys/auxv.h>
9b153dc2 2495
214e2d56 2496int main(void)
2497{
58828d07
SW
2498 /* Can we also do a runtime probe? */
2499#if __linux__
2500 return getauxval(AT_HWCAP);
2501#else
2502# error "Don't know how to do runtime probe for ARM CRC32c"
2503#endif
214e2d56 2504}
2505EOF
58828d07 2506 if compile_prog "-march=armv8-a+crc+crypto" "" "ARM CRC32c"; then
214e2d56 2507 march_armv8_a_crc_crypto="yes"
58828d07 2508 CFLAGS="$CFLAGS -march=armv8-a+crc+crypto"
9f75af77 2509 march_set="yes"
214e2d56 2510 fi
2511fi
484b0b65 2512print_config "march_armv8_a_crc_crypto" "$march_armv8_a_crc_crypto"
214e2d56 2513
03553853
YR
2514##########################################
2515# cuda probe
d490af7f 2516if test "$cuda" != "no" ; then
03553853
YR
2517cat > $TMPC << EOF
2518#include <cuda.h>
2519int main(int argc, char **argv)
2520{
2521 return cuInit(0);
2522}
2523EOF
d490af7f
SW
2524 if compile_prog "" "-lcuda" "cuda"; then
2525 cuda="yes"
2526 LIBS="-lcuda $LIBS"
2527 else
2528 if test "$cuda" = "yes" ; then
2529 feature_not_found "cuda" ""
2530 fi
2531 cuda="no"
2532 fi
03553853 2533fi
484b0b65 2534print_config "cuda" "$cuda"
214e2d56 2535
a817dc3b
JA
2536##########################################
2537# check for cc -march=native
2538build_native="no"
2539cat > $TMPC << EOF
2540int main(int argc, char **argv)
2541{
2542 return 0;
2543}
2544EOF
c922e0b0
SW
2545if test "$disable_native" = "no" && test "$disable_opt" != "yes" && \
2546 compile_prog "-march=native" "" "march=native"; then
a817dc3b
JA
2547 build_native="yes"
2548fi
2549print_config "Build march=native" "$build_native"
2550
b8b0e1ee
TK
2551##########################################
2552# check for -lcunit
2553if test "$cunit" != "yes" ; then
2554 cunit="no"
2555fi
2556cat > $TMPC << EOF
2557#include <CUnit/CUnit.h>
2558#include <CUnit/Basic.h>
2559int main(void)
2560{
2561 if (CU_initialize_registry() != CUE_SUCCESS)
2562 return CU_get_error();
2563 CU_basic_set_mode(CU_BRM_VERBOSE);
2564 CU_basic_run_tests();
2565 CU_cleanup_registry();
2566 return CU_get_error();
2567}
2568EOF
2569if compile_prog "" "-lcunit" "CUnit"; then
2570 cunit="yes"
2571fi
2572print_config "CUnit" "$cunit"
2573
57fa61f0
JA
2574##########################################
2575# check for __kernel_rwf_t
2576__kernel_rwf_t="no"
2577cat > $TMPC << EOF
2578#include <linux/fs.h>
2579int main(int argc, char **argv)
2580{
2581 __kernel_rwf_t x;
2582 x = 0;
2583 return x;
2584}
2585EOF
2586if compile_prog "" "" "__kernel_rwf_t"; then
2587 __kernel_rwf_t="yes"
2588fi
2589print_config "__kernel_rwf_t" "$__kernel_rwf_t"
2590
71144e67 2591##########################################
5ad91012 2592# check if gcc has -Wimplicit-fallthrough=2
71144e67
JA
2593fallthrough="no"
2594cat > $TMPC << EOF
2595int main(int argc, char **argv)
2596{
2597 return 0;
2598}
2599EOF
5ad91012 2600if compile_prog "-Wimplicit-fallthrough=2" "" "-Wimplicit-fallthrough=2"; then
71144e67
JA
2601 fallthrough="yes"
2602fi
5ad91012 2603print_config "-Wimplicit-fallthrough=2" "$fallthrough"
71144e67 2604
ff547caa
KB
2605##########################################
2606# check for MADV_HUGEPAGE support
2607if test "$thp" != "yes" ; then
2608 thp="no"
2609fi
2610if test "$esx" != "yes" ; then
2611 cat > $TMPC <<EOF
2612#include <sys/mman.h>
2613int main(void)
2614{
2615 return madvise(0, 0x1000, MADV_HUGEPAGE);
2616}
2617EOF
2618 if compile_prog "" "" "thp" ; then
2619 thp=yes
2620 else
2621 if test "$thp" = "yes" ; then
2622 feature_not_found "Transparent Huge Page" ""
2623 fi
2624 thp=no
2625 fi
2626fi
2627print_config "MADV_HUGEPAGE" "$thp"
2628
de5ed0e4
JA
2629##########################################
2630# check for gettid()
2631gettid="no"
2632cat > $TMPC << EOF
2633#include <unistd.h>
2634int main(int argc, char **argv)
2635{
2636 return gettid();
2637}
2638EOF
2639if compile_prog "" "" "gettid"; then
2640 gettid="yes"
2641fi
2642print_config "gettid" "$gettid"
2643
95f31f7d
TK
2644##########################################
2645# check for statx(2) support by libc
2646statx="no"
2647cat > $TMPC << EOF
2648#include <unistd.h>
2649#include <sys/stat.h>
2650
2651int main(int argc, char **argv)
2652{
2653 struct statx st;
2654 return statx(-1, *argv, 0, 0, &st);
2655}
2656EOF
2657if compile_prog "" "" "statx"; then
2658 statx="yes"
2659fi
2660print_config "statx(2)/libc" "$statx"
2661
2662##########################################
2663# check for statx(2) support by kernel
2664statx_syscall="no"
2665cat > $TMPC << EOF
2666#include <unistd.h>
2667#include <linux/stat.h>
2668#include <sys/stat.h>
2669#include <sys/syscall.h>
2670
2671static int _statx(int dfd, const char *pathname, int flags, unsigned int mask,
2672 struct statx *buffer)
2673{
2674 return syscall(__NR_statx, dfd, pathname, flags, mask, buffer);
2675}
2676
2677int main(int argc, char **argv)
2678{
2679 struct statx st;
2680 return _statx(-1, *argv, 0, 0, &st);
2681}
2682EOF
2683if compile_prog "" "" "statx_syscall"; then
2684 statx_syscall="yes"
2685fi
2686print_config "statx(2)/syscall" "$statx_syscall"
2687
67bf9823
JA
2688#############################################################################
2689
67bf9823 2690if test "$wordsize" = "64" ; then
4feafb1e 2691 output_sym "CONFIG_64BIT"
67bf9823 2692elif test "$wordsize" = "32" ; then
4feafb1e 2693 output_sym "CONFIG_32BIT"
67bf9823 2694else
d7145a78 2695 fatal "Unknown wordsize!"
67bf9823 2696fi
0dcebdf4 2697if test "$bigendian" = "yes" ; then
4feafb1e 2698 output_sym "CONFIG_BIG_ENDIAN"
0dcebdf4 2699else
4feafb1e 2700 output_sym "CONFIG_LITTLE_ENDIAN"
0dcebdf4 2701fi
3989b143
JA
2702if test "$zlib" = "yes" ; then
2703 output_sym "CONFIG_ZLIB"
2704fi
67bf9823 2705if test "$libaio" = "yes" ; then
4feafb1e 2706 output_sym "CONFIG_LIBAIO"
7d42e66e
KK
2707 if test "$libaio_rw_flags" = "yes" ; then
2708 output_sym "CONFIG_LIBAIO_RW_FLAGS"
2709 fi
e2defc22
JA
2710 if test "$libaio_uring" = "yes" ; then
2711 output_sym "CONFIG_LIBAIO_URING"
2712 fi
67bf9823
JA
2713fi
2714if test "$posix_aio" = "yes" ; then
4feafb1e 2715 output_sym "CONFIG_POSIXAIO"
67bf9823
JA
2716fi
2717if test "$posix_aio_fsync" = "yes" ; then
4feafb1e 2718 output_sym "CONFIG_POSIXAIO_FSYNC"
67bf9823 2719fi
06eac6b2
SW
2720if test "$posix_pshared" = "yes" ; then
2721 output_sym "CONFIG_PSHARED"
2722fi
78b66d32
BVA
2723if test "$pthread_condattr_setclock" = "yes" ; then
2724 output_sym "CONFIG_PTHREAD_CONDATTR_SETCLOCK"
2725fi
c31092b8
BVA
2726if test "$pthread_sigmask" = "yes" ; then
2727 output_sym "CONFIG_PTHREAD_SIGMASK"
2728fi
44e8e956 2729if test "$have_asprintf" = "yes" ; then
cb3b6806 2730 output_sym "CONFIG_HAVE_ASPRINTF"
44e8e956
BVA
2731fi
2732if test "$have_vasprintf" = "yes" ; then
cb3b6806 2733 output_sym "CONFIG_HAVE_VASPRINTF"
44e8e956 2734fi
67bf9823 2735if test "$linux_fallocate" = "yes" ; then
4feafb1e 2736 output_sym "CONFIG_LINUX_FALLOCATE"
67bf9823
JA
2737fi
2738if test "$posix_fallocate" = "yes" ; then
4feafb1e 2739 output_sym "CONFIG_POSIX_FALLOCATE"
67bf9823
JA
2740fi
2741if test "$fdatasync" = "yes" ; then
4feafb1e 2742 output_sym "CONFIG_FDATASYNC"
67bf9823 2743fi
52a552e2
BVA
2744if test "$pipe" = "yes" ; then
2745 output_sym "CONFIG_PIPE"
2746fi
2747if test "$pipe2" = "yes" ; then
2748 output_sym "CONFIG_PIPE2"
2749fi
15eca9aa
BVA
2750if test "$pread" = "yes" ; then
2751 output_sym "CONFIG_PREAD"
2752fi
67bf9823 2753if test "$sync_file_range" = "yes" ; then
4feafb1e 2754 output_sym "CONFIG_SYNC_FILE_RANGE"
67bf9823
JA
2755fi
2756if test "$sfaa" = "yes" ; then
4feafb1e 2757 output_sym "CONFIG_SFAA"
67bf9823 2758fi
a250edd0
JA
2759if test "$sync_sync" = "yes" ; then
2760 output_sym "CONFIG_SYNC_SYNC"
2761fi
2762if test "$cmp_swap" = "yes" ; then
2763 output_sym "CONFIG_CMP_SWAP"
2764fi
954cd73a 2765if test "$libverbs" = "yes" -a "$rdmacm" = "yes" ; then
4feafb1e 2766 output_sym "CONFIG_RDMA"
67bf9823
JA
2767fi
2768if test "$clock_gettime" = "yes" ; then
4feafb1e 2769 output_sym "CONFIG_CLOCK_GETTIME"
67bf9823
JA
2770fi
2771if test "$clock_monotonic" = "yes" ; then
4feafb1e 2772 output_sym "CONFIG_CLOCK_MONOTONIC"
67bf9823 2773fi
c544f604
SN
2774if test "$clock_monotonic_raw" = "yes" ; then
2775 output_sym "CONFIG_CLOCK_MONOTONIC_RAW"
2776fi
67bf9823 2777if test "$clock_monotonic_precise" = "yes" ; then
4feafb1e 2778 output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
67bf9823 2779fi
25f8227d
JA
2780if test "$clockid_t" = "yes"; then
2781 output_sym "CONFIG_CLOCKID_T"
2782fi
67bf9823 2783if test "$gettimeofday" = "yes" ; then
4feafb1e 2784 output_sym "CONFIG_GETTIMEOFDAY"
67bf9823
JA
2785fi
2786if test "$posix_fadvise" = "yes" ; then
4feafb1e 2787 output_sym "CONFIG_POSIX_FADVISE"
67bf9823
JA
2788fi
2789if test "$linux_3arg_affinity" = "yes" ; then
4feafb1e 2790 output_sym "CONFIG_3ARG_AFFINITY"
67bf9823 2791elif test "$linux_2arg_affinity" = "yes" ; then
4feafb1e 2792 output_sym "CONFIG_2ARG_AFFINITY"
67bf9823
JA
2793fi
2794if test "$strsep" = "yes" ; then
4feafb1e 2795 output_sym "CONFIG_STRSEP"
67bf9823 2796fi
9ad8da82
JA
2797if test "$strcasestr" = "yes" ; then
2798 output_sym "CONFIG_STRCASESTR"
2799fi
5ad7be56
KD
2800if test "$strlcat" = "yes" ; then
2801 output_sym "CONFIG_STRLCAT"
2802fi
67bf9823 2803if test "$getopt_long_only" = "yes" ; then
4feafb1e 2804 output_sym "CONFIG_GETOPT_LONG_ONLY"
67bf9823
JA
2805fi
2806if test "$inet_aton" = "yes" ; then
4feafb1e 2807 output_sym "CONFIG_INET_ATON"
67bf9823
JA
2808fi
2809if test "$socklen_t" = "yes" ; then
4feafb1e 2810 output_sym "CONFIG_SOCKLEN_T"
67bf9823
JA
2811fi
2812if test "$ext4_me" = "yes" ; then
4feafb1e 2813 output_sym "CONFIG_LINUX_EXT4_MOVE_EXTENT"
67bf9823
JA
2814fi
2815if test "$linux_splice" = "yes" ; then
4feafb1e 2816 output_sym "CONFIG_LINUX_SPLICE"
67bf9823
JA
2817fi
2818if test "$guasi" = "yes" ; then
4feafb1e 2819 output_sym "CONFIG_GUASI"
67bf9823 2820fi
50206d9b 2821if test "$libnuma_v2" = "yes" ; then
4feafb1e 2822 output_sym "CONFIG_LIBNUMA"
67bf9823
JA
2823fi
2824if test "$solaris_aio" = "yes" ; then
4feafb1e 2825 output_sym "CONFIG_SOLARISAIO"
67bf9823
JA
2826fi
2827if test "$tls_thread" = "yes" ; then
4feafb1e 2828 output_sym "CONFIG_TLS_THREAD"
67bf9823 2829fi
44404c5a 2830if test "$rusage_thread" = "yes" ; then
4feafb1e 2831 output_sym "CONFIG_RUSAGE_THREAD"
67bf9823 2832fi
91f94d5b 2833if test "$gfio" = "yes" ; then
bad7e42c 2834 output_sym "CONFIG_GFIO"
91f94d5b 2835fi
c8931876
JA
2836if test "$esx" = "yes" ; then
2837 output_sym "CONFIG_ESX"
2838 output_sym "CONFIG_NO_SHM"
2839fi
7e09a9f1
JA
2840if test "$sched_idle" = "yes" ; then
2841 output_sym "CONFIG_SCHED_IDLE"
2842fi
1eafa37a
JA
2843if test "$tcp_nodelay" = "yes" ; then
2844 output_sym "CONFIG_TCP_NODELAY"
2845fi
1008602c
JA
2846if test "$window_size" = "yes" ; then
2847 output_sym "CONFIG_NET_WINDOWSIZE"
2848fi
e5f34d95
JA
2849if test "$mss" = "yes" ; then
2850 output_sym "CONFIG_NET_MSS"
2851fi
38b9354a
JA
2852if test "$rlimit_memlock" = "yes" ; then
2853 output_sym "CONFIG_RLIMIT_MEMLOCK"
2854fi
07fc0acd
JA
2855if test "$pwritev" = "yes" ; then
2856 output_sym "CONFIG_PWRITEV"
2857fi
2cafffbe
JA
2858if test "$pwritev2" = "yes" ; then
2859 output_sym "CONFIG_PWRITEV2"
2860fi
ecad55e9
JA
2861if test "$ipv6" = "yes" ; then
2862 output_sym "CONFIG_IPV6"
2863fi
c2f6a13d
LMB
2864if test "$http" = "yes" ; then
2865 output_sym "CONFIG_HTTP"
2866fi
d5f9b0ea
IF
2867if test "$rados" = "yes" ; then
2868 output_sym "CONFIG_RADOS"
2869fi
fc5c0345
DG
2870if test "$rbd" = "yes" ; then
2871 output_sym "CONFIG_RBD"
2872fi
53b6c979
PL
2873if test "$rbd_poll" = "yes" ; then
2874 output_sym "CONFIG_RBD_POLL"
2875fi
903b2812
JA
2876if test "$rbd_inval" = "yes" ; then
2877 output_sym "CONFIG_RBD_INVAL"
2878fi
2e802282
JA
2879if test "$setvbuf" = "yes" ; then
2880 output_sym "CONFIG_SETVBUF"
2881fi
81795ce3
CE
2882if test "$s390_z196_facilities" = "yes" ; then
2883 output_sym "CONFIG_S390_Z196_FACILITIES"
2884 CFLAGS="$CFLAGS -march=z9-109"
9f75af77 2885 march_set="yes"
81795ce3 2886fi
6e7d7dfb 2887if test "$gfapi" = "yes" ; then
2888 output_sym "CONFIG_GFAPI"
2889fi
6fa14b99 2890if test "$gf_fadvise" = "yes" ; then
2891 output_sym "CONFIG_GF_FADVISE"
2892fi
6876c98c
JA
2893if test "$gf_trim" = "yes" ; then
2894 output_sym "CONFIG_GF_TRIM"
2895fi
ce4d13ca
JA
2896if test "$gf_new" = "yes" ; then
2897 output_sym "CONFIG_GF_NEW_API"
2898fi
1b10477b
MM
2899if test "$libhdfs" = "yes" ; then
2900 output_sym "CONFIG_LIBHDFS"
247e5436 2901 echo "FIO_HDFS_CPU=$FIO_HDFS_CPU" >> $config_host_mak
1527dc50
FB
2902 echo "JAVA_HOME=$JAVA_HOME" >> $config_host_mak
2903 echo "FIO_LIBHDFS_INCLUDE=$FIO_LIBHDFS_INCLUDE" >> $config_host_mak
2904 echo "FIO_LIBHDFS_LIB=$FIO_LIBHDFS_LIB" >> $config_host_mak
247ef2aa 2905fi
b8116a87
DE
2906if test "$mtd" = "yes" ; then
2907 output_sym "CONFIG_MTD"
2908fi
43f3cec2
BB
2909if test "$pmemblk" = "yes" ; then
2910 output_sym "CONFIG_PMEMBLK"
2911fi
cbb15e42
DJ
2912if test "$devdax" = "yes" ; then
2913 output_sym "CONFIG_LINUX_DEVDAX"
2914fi
ae0db592
TI
2915if test "$pmem" = "yes" ; then
2916 output_sym "CONFIG_LIBPMEM"
2917fi
a40e7a59
GB
2918if test "$libime" = "yes" ; then
2919 output_sym "CONFIG_IME"
2920fi
b470a02c
SC
2921if test "$arith" = "yes" ; then
2922 output_sym "CONFIG_ARITHMETIC"
e7b2c7a3
JA
2923 if test "$yacc_is_bison" = "yes" ; then
2924 echo "YACC=$YACC -y" >> $config_host_mak
2925 else
2926 echo "YACC=$YACC" >> $config_host_mak
2927 fi
63bda378
JA
2928 if test "$lex_use_o" = "yes" ; then
2929 echo "CONFIG_LEX_USE_O=y" >> $config_host_mak
2930 fi
b470a02c 2931fi
aae599ba
JA
2932if test "$getmntent" = "yes" ; then
2933 output_sym "CONFIG_GETMNTENT"
2934fi
e7e136da
TK
2935if test "$getmntinfo" = "yes" ; then
2936 output_sym "CONFIG_GETMNTINFO"
2937fi
b765bec0
TK
2938if test "$getmntinfo_statvfs" = "yes" ; then
2939 output_sym "CONFIG_GETMNTINFO_STATVFS"
2940fi
5018f79f
AH
2941if test "$static_assert" = "yes" ; then
2942 output_sym "CONFIG_STATIC_ASSERT"
2943fi
e39c0676
JA
2944if test "$have_bool" = "yes" ; then
2945 output_sym "CONFIG_HAVE_BOOL"
2946fi
b29c71c4
JA
2947if test "$strndup" = "yes" ; then
2948 output_sym "CONFIG_HAVE_STRNDUP"
2949fi
484817a9
JA
2950if test "$disable_opt" = "yes" ; then
2951 output_sym "CONFIG_DISABLE_OPTIMIZATIONS"
2952fi
0ffccc21
BVA
2953if test "$valgrind_dev" = "yes"; then
2954 output_sym "CONFIG_VALGRIND_DEV"
2955fi
a76e1995 2956if test "$linux_blkzoned" = "yes" ; then
b7694961 2957 output_sym "CONFIG_HAS_BLKZONED"
a76e1995 2958fi
56a19325
DF
2959if test "$libzbc" = "yes" ; then
2960 output_sym "CONFIG_LIBZBC"
2961fi
605cf82e 2962if test "$zlib" = "no" ; then
8f909424
JA
2963 echo "Consider installing zlib-dev (zlib-devel, some fio features depend on it."
2964 if test "$build_static" = "yes"; then
2965 echo "Note that some distros have separate packages for static libraries."
2966 fi
605cf82e 2967fi
58828d07
SW
2968if test "$march_armv8_a_crc_crypto" = "yes" ; then
2969 output_sym "ARCH_HAVE_CRC_CRYPTO"
2970fi
03553853
YR
2971if test "$cuda" = "yes" ; then
2972 output_sym "CONFIG_CUDA"
2973fi
9f75af77 2974if test "$march_set" = "no" && test "$build_native" = "yes" ; then
a817dc3b
JA
2975 output_sym "CONFIG_BUILD_NATIVE"
2976fi
b8b0e1ee
TK
2977if test "$cunit" = "yes" ; then
2978 output_sym "CONFIG_HAVE_CUNIT"
2979fi
57fa61f0
JA
2980if test "$__kernel_rwf_t" = "yes"; then
2981 output_sym "CONFIG_HAVE_KERNEL_RWF_T"
2982fi
de5ed0e4
JA
2983if test "$gettid" = "yes"; then
2984 output_sym "CONFIG_HAVE_GETTID"
2985fi
95f31f7d
TK
2986if test "$statx" = "yes"; then
2987 output_sym "CONFIG_HAVE_STATX"
2988fi
2989if test "$statx_syscall" = "yes"; then
2990 output_sym "CONFIG_HAVE_STATX_SYSCALL"
2991fi
71144e67
JA
2992if test "$fallthrough" = "yes"; then
2993 CFLAGS="$CFLAGS -Wimplicit-fallthrough"
2994fi
ff547caa
KB
2995if test "$thp" = "yes" ; then
2996 output_sym "CONFIG_HAVE_THP"
2997fi
247ef2aa
KZ
2998if test "$libiscsi" = "yes" ; then
2999 output_sym "CONFIG_LIBISCSI"
3000 echo "CONFIG_LIBISCSI=m" >> $config_host_mak
3001 echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
3002 echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
3003fi
d643a1e2
RJ
3004if test "$libnbd" = "yes" ; then
3005 output_sym "CONFIG_LIBNBD"
3006 echo "CONFIG_LIBNBD=m" >> $config_host_mak
3007 echo "LIBNBD_CFLAGS=$libnbd_cflags" >> $config_host_mak
3008 echo "LIBNBD_LIBS=$libnbd_libs" >> $config_host_mak
3009fi
5a8a6a03 3010if test "$dynamic_engines" = "yes" ; then
a504a390 3011 output_sym "CONFIG_DYNAMIC_ENGINES"
5a8a6a03
YK
3012fi
3013print_config "Lib-based ioengines dynamic" "$dynamic_engines"
01fe773d
JD
3014cat > $TMPC << EOF
3015int main(int argc, char **argv)
3016{
3017 return 0;
3018}
3019EOF
ab6e4714
SW
3020if test "$disable_tcmalloc" != "yes"; then
3021 if compile_prog "" "-ltcmalloc" "tcmalloc"; then
3022 tcmalloc="yes"
3023 LIBS="-ltcmalloc $LIBS"
3024 elif compile_prog "" "-l:libtcmalloc_minimal.so.4" "tcmalloc_minimal4"; then
3025 tcmalloc="yes"
3026 LIBS="-l:libtcmalloc_minimal.so.4 $LIBS"
3027 else
3028 tcmalloc="no"
3029 fi
01fe773d
JD
3030fi
3031print_config "TCMalloc support" "$tcmalloc"
605cf82e 3032
67bf9823 3033echo "LIBS+=$LIBS" >> $config_host_mak
86719845 3034echo "GFIO_LIBS+=$GFIO_LIBS" >> $config_host_mak
91f94d5b 3035echo "CFLAGS+=$CFLAGS" >> $config_host_mak
d2aeedb9 3036echo "LDFLAGS+=$LDFLAGS" >> $config_host_mak
67bf9823 3037echo "CC=$cc" >> $config_host_mak
af4862b3 3038echo "BUILD_CFLAGS=$BUILD_CFLAGS $CFLAGS" >> $config_host_mak
020d54bd 3039echo "INSTALL_PREFIX=$prefix" >> $config_host_mak
c61a3a44 3040
59d8f412 3041if [ `dirname $0` != "." -a ! -e Makefile ]; then
c61a3a44
JF
3042 cat > Makefile <<EOF
3043SRCDIR:=`dirname $0`
3044include \$(SRCDIR)/Makefile
3045EOF
3046fi