diff options
| author | Roy Marples <roy@marples.name> | 2019-10-07 15:00:21 +0100 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2019-10-07 15:00:21 +0100 |
| commit | 2c45fbda6bf25b4992b3b617dd1531786c25c9d1 (patch) | |
| tree | 892c551f63e067cea09b32c80c09c8d0aaf0e4da | |
| parent | 0f9338e0fd6093a34ad8d62cde60bf78462ba387 (diff) | |
| download | parpd-2c45fbda6bf25b4992b3b617dd1531786c25c9d1.tar.xz | |
build: Fix test for TAILQ_FOREACH_SAFE
| -rwxr-xr-x | configure | 61 |
1 files changed, 44 insertions, 17 deletions
@@ -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 <<EOF >_strtoi.c -#include <stdlib.h> -#include <limits.h> -#include <inttypes.h> +if [ -z "$TAILQ_FOREACH_SAFE" ]; then + printf "Testing for TAILQ_FOREACH_SAFE ... " + cat <<EOF >_queue.c +#include <sys/queue.h> 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 <<EOF >_queue.c +#include <sys/queue.h> +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 <sys/queue.h>">>$CONFIG_H + fi echo "#include \"compat/queue.h\"">>$CONFIG_H else echo "#define HAVE_SYS_QUEUE_H" >>$CONFIG_H |
