* [Qemu-devel] [PATCH v2 0/7] qdev: compat properties.
@ 2009-07-13 9:40 Gerd Hoffmann
2009-07-13 9:40 ` [Qemu-devel] [PATCH 1/7] cleanup: drop unused struct elements from VirtIOPCIProxy Gerd Hoffmann
` (6 more replies)
0 siblings, 7 replies; 14+ messages in thread
From: Gerd Hoffmann @ 2009-07-13 9:40 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Hi,
Respin of the compat property patch series, addressing review comments.
cheers,
Gerd
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH 1/7] cleanup: drop unused struct elements from VirtIOPCIProxy.
2009-07-13 9:40 [Qemu-devel] [PATCH v2 0/7] qdev: compat properties Gerd Hoffmann
@ 2009-07-13 9:40 ` Gerd Hoffmann
2009-07-13 9:40 ` [Qemu-devel] [PATCH 2/7] add strify() macros Gerd Hoffmann
` (5 subsequent siblings)
6 siblings, 0 replies; 14+ messages in thread
From: Gerd Hoffmann @ 2009-07-13 9:40 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/virtio-pci.c | 6 ------
1 files changed, 0 insertions(+), 6 deletions(-)
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index 3b9bfd1..0671967 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -86,12 +86,6 @@ typedef struct {
PCIDevice pci_dev;
VirtIODevice *vdev;
uint32_t addr;
-
- uint16_t vendor;
- uint16_t device;
- uint16_t subvendor;
- uint16_t class_code;
- uint8_t pif;
} VirtIOPCIProxy;
/* virtio device */
--
1.6.2.5
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH 2/7] add strify() macros.
2009-07-13 9:40 [Qemu-devel] [PATCH v2 0/7] qdev: compat properties Gerd Hoffmann
2009-07-13 9:40 ` [Qemu-devel] [PATCH 1/7] cleanup: drop unused struct elements from VirtIOPCIProxy Gerd Hoffmann
@ 2009-07-13 9:40 ` Gerd Hoffmann
2009-07-13 13:54 ` Anthony Liguori
2009-07-13 9:40 ` [Qemu-devel] [PATCH 3/7] qdev/compat: compat property infrastructure Gerd Hoffmann
` (4 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Gerd Hoffmann @ 2009-07-13 9:40 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
osdep.h | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/osdep.h b/osdep.h
index ffbf221..ac660c8 100644
--- a/osdep.h
+++ b/osdep.h
@@ -27,6 +27,11 @@
#define unlikely(x) __builtin_expect(!!(x), 0)
#endif
+#ifndef strify
+#define strify_i(a) # a
+#define strify(a) strify_i(a)
+#endif
+
#ifndef offsetof
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) 0)->MEMBER)
#endif
--
1.6.2.5
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH 3/7] qdev/compat: compat property infrastructure.
2009-07-13 9:40 [Qemu-devel] [PATCH v2 0/7] qdev: compat properties Gerd Hoffmann
2009-07-13 9:40 ` [Qemu-devel] [PATCH 1/7] cleanup: drop unused struct elements from VirtIOPCIProxy Gerd Hoffmann
2009-07-13 9:40 ` [Qemu-devel] [PATCH 2/7] add strify() macros Gerd Hoffmann
@ 2009-07-13 9:40 ` Gerd Hoffmann
2009-07-13 9:40 ` [Qemu-devel] [PATCH 4/7] qdev/compat: add pc-0.10 machine type Gerd Hoffmann
` (3 subsequent siblings)
6 siblings, 0 replies; 14+ messages in thread
From: Gerd Hoffmann @ 2009-07-13 9:40 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/boards.h | 1 +
hw/qdev-properties.c | 19 +++++++++++++++++++
hw/qdev.c | 1 +
hw/qdev.h | 11 +++++++++++
vl.c | 2 ++
5 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/hw/boards.h b/hw/boards.h
index f6733b7..5a07d07 100644
--- a/hw/boards.h
+++ b/hw/boards.h
@@ -17,6 +17,7 @@ typedef struct QEMUMachine {
int use_scsi;
int max_cpus;
int is_default;
+ struct CompatProperty *compat_props;
struct QEMUMachine *next;
} QEMUMachine;
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index 3c31e31..7f58d69 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -240,3 +240,22 @@ void qdev_prop_set_defaults(DeviceState *dev, Property *props)
}
}
+static CompatProperty *compat_props;
+
+void qdev_register_compat_props(CompatProperty *props)
+{
+ compat_props = props;
+}
+
+void qdev_prop_set_compat(DeviceState *dev)
+{
+ CompatProperty *prop;
+
+ if (!compat_props)
+ return;
+ for (prop = compat_props; prop->driver != NULL; prop++) {
+ if (strcmp(dev->info->name, prop->driver) != 0)
+ continue;
+ qdev_prop_parse(dev, prop->property, prop->value);
+ }
+}
diff --git a/hw/qdev.c b/hw/qdev.c
index a075e86..669a642 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -98,6 +98,7 @@ DeviceState *qdev_create(BusState *bus, const char *name)
dev->parent_bus = bus;
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);
return dev;
}
diff --git a/hw/qdev.h b/hw/qdev.h
index 6b35961..7f70934 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -8,6 +8,8 @@ typedef struct Property Property;
typedef struct PropertyInfo PropertyInfo;
+typedef struct CompatProperty CompatProperty;
+
typedef struct DeviceInfo DeviceInfo;
typedef struct BusState BusState;
@@ -61,6 +63,12 @@ struct PropertyInfo {
int (*print)(DeviceState *dev, Property *prop, char *dest, size_t len);
};
+struct CompatProperty {
+ const char *driver;
+ const char *property;
+ const char *value;
+};
+
/*** Board API. This should go away once we have a machine config file. ***/
DeviceState *qdev_create(BusState *bus, const char *name);
@@ -144,4 +152,7 @@ int qdev_prop_set_uint32(DeviceState *dev, const char *name, uint32_t value);
int qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value);
void qdev_prop_set_defaults(DeviceState *dev, Property *props);
+void qdev_register_compat_props(CompatProperty *props);
+void qdev_prop_set_compat(DeviceState *dev);
+
#endif
diff --git a/vl.c b/vl.c
index cdc7b8a..5402787 100644
--- a/vl.c
+++ b/vl.c
@@ -5911,6 +5911,8 @@ int main(int argc, char **argv, char **envp)
module_call_init(MODULE_INIT_DEVICE);
+ if (machine->compat_props)
+ qdev_register_compat_props(machine->compat_props);
machine->init(ram_size, boot_devices,
kernel_filename, kernel_cmdline, initrd_filename, cpu_model);
--
1.6.2.5
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH 4/7] qdev/compat: add pc-0.10 machine type.
2009-07-13 9:40 [Qemu-devel] [PATCH v2 0/7] qdev: compat properties Gerd Hoffmann
` (2 preceding siblings ...)
2009-07-13 9:40 ` [Qemu-devel] [PATCH 3/7] qdev/compat: compat property infrastructure Gerd Hoffmann
@ 2009-07-13 9:40 ` Gerd Hoffmann
2009-07-13 9:40 ` [Qemu-devel] [PATCH 5/7] qdev/compat: virtio-blk-pci 0.10 compatibility Gerd Hoffmann
` (2 subsequent siblings)
6 siblings, 0 replies; 14+ messages in thread
From: Gerd Hoffmann @ 2009-07-13 9:40 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/pc.c | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/hw/pc.c b/hw/pc.c
index ccd2fed..6ba6b25 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1457,6 +1457,16 @@ static QEMUMachine pc_machine = {
.is_default = 1,
};
+static QEMUMachine pc_machine_v0_10 = {
+ .name = "pc-0.10",
+ .desc = "Standard PC, qemu 0.10",
+ .init = pc_init_pci,
+ .max_cpus = 255,
+ .compat_props = (CompatProperty[]) {
+ { /* end of list */ }
+ },
+};
+
static QEMUMachine isapc_machine = {
.name = "isapc",
.desc = "ISA-only PC",
@@ -1467,6 +1477,7 @@ static QEMUMachine isapc_machine = {
static void pc_machine_init(void)
{
qemu_register_machine(&pc_machine);
+ qemu_register_machine(&pc_machine_v0_10);
qemu_register_machine(&isapc_machine);
}
--
1.6.2.5
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH 5/7] qdev/compat: virtio-blk-pci 0.10 compatibility.
2009-07-13 9:40 [Qemu-devel] [PATCH v2 0/7] qdev: compat properties Gerd Hoffmann
` (3 preceding siblings ...)
2009-07-13 9:40 ` [Qemu-devel] [PATCH 4/7] qdev/compat: add pc-0.10 machine type Gerd Hoffmann
@ 2009-07-13 9:40 ` Gerd Hoffmann
2009-07-13 9:40 ` [Qemu-devel] [PATCH 6/7] qdev/compat: virtio-balloon-pci " Gerd Hoffmann
2009-07-13 9:40 ` [Qemu-devel] [PATCH 7/7] qdev/compat: virtio-net-pci " Gerd Hoffmann
6 siblings, 0 replies; 14+ messages in thread
From: Gerd Hoffmann @ 2009-07-13 9:40 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/pc.c | 5 +++++
hw/virtio-pci.c | 16 ++++++++++++++--
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/hw/pc.c b/hw/pc.c
index 6ba6b25..a43dff7 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1463,6 +1463,11 @@ static QEMUMachine pc_machine_v0_10 = {
.init = pc_init_pci,
.max_cpus = 255,
.compat_props = (CompatProperty[]) {
+ {
+ .driver = "virtio-blk-pci",
+ .property = "class",
+ .value = strify(PCI_CLASS_STORAGE_OTHER),
+ },
{ /* end of list */ }
},
};
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index 0671967..41ba574 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -86,6 +86,7 @@ typedef struct {
PCIDevice pci_dev;
VirtIODevice *vdev;
uint32_t addr;
+ uint32_t class_code;
} VirtIOPCIProxy;
/* virtio device */
@@ -425,12 +426,15 @@ static void virtio_blk_init_pci(PCIDevice *pci_dev)
VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
VirtIODevice *vdev;
+ if (proxy->class_code != PCI_CLASS_STORAGE_SCSI &&
+ proxy->class_code != PCI_CLASS_STORAGE_OTHER)
+ proxy->class_code = PCI_CLASS_STORAGE_SCSI;
+
vdev = virtio_blk_init(&pci_dev->qdev);
virtio_init_pci(proxy, vdev,
PCI_VENDOR_ID_REDHAT_QUMRANET,
PCI_DEVICE_ID_VIRTIO_BLOCK,
- PCI_CLASS_STORAGE_OTHER,
- 0x00);
+ proxy->class_code, 0x00);
}
static void virtio_console_init_pci(PCIDevice *pci_dev)
@@ -477,6 +481,14 @@ static PCIDeviceInfo virtio_info[] = {
.qdev.name = "virtio-blk-pci",
.qdev.size = sizeof(VirtIOPCIProxy),
.init = virtio_blk_init_pci,
+ .qdev.props = (Property[]) {
+ {
+ .name = "class",
+ .info = &qdev_prop_hex32,
+ .offset = offsetof(VirtIOPCIProxy, class_code),
+ },
+ {/* end of list */}
+ },
},{
.qdev.name = "virtio-net-pci",
.qdev.size = sizeof(VirtIOPCIProxy),
--
1.6.2.5
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH 6/7] qdev/compat: virtio-balloon-pci 0.10 compatibility.
2009-07-13 9:40 [Qemu-devel] [PATCH v2 0/7] qdev: compat properties Gerd Hoffmann
` (4 preceding siblings ...)
2009-07-13 9:40 ` [Qemu-devel] [PATCH 5/7] qdev/compat: virtio-blk-pci 0.10 compatibility Gerd Hoffmann
@ 2009-07-13 9:40 ` Gerd Hoffmann
2009-07-13 9:40 ` [Qemu-devel] [PATCH 7/7] qdev/compat: virtio-net-pci " Gerd Hoffmann
6 siblings, 0 replies; 14+ messages in thread
From: Gerd Hoffmann @ 2009-07-13 9:40 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/pc.c | 4 ++++
hw/virtio-pci.c | 16 ++++++++++++++--
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/hw/pc.c b/hw/pc.c
index a43dff7..b33e696 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1467,6 +1467,10 @@ static QEMUMachine pc_machine_v0_10 = {
.driver = "virtio-blk-pci",
.property = "class",
.value = strify(PCI_CLASS_STORAGE_OTHER),
+ },{
+ .driver = "virtio-console-pci",
+ .property = "class",
+ .value = strify(PCI_CLASS_DISPLAY_OTHER),
},
{ /* end of list */ }
},
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index 41ba574..f186b53 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -442,12 +442,16 @@ static void virtio_console_init_pci(PCIDevice *pci_dev)
VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
VirtIODevice *vdev;
+ if (proxy->class_code != PCI_CLASS_COMMUNICATION_OTHER &&
+ proxy->class_code != PCI_CLASS_DISPLAY_OTHER && /* qemu 0.10 */
+ proxy->class_code != PCI_CLASS_OTHERS) /* qemu-kvm */
+ proxy->class_code = PCI_CLASS_COMMUNICATION_OTHER;
+
vdev = virtio_console_init(&pci_dev->qdev);
virtio_init_pci(proxy, vdev,
PCI_VENDOR_ID_REDHAT_QUMRANET,
PCI_DEVICE_ID_VIRTIO_CONSOLE,
- PCI_CLASS_DISPLAY_OTHER,
- 0x00);
+ proxy->class_code, 0x00);
}
static void virtio_net_init_pci(PCIDevice *pci_dev)
@@ -497,6 +501,14 @@ static PCIDeviceInfo virtio_info[] = {
.qdev.name = "virtio-console-pci",
.qdev.size = sizeof(VirtIOPCIProxy),
.init = virtio_console_init_pci,
+ .qdev.props = (Property[]) {
+ {
+ .name = "class",
+ .info = &qdev_prop_hex32,
+ .offset = offsetof(VirtIOPCIProxy, class_code),
+ },
+ {/* end of list */}
+ },
},{
.qdev.name = "virtio-balloon-pci",
.qdev.size = sizeof(VirtIOPCIProxy),
--
1.6.2.5
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH 7/7] qdev/compat: virtio-net-pci 0.10 compatibility.
2009-07-13 9:40 [Qemu-devel] [PATCH v2 0/7] qdev: compat properties Gerd Hoffmann
` (5 preceding siblings ...)
2009-07-13 9:40 ` [Qemu-devel] [PATCH 6/7] qdev/compat: virtio-balloon-pci " Gerd Hoffmann
@ 2009-07-13 9:40 ` Gerd Hoffmann
6 siblings, 0 replies; 14+ messages in thread
From: Gerd Hoffmann @ 2009-07-13 9:40 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/pc.c | 4 ++++
hw/virtio-pci.c | 27 ++++++++++++++++++++++++---
2 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/hw/pc.c b/hw/pc.c
index b33e696..8f35d24 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1471,6 +1471,10 @@ static QEMUMachine pc_machine_v0_10 = {
.driver = "virtio-console-pci",
.property = "class",
.value = strify(PCI_CLASS_DISPLAY_OTHER),
+ },{
+ .driver = "virtio-net-pci",
+ .property = "vectors",
+ .value = "0",
},
{ /* end of list */ }
},
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index f186b53..703f4fe 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -19,6 +19,7 @@
#include "pci.h"
//#include "sysemu.h"
#include "msix.h"
+#include "net.h"
/* from Linux's linux/virtio_pci.h */
@@ -87,6 +88,7 @@ typedef struct {
VirtIODevice *vdev;
uint32_t addr;
uint32_t class_code;
+ uint32_t nvectors;
} VirtIOPCIProxy;
/* virtio device */
@@ -460,11 +462,21 @@ static void virtio_net_init_pci(PCIDevice *pci_dev)
VirtIODevice *vdev;
vdev = virtio_net_init(&pci_dev->qdev);
+
+ /* set nvectors from property, unless the user specified something
+ * via -net nic,model=virtio,vectors=n command line option */
+ if (pci_dev->qdev.nd->nvectors == NIC_NVECTORS_UNSPECIFIED)
+ if (proxy->nvectors != NIC_NVECTORS_UNSPECIFIED)
+ vdev->nvectors = proxy->nvectors;
+
virtio_init_pci(proxy, vdev,
PCI_VENDOR_ID_REDHAT_QUMRANET,
PCI_DEVICE_ID_VIRTIO_NET,
PCI_CLASS_NETWORK_ETHERNET,
0x00);
+
+ /* make the actual value visible */
+ proxy->nvectors = vdev->nvectors;
}
static void virtio_balloon_init_pci(PCIDevice *pci_dev)
@@ -494,9 +506,18 @@ static PCIDeviceInfo virtio_info[] = {
{/* end of list */}
},
},{
- .qdev.name = "virtio-net-pci",
- .qdev.size = sizeof(VirtIOPCIProxy),
- .init = virtio_net_init_pci,
+ .qdev.name = "virtio-net-pci",
+ .qdev.size = sizeof(VirtIOPCIProxy),
+ .init = virtio_net_init_pci,
+ .qdev.props = (Property[]) {
+ {
+ .name = "vectors",
+ .info = &qdev_prop_uint32,
+ .offset = offsetof(VirtIOPCIProxy, nvectors),
+ .defval = (uint32_t[]) { NIC_NVECTORS_UNSPECIFIED },
+ },
+ {/* end of list */}
+ },
},{
.qdev.name = "virtio-console-pci",
.qdev.size = sizeof(VirtIOPCIProxy),
--
1.6.2.5
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH 2/7] add strify() macros.
2009-07-13 9:40 ` [Qemu-devel] [PATCH 2/7] add strify() macros Gerd Hoffmann
@ 2009-07-13 13:54 ` Anthony Liguori
2009-07-13 14:59 ` Blue Swirl
2009-07-13 15:19 ` [Qemu-devel] " Gerd Hoffmann
0 siblings, 2 replies; 14+ messages in thread
From: Anthony Liguori @ 2009-07-13 13:54 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: qemu-devel, Paul Brook
Gerd Hoffmann wrote:
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> osdep.h | 5 +++++
> 1 files changed, 5 insertions(+), 0 deletions(-)
>
> diff --git a/osdep.h b/osdep.h
> index ffbf221..ac660c8 100644
> --- a/osdep.h
> +++ b/osdep.h
> @@ -27,6 +27,11 @@
> #define unlikely(x) __builtin_expect(!!(x), 0)
> #endif
>
> +#ifndef strify
> +#define strify_i(a) # a
> +#define strify(a) strify_i(a)
> +#endif
> +
>
Could get even fancier with something like:
#define strify_i(a) # a
#define strify(a) strify_i(a)
#define to_prop(a) __builtin_choose_expr( \
__builtin_types_compatible_p(typeof(a), const char []), \
(a), \
__builtin_choose_expr( \
__builtin_types_compatible_p(typeof(a), int) || \
__builtin_types_compatible_p(typeof(a), double), \
strify(a), \
(int *)0))
It should be possible to use to_prop() for any property initializer.
Regards,
Anthony Liguori
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH 2/7] add strify() macros.
2009-07-13 13:54 ` Anthony Liguori
@ 2009-07-13 14:59 ` Blue Swirl
2009-07-13 15:08 ` Anthony Liguori
` (2 more replies)
2009-07-13 15:19 ` [Qemu-devel] " Gerd Hoffmann
1 sibling, 3 replies; 14+ messages in thread
From: Blue Swirl @ 2009-07-13 14:59 UTC (permalink / raw)
To: Anthony Liguori; +Cc: Paul Brook, Gerd Hoffmann, qemu-devel
On 7/13/09, Anthony Liguori <anthony@codemonkey.ws> wrote:
> Gerd Hoffmann wrote:
>
> > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> > ---
> > osdep.h | 5 +++++
> > 1 files changed, 5 insertions(+), 0 deletions(-)
> >
> > diff --git a/osdep.h b/osdep.h
> > index ffbf221..ac660c8 100644
> > --- a/osdep.h
> > +++ b/osdep.h
> > @@ -27,6 +27,11 @@
> > #define unlikely(x) __builtin_expect(!!(x), 0)
> > #endif
> > +#ifndef strify
> > +#define strify_i(a) # a
> > +#define strify(a) strify_i(a)
> > +#endif
> > +
> >
> >
>
> Could get even fancier with something like:
>
> #define strify_i(a) # a
> #define strify(a) strify_i(a)
What's wrong with the almost identical stringify() macro?
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH 2/7] add strify() macros.
2009-07-13 14:59 ` Blue Swirl
@ 2009-07-13 15:08 ` Anthony Liguori
2009-07-13 15:15 ` Gerd Hoffmann
2009-07-13 15:18 ` [Qemu-devel] " Måns Rullgård
2 siblings, 0 replies; 14+ messages in thread
From: Anthony Liguori @ 2009-07-13 15:08 UTC (permalink / raw)
To: Blue Swirl; +Cc: Paul Brook, Gerd Hoffmann, qemu-devel
Blue Swirl wrote:
> What's wrong with the almost identical stringify() macro?
>
It's fine, I didn't know it existed :-)
Regards,
Anthony Liguori
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH 2/7] add strify() macros.
2009-07-13 14:59 ` Blue Swirl
2009-07-13 15:08 ` Anthony Liguori
@ 2009-07-13 15:15 ` Gerd Hoffmann
2009-07-13 15:18 ` [Qemu-devel] " Måns Rullgård
2 siblings, 0 replies; 14+ messages in thread
From: Gerd Hoffmann @ 2009-07-13 15:15 UTC (permalink / raw)
To: Blue Swirl; +Cc: qemu-devel, Paul Brook
On 07/13/09 16:59, Blue Swirl wrote:
> On 7/13/09, Anthony Liguori<anthony@codemonkey.ws> wrote:
>> #define strify_i(a) # a
>> #define strify(a) strify_i(a)
>
> What's wrong with the almost identical stringify() macro?
Nothing, just havn't noticed it, fixing ...
cheers,
Gerd
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Qemu-devel] Re: [PATCH 2/7] add strify() macros.
2009-07-13 14:59 ` Blue Swirl
2009-07-13 15:08 ` Anthony Liguori
2009-07-13 15:15 ` Gerd Hoffmann
@ 2009-07-13 15:18 ` Måns Rullgård
2 siblings, 0 replies; 14+ messages in thread
From: Måns Rullgård @ 2009-07-13 15:18 UTC (permalink / raw)
To: qemu-devel
Blue Swirl <blauwirbel@gmail.com> writes:
> On 7/13/09, Anthony Liguori <anthony@codemonkey.ws> wrote:
>> Gerd Hoffmann wrote:
>>
>> > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
>> > ---
>> > osdep.h | 5 +++++
>> > 1 files changed, 5 insertions(+), 0 deletions(-)
>> >
>> > diff --git a/osdep.h b/osdep.h
>> > index ffbf221..ac660c8 100644
>> > --- a/osdep.h
>> > +++ b/osdep.h
>> > @@ -27,6 +27,11 @@
>> > #define unlikely(x) __builtin_expect(!!(x), 0)
>> > #endif
>> > +#ifndef strify
>> > +#define strify_i(a) # a
>> > +#define strify(a) strify_i(a)
>> > +#endif
>> > +
>> >
>> >
>>
>> Could get even fancier with something like:
>>
>> #define strify_i(a) # a
>> #define strify(a) strify_i(a)
>
> What's wrong with the almost identical stringify() macro?
Both are wrong in that any name beginning with 'str' is reserved for
future expansion of the standard C library if the string.h header is
used.
--
Måns Rullgård
mans@mansr.com
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH 2/7] add strify() macros.
2009-07-13 13:54 ` Anthony Liguori
2009-07-13 14:59 ` Blue Swirl
@ 2009-07-13 15:19 ` Gerd Hoffmann
1 sibling, 0 replies; 14+ messages in thread
From: Gerd Hoffmann @ 2009-07-13 15:19 UTC (permalink / raw)
To: Anthony Liguori; +Cc: qemu-devel, Paul Brook
On 07/13/09 15:54, Anthony Liguori wrote:
> Gerd Hoffmann wrote:
> Could get even fancier with something like:
>
> #define strify_i(a) # a
> #define strify(a) strify_i(a)
>
> #define to_prop(a) __builtin_choose_expr( \
> __builtin_types_compatible_p(typeof(a), const char []), \
> (a), \
> __builtin_choose_expr( \
> __builtin_types_compatible_p(typeof(a), int) || \
> __builtin_types_compatible_p(typeof(a), double), \
> strify(a), \
> (int *)0))
>
> It should be possible to use to_prop() for any property initializer.
Hmm? This is how related to properties? To me it looks just like a
stringify version which accepts strings too and does nothing for them.
Not sure why this would be useful ...
cheers,
Gerd
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2009-07-13 15:21 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-13 9:40 [Qemu-devel] [PATCH v2 0/7] qdev: compat properties Gerd Hoffmann
2009-07-13 9:40 ` [Qemu-devel] [PATCH 1/7] cleanup: drop unused struct elements from VirtIOPCIProxy Gerd Hoffmann
2009-07-13 9:40 ` [Qemu-devel] [PATCH 2/7] add strify() macros Gerd Hoffmann
2009-07-13 13:54 ` Anthony Liguori
2009-07-13 14:59 ` Blue Swirl
2009-07-13 15:08 ` Anthony Liguori
2009-07-13 15:15 ` Gerd Hoffmann
2009-07-13 15:18 ` [Qemu-devel] " Måns Rullgård
2009-07-13 15:19 ` [Qemu-devel] " Gerd Hoffmann
2009-07-13 9:40 ` [Qemu-devel] [PATCH 3/7] qdev/compat: compat property infrastructure Gerd Hoffmann
2009-07-13 9:40 ` [Qemu-devel] [PATCH 4/7] qdev/compat: add pc-0.10 machine type Gerd Hoffmann
2009-07-13 9:40 ` [Qemu-devel] [PATCH 5/7] qdev/compat: virtio-blk-pci 0.10 compatibility Gerd Hoffmann
2009-07-13 9:40 ` [Qemu-devel] [PATCH 6/7] qdev/compat: virtio-balloon-pci " Gerd Hoffmann
2009-07-13 9:40 ` [Qemu-devel] [PATCH 7/7] qdev/compat: virtio-net-pci " Gerd Hoffmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).