diff options
| author | Peter Maydell <peter.maydell@linaro.org> | 2020-09-21 18:55:39 +0100 |
|---|---|---|
| committer | Peter Maydell <peter.maydell@linaro.org> | 2020-09-21 18:55:39 +0100 |
| commit | 4dad0a9aa818698e0735c8352bf7925a1660df6f (patch) | |
| tree | 325a8c11dfaeb57fcd69a9613582a2c4ba3d29b4 /include/qom/object.h | |
| parent | 5df6c87e8080e0021e975c8387baa20cfe43c932 (diff) | |
| parent | 8063396bf3459a810d24e3efd6110b8480f0de5b (diff) | |
| download | focaccia-qemu-4dad0a9aa818698e0735c8352bf7925a1660df6f.tar.gz focaccia-qemu-4dad0a9aa818698e0735c8352bf7925a1660df6f.zip | |
Merge remote-tracking branch 'remotes/ehabkost/tags/machine-next-pull-request' into staging
QOM queue, 2020-09-18 Fixes: * Error value corrections (Markus Armbruster) * Correct object_class_dynamic_cast_assert() documentation (Eduardo Habkost) * Ensure objects using QEMU_ALIGNED are properly aligned (Richard Henderson) QOM cleanups (Eduardo Habkost): * Rename some constants * Simplify parameters of OBJECT_DECLARE* macros * Additional DECLARE_*CHECKER* usage * Additional OBJECT_DECLARE_TYPE usage * Additional OBJECT_DECLARE_SIMPLE_TYPE usage # gpg: Signature made Fri 18 Sep 2020 21:45:29 BST # gpg: using RSA key 5A322FD5ABC4D3DBACCFD1AA2807936F984DC5A6 # gpg: issuer "ehabkost@redhat.com" # gpg: Good signature from "Eduardo Habkost <ehabkost@redhat.com>" [full] # Primary key fingerprint: 5A32 2FD5 ABC4 D3DB ACCF D1AA 2807 936F 984D C5A6 * remotes/ehabkost/tags/machine-next-pull-request: Use OBJECT_DECLARE_SIMPLE_TYPE when possible Use OBJECT_DECLARE_TYPE when possible qom: Remove module_obj_name parameter from OBJECT_DECLARE* macros qom: Remove ParentClassType argument from OBJECT_DECLARE_SIMPLE_TYPE scripts/codeconverter: Update to latest version target/s390x: Set instance_align on S390CPU TypeInfo target/riscv: Set instance_align on RISCVCPU TypeInfo target/ppc: Set instance_align on PowerPCCPU TypeInfo target/arm: Set instance_align on CPUARM TypeInfo qom: Allow objects to be allocated with increased alignment qom: Correct error values in two contracts qom: Clean up object_property_get_enum()'s error value qom: Correct object_class_dynamic_cast_assert() documentation sifive: Use DECLARE_*CHECKER* macros sifive: Move QOM typedefs and add missing includes sifive_u: Rename memmap enum constants sifive_e: Rename memmap enum constants Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'include/qom/object.h')
| -rw-r--r-- | include/qom/object.h | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/include/qom/object.h b/include/qom/object.h index 056f67ab3b..19cccd3f5f 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -614,7 +614,6 @@ struct Object * OBJECT_DECLARE_TYPE: * @InstanceType: instance struct name * @ClassType: class struct name - * @module_obj_name: the object name in lowercase with underscore separators * @MODULE_OBJ_NAME: the object name in uppercase with underscore separators * * This macro is typically used in a header file, and will: @@ -625,7 +624,7 @@ struct Object * * The object struct and class struct need to be declared manually. */ -#define OBJECT_DECLARE_TYPE(InstanceType, ClassType, module_obj_name, MODULE_OBJ_NAME) \ +#define OBJECT_DECLARE_TYPE(InstanceType, ClassType, MODULE_OBJ_NAME) \ typedef struct InstanceType InstanceType; \ typedef struct ClassType ClassType; \ \ @@ -637,21 +636,20 @@ struct Object /** * OBJECT_DECLARE_SIMPLE_TYPE: * @InstanceType: instance struct name - * @module_obj_name: the object name in lowercase with underscore separators * @MODULE_OBJ_NAME: the object name in uppercase with underscore separators - * @ParentClassType: class struct name of parent type * - * This does the same as OBJECT_DECLARE_TYPE(), but also declares - * the class struct, thus only the object struct needs to be declare - * manually. + * This does the same as OBJECT_DECLARE_TYPE(), but with no class struct + * declared. * * This macro should be used unless the class struct needs to have * virtual methods declared. */ -#define OBJECT_DECLARE_SIMPLE_TYPE(InstanceType, module_obj_name, \ - MODULE_OBJ_NAME, ParentClassType) \ - OBJECT_DECLARE_TYPE(InstanceType, InstanceType##Class, module_obj_name, MODULE_OBJ_NAME) \ - struct InstanceType##Class { ParentClassType parent_class; }; +#define OBJECT_DECLARE_SIMPLE_TYPE(InstanceType, MODULE_OBJ_NAME) \ + typedef struct InstanceType InstanceType; \ + \ + G_DEFINE_AUTOPTR_CLEANUP_FUNC(InstanceType, object_unref) \ + \ + DECLARE_INSTANCE_CHECKER(InstanceType, MODULE_OBJ_NAME, TYPE_##MODULE_OBJ_NAME) /** @@ -691,6 +689,7 @@ struct Object .parent = TYPE_##PARENT_MODULE_OBJ_NAME, \ .name = TYPE_##MODULE_OBJ_NAME, \ .instance_size = sizeof(ModuleObjName), \ + .instance_align = __alignof__(ModuleObjName), \ .instance_init = module_obj_name##_init, \ .instance_finalize = module_obj_name##_finalize, \ .class_size = sizeof(ModuleObjName##Class), \ @@ -770,6 +769,9 @@ struct Object * @instance_size: The size of the object (derivative of #Object). If * @instance_size is 0, then the size of the object will be the size of the * parent object. + * @instance_align: The required alignment of the object. If @instance_align + * is 0, then normal malloc alignment is sufficient; if non-zero, then we + * must use qemu_memalign for allocation. * @instance_init: This function is called to initialize an object. The parent * class will have already been initialized so the type is only responsible * for initializing its own members. @@ -807,6 +809,7 @@ struct TypeInfo const char *parent; size_t instance_size; + size_t instance_align; void (*instance_init)(Object *obj); void (*instance_post_init)(Object *obj); void (*instance_finalize)(Object *obj); @@ -1257,7 +1260,7 @@ type_init(do_qemu_init_ ## type_array) * of this function. The only difference in behavior is that this function * asserts instead of returning #NULL on failure if QOM cast debugging is * enabled. This function is not meant to be called directly, but only through - * the wrapper macros OBJECT_CLASS_CHECK and INTERFACE_CHECK. + * the wrapper macro OBJECT_CLASS_CHECK. */ ObjectClass *object_class_dynamic_cast_assert(ObjectClass *klass, const char *typename, @@ -1624,7 +1627,7 @@ bool object_property_set_bool(Object *obj, const char *name, * @name: the name of the property * @errp: returns an error if this function fails * - * Returns: the value of the property, converted to a boolean, or NULL if + * Returns: the value of the property, converted to a boolean, or false if * an error occurs (including when the property value is not a bool). */ bool object_property_get_bool(Object *obj, const char *name, @@ -1649,7 +1652,7 @@ bool object_property_set_int(Object *obj, const char *name, * @name: the name of the property * @errp: returns an error if this function fails * - * Returns: the value of the property, converted to an integer, or negative if + * Returns: the value of the property, converted to an integer, or -1 if * an error occurs (including when the property value is not an integer). */ int64_t object_property_get_int(Object *obj, const char *name, @@ -1687,9 +1690,9 @@ uint64_t object_property_get_uint(Object *obj, const char *name, * @typename: the name of the enum data type * @errp: returns an error if this function fails * - * Returns: the value of the property, converted to an integer, or - * undefined if an error occurs (including when the property value is not - * an enum). + * Returns: the value of the property, converted to an integer (which + * can't be negative), or -1 on error (including when the property + * value is not an enum). */ int object_property_get_enum(Object *obj, const char *name, const char *typename, Error **errp); |