Patchwork [21/24] qdev: add weak alias to sysbus_get_default() on qdev.c

login
register
mail settings
Submitter Eduardo Habkost
Date Nov. 9, 2012, 2:56 p.m.
Message ID <1352473012-20500-22-git-send-email-ehabkost@redhat.com>
Download mbox | patch
Permalink /patch/198121/
State New
Headers show

Comments

Eduardo Habkost - Nov. 9, 2012, 2:56 p.m.
This version will be used on cases where sysbus.c is not compiled in
(e.g. *-user).

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Changes v1 -> v2:
 - Use the new QEMU_WEAK_ALIAS mechanism, instead of GCC_WEAK
---
 hw/qdev-core.h |  5 ++++-
 hw/qdev.c      | 13 +++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

Patch

diff --git a/hw/qdev-core.h b/hw/qdev-core.h
index 494b687..b64daf0 100644
--- a/hw/qdev-core.h
+++ b/hw/qdev-core.h
@@ -193,7 +193,10 @@  void qbus_free(BusState *bus);
 
 #define FROM_QBUS(type, dev) DO_UPCAST(type, qbus, dev)
 
-/* This should go away once we get rid of the NULL bus hack */
+/* This should go away once we get rid of the NULL bus hack.
+ * This has a weak alias for a stub function on qdev.c (for *-user, that
+ * doesn't have a main system bus).
+ */
 BusState *sysbus_get_default(void);
 
 char *qdev_get_fw_dev_path(DeviceState *dev);
diff --git a/hw/qdev.c b/hw/qdev.c
index 94ae1cd..0702659 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -100,6 +100,19 @@  static void stub_vmstate_unregister(DeviceState *dev,
 }
 QEMU_WEAK_ALIAS(vmstate_unregister, stub_vmstate_unregister);
 
+
+/* sysbus stub functions
+ *
+ * The real implementation is on sysbus.c, but the stub functions will be used
+ * on cases where sysbus.c is not compiled in (e.g. *-user).
+ */
+
+static BusState *sysbus_get_none(void)
+{
+    return NULL;
+}
+QEMU_WEAK_ALIAS(sysbus_get_default, sysbus_get_none);
+
 const VMStateDescription *qdev_get_vmsd(DeviceState *dev)
 {
     DeviceClass *dc = DEVICE_GET_CLASS(dev);