From 2c45fbda6bf25b4992b3b617dd1531786c25c9d1 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Mon, 7 Oct 2019 15:00:21 +0100 Subject: build: Fix test for TAILQ_FOREACH_SAFE --- configure | 61 ++++++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 17 deletions(-) diff --git a/configure b/configure index 9f11edf..8eed93c 100755 --- a/configure +++ b/configure @@ -445,29 +445,48 @@ if [ "$STRLCPY" = no ]; then echo "#include \"compat/strlcpy.h\"" >>$CONFIG_H fi -if [ -z "$STRTOI" ]; then - printf "Testing for strtoi ... " - cat <_strtoi.c -#include -#include -#include +if [ -z "$TAILQ_FOREACH_SAFE" ]; then + printf "Testing for TAILQ_FOREACH_SAFE ... " + cat <_queue.c +#include int main(void) { - int e; - strtoi("1234", NULL, 0, 0, INT32_MAX, &e); +#ifndef TAILQ_FOREACH_SAFE +#error TAILQ_FOREACH_SAFE +#endif return 0; } EOF - if $XCC _strtoi.c -o _strtoi 2>&3; then - STRTOI=yes + if $XCC _queue.c -o _queue 2>&3; then + TAILQ_FOREACH_SAFE=yes + TAILQ_FOREACH=yes else - STRTOI=no + TAILQ_FOREACH_SAFE=no fi - echo "$STRTOI" - rm -f _strtoi.c _strtoi + echo "$TAILQ_FOREACH_SAFE" + rm -f _queue.c _queue fi -if [ "$STRTOI" = no ]; then - echo "COMPAT_SRCS+= compat/strtoi.c compat/strtou.c" >>$CONFIG_MK - echo "#include \"compat/strtoi.h\"" >>$CONFIG_H +if [ "$TAILQ_FOREACH_SAFE" = no ] && [ -z "$TAILQ_FOREACH_MUTABLE" ]; then + printf "Testing for TAILQ_FOREACH_MUTABLE ... " + cat <_queue.c +#include +int main(void) { +#ifndef TAILQ_FOREACH_MUTABLE +#error TAILQ_FOREACH_MUTABLE +#endif + return 0; +} +EOF + if $XCC _queue.c -o _queue 2>&3; then + TAILQ_FOREACH_MUTABLE=yes + TAILQ_FOREACH_SAFE=yes + TAILQ_FOREACH=yes + echo "#define TAILQ_FOREACH_SAFE TAILQ_FOREACH_MUTABLE" \ + >> $CONFIG_H + else + TAILQ_FOREACH_MUTABLE=no + fi + echo "$TAILQ_FOREACH_MUTABLE" + rm -f _queue.c _queue fi if [ -z "$TAILQ_FOREACH" ]; then @@ -489,7 +508,15 @@ EOF echo "$TAILQ_FOREACH" rm -f _queue.c _queue fi -if [ "$TAILQ_FOREACH" = no ]; then +if [ "$TAILQ_FOREACH_SAFE" = no ]; then + # If we don't include sys/queue.h then clang analyser finds + # too many false positives. + # See http://llvm.org/bugs/show_bug.cgi?id=18222 + # Strictly speaking this isn't needed, but I like it to help + # catch any nasties. + if [ "$TAILQ_FOREACH" = yes ]; then + echo "#include ">>$CONFIG_H + fi echo "#include \"compat/queue.h\"">>$CONFIG_H else echo "#define HAVE_SYS_QUEUE_H" >>$CONFIG_H -- cgit v1.2.3