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/hw/qdev.c b/hw/qdev.c
index 6451b8a..43b1beb 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -101,7 +101,7 @@ DeviceState *qdev_create(BusState *bus, const char *name)
     qdev_prop_set_defaults(dev, dev->info->props);
     qdev_prop_set_defaults(dev, dev->parent_bus->info->props);
     qdev_prop_set_compat(dev);
-    LIST_INSERT_HEAD(&bus->children, dev, sibling);
+    QLIST_INSERT_HEAD(&bus->children, dev, sibling);
     return dev;
 }
 
@@ -235,7 +235,7 @@ void qdev_free(DeviceState *dev)
 #endif
     if (dev->info->reset)
         qemu_unregister_reset(dev->info->reset, dev);
-    LIST_REMOVE(dev, sibling);
+    QLIST_REMOVE(dev, sibling);
     qemu_free(dev);
 }
 
@@ -321,7 +321,7 @@ BusState *qdev_get_child_bus(DeviceState *dev, const char *name)
 {
     BusState *bus;
 
-    LIST_FOREACH(bus, &dev->child_bus, sibling) {
+    QLIST_FOREACH(bus, &dev->child_bus, sibling) {
         if (strcmp(name, bus->name) == 0) {
             return bus;
         }
@@ -346,8 +346,8 @@ static BusState *qbus_find_recursive(BusState *bus, const char *name,
         return bus;
     }
 
-    LIST_FOREACH(dev, &bus->children, sibling) {
-        LIST_FOREACH(child, &dev->child_bus, sibling) {
+    QLIST_FOREACH(dev, &bus->children, sibling) {
+        QLIST_FOREACH(child, &dev->child_bus, sibling) {
             ret = qbus_find_recursive(child, name, info);
             if (ret) {
                 return ret;
@@ -365,7 +365,7 @@ static void qbus_list_bus(DeviceState *dev, char *dest, int len)
 
     pos += snprintf(dest+pos, len-pos,"child busses at \"%s\":",
                     dev->id ? dev->id : dev->info->name);
-    LIST_FOREACH(child, &dev->child_bus, sibling) {
+    QLIST_FOREACH(child, &dev->child_bus, sibling) {
         pos += snprintf(dest+pos, len-pos, "%s\"%s\"", sep, child->name);
         sep = ", ";
     }
@@ -379,7 +379,7 @@ static void qbus_list_dev(BusState *bus, char *dest, int len)
 
     pos += snprintf(dest+pos, len-pos, "devices at \"%s\":",
                     bus->name);
-    LIST_FOREACH(dev, &bus->children, sibling) {
+    QLIST_FOREACH(dev, &bus->children, sibling) {
         pos += snprintf(dest+pos, len-pos, "%s\"%s\"",
                         sep, dev->info->name);
         if (dev->id)
@@ -392,7 +392,7 @@ static BusState *qbus_find_bus(DeviceState *dev, char *elem)
 {
     BusState *child;
 
-    LIST_FOREACH(child, &dev->child_bus, sibling) {
+    QLIST_FOREACH(child, &dev->child_bus, sibling) {
         if (strcmp(child->name, elem) == 0) {
             return child;
         }
@@ -410,17 +410,17 @@ static DeviceState *qbus_find_dev(BusState *bus, char *elem)
      *   (2) driver name
      *   (3) driver alias, if present
      */
-    LIST_FOREACH(dev, &bus->children, sibling) {
+    QLIST_FOREACH(dev, &bus->children, sibling) {
         if (dev->id  &&  strcmp(dev->id, elem) == 0) {
             return dev;
         }
     }
-    LIST_FOREACH(dev, &bus->children, sibling) {
+    QLIST_FOREACH(dev, &bus->children, sibling) {
         if (strcmp(dev->info->name, elem) == 0) {
             return dev;
         }
     }
-    LIST_FOREACH(dev, &bus->children, sibling) {
+    QLIST_FOREACH(dev, &bus->children, sibling) {
         if (dev->info->alias && strcmp(dev->info->alias, elem) == 0) {
             return dev;
         }
@@ -478,7 +478,7 @@ static BusState *qbus_find(const char *path)
                 qemu_error("device has no child bus (%s)\n", path);
                 return NULL;
             case 1:
-                return LIST_FIRST(&dev->child_bus);
+                return QLIST_FIRST(&dev->child_bus);
             default:
                 qbus_list_bus(dev, msg, sizeof(msg));
                 qemu_error("device has multiple child busses (%s)\n%s\n",
@@ -532,9 +532,9 @@ BusState *qbus_create(BusInfo *info, DeviceState *parent, const char *name)
         bus->name = buf;
     }
 
-    LIST_INIT(&bus->children);
+    QLIST_INIT(&bus->children);
     if (parent) {
-        LIST_INSERT_HEAD(&parent->child_bus, bus, sibling);
+        QLIST_INSERT_HEAD(&parent->child_bus, bus, sibling);
         parent->num_child_bus++;
     }
     return bus;
@@ -575,7 +575,7 @@ static void qdev_print(Monitor *mon, DeviceState *dev, int indent)
     qdev_print_props(mon, dev, dev->parent_bus->info->props, "bus", indent);
     if (dev->parent_bus->info->print_dev)
         dev->parent_bus->info->print_dev(mon, dev, indent);
-    LIST_FOREACH(child, &dev->child_bus, sibling) {
+    QLIST_FOREACH(child, &dev->child_bus, sibling) {
         qbus_print(mon, child, indent);
     }
 }
@@ -587,7 +587,7 @@ static void qbus_print(Monitor *mon, BusState *bus, int indent)
     qdev_printf("bus: %s\n", bus->name);
     indent += 2;
     qdev_printf("type %s\n", bus->info->name);
-    LIST_FOREACH(dev, &bus->children, sibling) {
+    QLIST_FOREACH(dev, &bus->children, sibling) {
         qdev_print(mon, dev, indent);
     }
 }
