EOF
if $XCC _queue.c -o _queue 2>&3; then
TAILQ_FOREACH_SAFE=yes
+ TAILQ_FOREACH=yes
else
TAILQ_FOREACH_SAFE=no
fi
echo "$TAILQ_FOREACH_SAFE"
rm -f _queue.c _queue
fi
+
if [ -z "$TAILQ_CONCAT" ]; then
printf "Testing for TAILQ_CONCAT ..."
cat <<EOF >_queue.c
EOF
if $XCC _queue.c -o _queue 2>&3; then
TAILQ_CONCAT=yes
+ TAILQ_FOREACH=yes
else
TAILQ_CONCAT=no
fi
echo "$TAILQ_CONCAT"
rm -f _queue.c _queue
fi
+
+if [ -z "$TAILQ_FOREACH" ]; then
+ printf "Testing for TAILQ_FOREACH ... "
+ cat <<EOF >_queue.c
+#include <sys/queue.h>
+int main(void) {
+#ifndef TAILQ_FOREACH
+#error TAILQ_FOREACH
+#endif
+ return 0;
+}
+EOF
+ if $XCC _queue.c -o _queue 2>&3; then
+ TAILQ_FOREACH=yes
+ else
+ TAILQ_FOREACH=no
+ fi
+ echo "$TAILQ_FOREACH"
+ rm -f _queue.c _queue
+fi
+
if [ "$TAILQ_FOREACH_SAFE" = no -o "$TAILQ_CONCAT" = 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 <sys/queue.h>">>$CONFIG_H
+ fi
echo "#include \"compat/queue.h\"">>$CONFIG_H
else
echo "#include <sys/queue.h>" >>$CONFIG_H