diff --git a/CONFIG b/CONFIG index a056f326b..2d4e53eb9 100644 --- a/CONFIG +++ b/CONFIG @@ -180,6 +180,9 @@ CONFIG_USDT=n # In this mode, SPDK shares the DSA device with the kernel. CONFIG_IDXD_KERNEL=n +# arc4random is available in stdlib.h +CONFIG_HAVE_ARC4RANDOM=n + # Is DPDK using libbsd? CONFIG_HAVE_LIBBSD=n diff --git a/configure b/configure index 6b7216f82..541c0771c 100755 --- a/configure +++ b/configure @@ -1065,6 +1065,11 @@ if [[ "${CONFIG[TSAN]}" = "y" ]]; then fi fi +if echo -e '#include \nint main(void) { arc4random(); return 0; }\n' \ + | "${BUILD_CMD[@]}" - 2> /dev/null; then + CONFIG[HAVE_ARC4RANDOM]="y" +fi + if [[ "${CONFIG[OCF]}" = "y" ]]; then # If OCF_PATH is a file, assume it is a library and use it to compile with if [ -f ${CONFIG[OCF_PATH]} ]; then diff --git a/lib/iscsi/iscsi.c b/lib/iscsi/iscsi.c index ae4ad5f09..54e05620f 100644 --- a/lib/iscsi/iscsi.c +++ b/lib/iscsi/iscsi.c @@ -34,7 +34,6 @@ #ifdef __FreeBSD__ #define HAVE_SRANDOMDEV 1 -#define HAVE_ARC4RANDOM 1 #endif struct spdk_iscsi_globals g_iscsi = { @@ -69,7 +68,7 @@ srandomdev(void) } #endif /* HAVE_SRANDOMDEV */ -#ifndef HAVE_ARC4RANDOM +#ifndef SPDK_CONFIG_HAVE_ARC4RANDOM static int g_arc4random_initialized = 0; static uint32_t @@ -87,7 +86,7 @@ arc4random(void) r = (r1 << 16) | r2; return r; } -#endif /* HAVE_ARC4RANDOM */ +#endif /* SPDK_CONFIG_HAVE_ARC4RANDOM */ static void gen_random(uint8_t *buf, size_t len) diff --git a/scripts/check_format.sh b/scripts/check_format.sh index 3e624a1d5..6fe67a485 100755 --- a/scripts/check_format.sh +++ b/scripts/check_format.sh @@ -274,7 +274,7 @@ function check_posix_includes() { local rc=0 echo -n "Checking for POSIX includes..." - git grep -I -i -f scripts/posix.txt -- './*' ':!include/spdk/stdinc.h' ':!include/linux/**' ':!lib/rte_vhost*/**' ':!scripts/posix.txt' ':!*.patch' > scripts/posix.log || true + git grep -I -i -f scripts/posix.txt -- './*' ':!include/spdk/stdinc.h' ':!include/linux/**' ':!lib/rte_vhost*/**' ':!scripts/posix.txt' ':!*.patch' ':!configure' > scripts/posix.log || true if [ -s scripts/posix.log ]; then echo "POSIX includes detected. Please include spdk/stdinc.h instead." cat scripts/posix.log