Skip to contentSkip to conversation

[5956] linux-user: Introduce h2g_valid

Qemu-devel Aurelien Jarno 1 participant 1 message Dec 8, 2008

lore
Share & tools
lore
#0 lore raw

Revision: 5956

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5956
Author:   aurel32
Date:     2008-12-08 18:12:18 +0000 (Mon, 08 Dec 2008)

Log Message:
-----------
linux-user: Introduce h2g_valid

Introduce h2g_valid to check if a given host address can be converted into a valid guest address.

Based on a patch from Jan Kiszka <[email protected]>

Modified Paths:
--------------
trunk/cpu-all.h

Modified: trunk/cpu-all.h
===================================================================

cpu-all.h +4 -0
@@ -638,6 +638,10 @@
     assert(__ret == (abi_ulong)__ret); \
     (abi_ulong)__ret; \
 })
+#define h2g_valid(x) ({ \
+    unsigned long __guest = (unsigned long)(x) - GUEST_BASE; \
+    (__guest == (abi_ulong)__guest); \
+})
 
 #define saddr(x) g2h(x)
 #define laddr(x) g2h(x)