1use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7use kalloc::AllocError;
8
9#[repr(C)]
10pub struct VmObject {
15 _data: [u8; 0],
16 _marker: PhantomData<PhantomPinned>,
17}
18
19unsafe extern "C" {
20 fn cpp_vm_object_get_ref_counted(vmo: *const VmObject) -> *mut fbl::RefCounted;
21 fn cpp_vm_object_free(vmo: *mut VmObject);
22}
23
24impl fbl::HasRefCount for VmObject {
25 fn ref_count(&self) -> &fbl::RefCounted {
26 unsafe { &*cpp_vm_object_get_ref_counted(self as *const _) }
27 }
28}
29
30unsafe impl fbl::Recyclable for VmObject {
31 unsafe fn recycle(ptr: NonNull<Self>) {
32 unsafe {
33 cpp_vm_object_free(ptr.as_ptr());
34 }
35 }
36
37 fn allocate(_value: Self) -> Result<NonNull<Self>, AllocError> {
38 Err(AllocError)
39 }
40}