[PATCH v4 05/16] qom/object.c: add object_class_property_add_uint64_ptr()
Mark Cave-Ayland <[email protected]>
| Newsgroups | org.nongnu.qemu-arm,org.nongnu.qemu-devel |
|---|---|
| Message-ID | <[email protected]> |
This adds a class property that references a uint8_t within the object instance and is intended to be a replacement for object_property_add_uint64_ptr(). Signed-off-by: Mark Cave-Ayland <[email protected]> --- include/qom/object.h | 18 ++++++++++++++++++ qom/object.c | 21 +++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/include/qom/object.h b/include/qom/object.h index eba675d218..67ccd2b08f 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -2168,6 +2168,24 @@ ObjectProperty *object_property_add_uint64_ptr(Object *obj, const char *name, const uint64_t *v, ObjectPropertyFlags flags); +/** + * object_class_property_add_uint64_ptr: + * @klass: the object class to add a property to + * @name: the name of the property + * @offset: the offset from the object instance where the uint64 value is + * stored + * @flags: bitwise-or'd ObjectPropertyFlags + * + * Add an integer property in memory. This function will add a + * property of type 'uint64'. + * + * Returns: The newly added property on success, or %NULL on failure. + */ +ObjectProperty *object_class_property_add_uint64_ptr(ObjectClass *klass, + const char *name, + ptrdiff_t offset, + ObjectPropertyFlags flags); + /** * object_class_static_property_add_uint64_ptr: * @klass: the object class to add a static property to diff --git a/qom/object.c b/qom/object.c index a480fdd400..271c2916b7 100644 --- a/qom/object.c +++ b/qom/object.c @@ -2742,6 +2742,7 @@ static void *object_class_prop_ptr(Object *obj, ptrdiff_t offset) OBJECT_CLASS_PROPERTY_SCALAR_SETTER(type) DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(uint8) +DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(uint64) #undef OBJECT_CLASS_PROPERTY_SCALAR_GETTER #undef OBJECT_CLASS_PROPERTY_SCALAR_SETTER @@ -2911,6 +2912,26 @@ object_property_add_uint64_ptr(Object *obj, const char *name, getter, setter, NULL, (void *)v); } +ObjectProperty * +object_class_property_add_uint64_ptr(ObjectClass *klass, const char *name, + ptrdiff_t offset, + ObjectPropertyFlags flags) +{ + ObjectPropertyAccessor *getter = NULL; + ObjectPropertyAccessor *setter = NULL; + + if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) { + getter = property_class_get_uint64_ptr; + } + + if ((flags & OBJ_PROP_FLAG_WRITE) == OBJ_PROP_FLAG_WRITE) { + setter = property_class_set_uint64_ptr; + } + + return object_class_property_add(klass, name, "uint64", + getter, setter, NULL, (void *)offset); +} + ObjectProperty * object_class_static_property_add_uint64_ptr(ObjectClass *klass, const char *name, -- 2.43.0