commit 72cf2d4f0e181d0d3a3122e04129c58a95da713e
Author: Blue Swirl <blauwirbel@gmail.com>
Date:   Sat Sep 12 07:36:22 2009 +0000

    Fix sys-queue.h conflict for good
    
    Problem: Our file sys-queue.h is a copy of the BSD file, but there are
    some additions and it's not entirely compatible. Because of that, there have
    been conflicts with system headers on BSD systems. Some hacks have been
    introduced in the commits 15cc9235840a22c289edbe064a9b3c19c5f49896,
    f40d753718c72693c5f520f0d9899f6e50395e94,
    96555a96d724016e13190b28cffa3bc929ac60dc and
    3990d09adf4463eca200ad964cc55643c33feb50 but the fixes were fragile.
    
    Solution: Avoid the conflict entirely by renaming the functions and the
    file. Revert the previous hacks.
    
    Signed-off-by: Blue Swirl <blauwirbel@gmail.com>

diff --git a/qemu-option.c b/qemu-option.c
index 0c2101e..88298e4 100644
--- a/qemu-option.c
+++ b/qemu-option.c
@@ -477,21 +477,21 @@ struct QemuOpt {
     } value;
 
     QemuOpts     *opts;
-    TAILQ_ENTRY(QemuOpt) next;
+    QTAILQ_ENTRY(QemuOpt) next;
 };
 
 struct QemuOpts {
     const char *id;
     QemuOptsList *list;
-    TAILQ_HEAD(, QemuOpt) head;
-    TAILQ_ENTRY(QemuOpts) next;
+    QTAILQ_HEAD(, QemuOpt) head;
+    QTAILQ_ENTRY(QemuOpts) next;
 };
 
 static QemuOpt *qemu_opt_find(QemuOpts *opts, const char *name)
 {
     QemuOpt *opt;
 
-    TAILQ_FOREACH(opt, &opts->head, next) {
+    QTAILQ_FOREACH(opt, &opts->head, next) {
         if (strcmp(opt->name, name) != 0)
             continue;
         return opt;
@@ -556,7 +556,7 @@ static int qemu_opt_parse(QemuOpt *opt)
 
 static void qemu_opt_del(QemuOpt *opt)
 {
-    TAILQ_REMOVE(&opt->opts->head, opt, next);
+    QTAILQ_REMOVE(&opt->opts->head, opt, next);
     qemu_free((/* !const */ char*)opt->name);
     qemu_free((/* !const */ char*)opt->str);
     qemu_free(opt);
@@ -588,7 +588,7 @@ int qemu_opt_set(QemuOpts *opts, const char *name, const char *value)
         opt = qemu_mallocz(sizeof(*opt));
         opt->name = qemu_strdup(name);
         opt->opts = opts;
-        TAILQ_INSERT_TAIL(&opts->head, opt, next);
+        QTAILQ_INSERT_TAIL(&opts->head, opt, next);
         if (desc[i].name != NULL) {
             opt->desc = desc+i;
         }
@@ -613,7 +613,7 @@ int qemu_opt_foreach(QemuOpts *opts, qemu_opt_loopfunc func, void *opaque,
     QemuOpt *opt;
     int rc = 0;
 
-    TAILQ_FOREACH(opt, &opts->head, next) {
+    QTAILQ_FOREACH(opt, &opts->head, next) {
         rc = func(opt->name, opt->str, opaque);
         if (abort_on_failure  &&  rc != 0)
             break;
@@ -625,7 +625,7 @@ QemuOpts *qemu_opts_find(QemuOptsList *list, const char *id)
 {
     QemuOpts *opts;
 
-    TAILQ_FOREACH(opts, &list->head, next) {
+    QTAILQ_FOREACH(opts, &list->head, next) {
         if (!opts->id) {
             continue;
         }
@@ -658,8 +658,8 @@ QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id, int fail_if_exist
         opts->id = qemu_strdup(id);
     }
     opts->list = list;
-    TAILQ_INIT(&opts->head);
-    TAILQ_INSERT_TAIL(&list->head, opts, next);
+    QTAILQ_INIT(&opts->head);
+    QTAILQ_INSERT_TAIL(&list->head, opts, next);
     return opts;
 }
 
@@ -687,12 +687,12 @@ void qemu_opts_del(QemuOpts *opts)
     QemuOpt *opt;
 
     for (;;) {
-        opt = TAILQ_FIRST(&opts->head);
+        opt = QTAILQ_FIRST(&opts->head);
         if (opt == NULL)
             break;
         qemu_opt_del(opt);
     }
-    TAILQ_REMOVE(&opts->list->head, opts, next);
+    QTAILQ_REMOVE(&opts->list->head, opts, next);
     qemu_free(opts);
 }
 
@@ -702,7 +702,7 @@ int qemu_opts_print(QemuOpts *opts, void *dummy)
 
     fprintf(stderr, "%s: %s:", opts->list->name,
             opts->id ? opts->id : "<noid>");
-    TAILQ_FOREACH(opt, &opts->head, next) {
+    QTAILQ_FOREACH(opt, &opts->head, next) {
         fprintf(stderr, " %s=\"%s\"", opt->name, opt->str);
     }
     fprintf(stderr, "\n");
@@ -788,7 +788,7 @@ int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func, void *opaque,
     QemuOpts *opts;
     int rc = 0;
 
-    TAILQ_FOREACH(opts, &list->head, next) {
+    QTAILQ_FOREACH(opts, &list->head, next) {
         rc = func(opts, opaque);
         if (abort_on_failure  &&  rc != 0)
             break;
