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