[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 14/26] rust: qom: move bridge for TypeInfo functions out of p
From: |
Zhao Liu |
Subject: |
Re: [PATCH 14/26] rust: qom: move bridge for TypeInfo functions out of pl011 |
Date: |
Wed, 11 Dec 2024 00:02:15 +0800 |
> +unsafe extern "C" fn rust_instance_init<T: ObjectImpl>(obj: *mut Object) {
> + // SAFETY: obj is an instance of T, since rust_instance_init<T>
> + // is called from QOM core as the instance_init function
> + // for class T
> + unsafe { T::INSTANCE_INIT.unwrap()(&mut *obj.cast::<T>()) }
> +}
Here's the difference, why doesn't init() narrow the unsafe scope like
post_init() does?
> +unsafe extern "C" fn rust_instance_post_init<T: ObjectImpl>(obj: *mut
> Object) {
> + // SAFETY: obj is an instance of T, since rust_instance_post_init<T>
> + // is called from QOM core as the instance_post_init function
> + // for class T
> + //
> + // FIXME: it's not really guaranteed that there are no backpointers to
> + // obj; it's quite possible that they have been created by
> instance_init().
> + // The receiver should be &self, not &mut self.
> + T::INSTANCE_POST_INIT.unwrap()(unsafe { &mut *obj.cast::<T>() })
> +}
> +
- Re: [PATCH 13/26] rust: qom: automatically use Drop trait to implement instance_finalize, (continued)
[PATCH 14/26] rust: qom: move bridge for TypeInfo functions out of pl011, Paolo Bonzini, 2024/12/09
- Re: [PATCH 14/26] rust: qom: move bridge for TypeInfo functions out of pl011, Zhao Liu, 2024/12/10
- Re: [PATCH 14/26] rust: qom: move bridge for TypeInfo functions out of pl011, Paolo Bonzini, 2024/12/10
- Re: [PATCH 14/26] rust: qom: move bridge for TypeInfo functions out of pl011, Zhao Liu, 2024/12/11
- Re: [PATCH 14/26] rust: qom: move bridge for TypeInfo functions out of pl011, Paolo Bonzini, 2024/12/11
- Re: [PATCH 14/26] rust: qom: move bridge for TypeInfo functions out of pl011, Zhao Liu, 2024/12/11
- Re: [PATCH 14/26] rust: qom: move bridge for TypeInfo functions out of pl011, Paolo Bonzini, 2024/12/12
- Re: [PATCH 14/26] rust: qom: move bridge for TypeInfo functions out of pl011, Zhao Liu, 2024/12/13
Re: [PATCH 14/26] rust: qom: move bridge for TypeInfo functions out of pl011,
Zhao Liu <=
[PATCH 15/26] rust: qom: split ObjectType from ObjectImpl trait, Paolo Bonzini, 2024/12/09
[PATCH 11/26] rust: qdev: move device_class_init! body to generic function, ClassInitImpl implementation to macro, Paolo Bonzini, 2024/12/09
[PATCH 16/26] rust: qom: change the parent type to an associated type, Paolo Bonzini, 2024/12/09
[PATCH 19/26] rust: rename qemu-api modules to follow C code a bit more, Paolo Bonzini, 2024/12/09