aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSUZUKI, Shinsuke <suz@kame.net>2006-09-02 08:00:25 +0000
committerSUZUKI, Shinsuke <suz@kame.net>2006-09-02 08:00:25 +0000
commita81d6601b213f657821f80bd6f257545647574a0 (patch)
tree765faa8d45b5512188ad7cf46df6d2b33e1f658c
parent26ff90dadfa215eaeb5008bd6d50fe1db5969a13 (diff)
added a configure check routine to automatically detect a difference(*1) in
TAILQ_FOREACH_REVERSE macros. (Suggested by Brute STEVANT) *1) Some OS (*BSD) adopts the following definition, #define TAILQ_FOREACH_REVERSE(var, head, headname, field) but others (MacOS-X, old OpenBSD) adopts the following definition #define TAILQ_FOREACH_REVERSE(var, head, field, headname)
-rw-r--r--common.h3
-rwxr-xr-xconfigure102
-rw-r--r--configure.in40
3 files changed, 145 insertions, 0 deletions
diff --git a/common.h b/common.h
index 194829d..c10b65d 100644
--- a/common.h
+++ b/common.h
@@ -84,6 +84,9 @@
(var); \
(var) = TAILQ_NEXT((var), field))
#endif
+#ifdef HAVE_TAILQ_FOREACH_REVERSE_OLD
+#undef TAILQ_FOREACH_REVERSE
+#endif
#ifndef TAILQ_FOREACH_REVERSE
#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
for ((var) = TAILQ_LAST((head), headname); \
diff --git a/configure b/configure
index 05ad1cc..a0d1dfe 100755
--- a/configure
+++ b/configure
@@ -5293,6 +5293,108 @@ _ACEOF
esac
+echo "$as_me:$LINENO: checking checking the existence TAILQ_FOREACH_REVERSE" >&5
+echo $ECHO_N "checking checking the existence TAILQ_FOREACH_REVERSE... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <sys/queue.h>
+ #ifdef TAILQ_FOREACH_REVERSE
+ yes
+#endif
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "yes" >/dev/null 2>&1; then
+ result=yes
+fi
+rm -f conftest*
+
+echo "$as_me:$LINENO: result: $result" >&5
+echo "${ECHO_T}$result" >&6
+case $result in
+yes) tailq_foreach=yes
+ ;;
+*) tailq_foreach=no
+ ;;
+esac
+
+if test $tailq_foreach = yes) {
+ echo "$as_me:$LINENO: checking argument order of TAILQ_FOREACH_REVERSE" >&5
+echo $ECHO_N "checking argument order of TAILQ_FOREACH_REVERSE... $ECHO_C" >&6
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ #include <stdio.h>
+ #include <sys/queue.h>
+
+ TAILQ_HEAD(tailhead, entry) head = TAILQ_HEAD_INITIALIZER(head);
+ struct entry {
+ TAILQ_ENTRY(entry) entries;
+ } *p;
+
+ int i;
+ struct tailhead *headp;
+
+ TAILQ_FOREACH_REVERSE(p, headp, tailhead, entries) {
+ }
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ echo "$as_me:$LINENO: result: new" >&5
+echo "${ECHO_T}new" >&6
+ cat >>confdefs.h <<\_ACEOF
+#define HAVE_TAILQ_FOREACH_REVERSE 1
+_ACEOF
+
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+echo "$as_me:$LINENO: result: old" >&5
+echo "${ECHO_T}old" >&6
+ cat >>confdefs.h <<\_ACEOF
+#define HAVE_TAILQ_FOREACH_REVERSE_OLD 1
+_ACEOF
+
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext;
+fi
+
for ac_header in stdarg.h
do
diff --git a/configure.in b/configure.in
index 624061f..19e8d38 100644
--- a/configure.in
+++ b/configure.in
@@ -147,6 +147,46 @@ esac
dnl DHCP option type values not officially defined
dnl (no such option now)
+dnl Checks the existence of TAILQ_FOREACH_REVERSE
+AC_MSG_CHECKING(checking the existence TAILQ_FOREACH_REVERSE)
+AC_EGREP_CPP(yes,
+[#include <sys/queue.h>
+ #ifdef TAILQ_FOREACH_REVERSE
+ yes
+#endif], [result=yes], [result=no])
+AC_MSG_RESULT($result)
+case $result in
+yes) tailq_foreach=yes
+ ;;
+*) tailq_foreach=no
+ ;;
+esac
+
+dnl Checks the argument order of TAILQ_FOREACH_REVERSE if it exists
+if test $tailq_foreach = yes ; then
+ AC_MSG_CHECKING(argument order of TAILQ_FOREACH_REVERSE)
+ AC_TRY_COMPILE([],
+ [
+ #include <stdio.h>
+ #include <sys/queue.h>
+
+ TAILQ_HEAD(tailhead, entry) head = TAILQ_HEAD_INITIALIZER(head);
+ struct entry {
+ TAILQ_ENTRY(entry) entries;
+ } *p;
+
+ int i;
+ struct tailhead *headp;
+
+ TAILQ_FOREACH_REVERSE(p, headp, tailhead, entries) {
+ }
+ ],
+ [AC_MSG_RESULT(new)
+ AC_DEFINE(HAVE_TAILQ_FOREACH_REVERSE)],
+ [AC_MSG_RESULT(old)
+ AC_DEFINE(HAVE_TAILQ_FOREACH_REVERSE_OLD)]);
+fi
+
AC_CHECK_HEADERS(stdarg.h)
AC_OUTPUT(Makefile)