XObject::StashNative
This commit is contained in:
parent
7595df4876
commit
e54477d0e4
|
@ -273,10 +273,7 @@ void XObject::SetNativePointer(uint32_t native_ptr, bool uninitialized) {
|
|||
|
||||
// Stash pointer in struct.
|
||||
// FIXME: This assumes the object has a dispatch header (some don't!)
|
||||
uint64_t object_ptr = reinterpret_cast<uint64_t>(this);
|
||||
object_ptr |= 0x1;
|
||||
header->wait_list_flink = (uint32_t)(object_ptr >> 32);
|
||||
header->wait_list_blink = (uint32_t)(object_ptr & 0xFFFFFFFF);
|
||||
StashNative(header, this);
|
||||
|
||||
guest_object_ptr_ = native_ptr;
|
||||
}
|
||||
|
@ -354,10 +351,7 @@ object_ref<XObject> XObject::GetNativeObject(KernelState* kernel_state,
|
|||
|
||||
// Stash pointer in struct.
|
||||
// FIXME: This assumes the object contains a dispatch header (some don't!)
|
||||
uint64_t object_ptr = reinterpret_cast<uint64_t>(object);
|
||||
object_ptr |= 0x1;
|
||||
header->wait_list_flink = (uint32_t)(object_ptr >> 32);
|
||||
header->wait_list_blink = (uint32_t)(object_ptr & 0xFFFFFFFF);
|
||||
StashNative(header, object);
|
||||
|
||||
// NOTE: we are double-retaining, as the object is implicitly created and
|
||||
// can never be released.
|
||||
|
|
|
@ -156,6 +156,19 @@ class XObject {
|
|||
uint8_t* CreateNative(uint32_t size);
|
||||
void SetNativePointer(uint32_t native_ptr, bool uninitialized = false);
|
||||
|
||||
template <typename T>
|
||||
T* CreateNative(uint32_t size) {
|
||||
return reinterpret_cast<T*>(CreateNative(size));
|
||||
}
|
||||
|
||||
// Stash native pointer into X_DISPATCH_HEADER
|
||||
static void StashNative(X_DISPATCH_HEADER* header, void* native_ptr) {
|
||||
uint64_t object_ptr = reinterpret_cast<uint64_t>(native_ptr);
|
||||
object_ptr |= 0x1;
|
||||
header->wait_list_flink = (uint32_t)(object_ptr >> 32);
|
||||
header->wait_list_blink = (uint32_t)(object_ptr & 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
static uint32_t TimeoutTicksToMs(int64_t timeout_ticks);
|
||||
|
||||
KernelState* kernel_state_;
|
||||
|
|
Loading…
Reference in New Issue