+/* Like lock_user but for null terminated strings. */
+static inline void *lock_user_string(target_ulong guest_addr)
+{
+ long len;
+ len = target_strlen(guest_addr) + 1;
+ return lock_user(guest_addr, len, 1);
+}
+
+/* Helper macros for locking/ulocking a target struct. */
+#define lock_user_struct(host_ptr, guest_addr, copy) \
+ host_ptr = lock_user(guest_addr, sizeof(*host_ptr), copy)
+#define unlock_user_struct(host_ptr, guest_addr, copy) \
+ unlock_user(host_ptr, guest_addr, (copy) ? sizeof(*host_ptr) : 0)
+
+#define tget8(addr) ldub(addr)
+#define tput8(addr, val) stb(addr, val)
+#define tget16(addr) lduw(addr)
+#define tput16(addr, val) stw(addr, val)
+#define tget32(addr) ldl(addr)
+#define tput32(addr, val) stl(addr, val)
+#define tget64(addr) ldq(addr)
+#define tput64(addr, val) stq(addr, val)
+#if TARGET_LONG_BITS == 64
+#define tgetl(addr) ldq(addr)
+#define tputl(addr, val) stq(addr, val)
+#else
+#define tgetl(addr) ldl(addr)
+#define tputl(addr, val) stl(addr, val)
+#endif
+