From c056c5a71b2d4b03677d16846f1403b6957b9620 Mon Sep 17 00:00:00 2001
From: Petr Rockai <me@mornfall.net>
Date: Tue, 14 Jan 2020 16:01:03 +0000
Subject: [PATCH] rst: Update {peek,poke}_object to use the new
 __vm_{peek,poke} API.

---
 dios/include/rst/common.hpp | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/dios/include/rst/common.hpp b/dios/include/rst/common.hpp
index 44b0eb55d..20ff5a460 100644
--- a/dios/include/rst/common.hpp
+++ b/dios/include/rst/common.hpp
@@ -195,22 +195,19 @@ namespace __dios::rst::abstract {
     }
 
     template< typename T >
-    _LART_INLINE T * peek_object( void * addr ) noexcept
+    _LART_INLINE T * peek_object( void * addr_ ) noexcept
     {
-        struct { uint32_t off = 0, obj; } ptr;
-        ptr.obj = __vm_peek( addr, _VM_ML_User );
-
-        T * obj;
-        memcpy( &obj, &ptr, sizeof( T * ) );
-        return obj;
+        __vm_pointer_t addr = __vm_pointer_split( addr_ );
+        auto m = __vm_peek( _VM_ML_User, addr.obj, addr.off, 1 );
+        return static_cast< T * >( __vm_pointer_make( m.value, 0 ) );
     }
 
     template< typename T >
-    _LART_INLINE void poke_object( T obj, void * addr ) noexcept
+    _LART_INLINE void poke_object( T obj, void * addr_ ) noexcept
     {
-        struct { uint32_t off, obj; } ptr;
-        memcpy( &ptr, &obj, sizeof( T * ) );
-        __vm_poke( addr, _VM_ML_User, ptr.obj );
+        __vm_pointer_t addr = __vm_pointer_split( addr_ ),
+                       ptr  = __vm_pointer_split( static_cast< void * >( obj ) );
+        __vm_poke( _VM_ML_User, addr.obj, addr.off, 1, ptr.obj );
     }
 
     struct object_t
-- 
GitLab