better than nothing 64 bit support - added sign extension for TYPE_LONG
authorbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>
Sun, 11 Nov 2007 19:31:34 +0000 (19:31 +0000)
committerbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>
Sun, 11 Nov 2007 19:31:34 +0000 (19:31 +0000)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3605 c046a42c-6fe2-441c-8c8c-71466251a162

thunk.c

diff --git a/thunk.c b/thunk.c
index 0347d6d049d47c0a5f2152d4cec318729556b54d..dc9e315d7d3dd12befe9b651ffa50be12d01c887 100644 (file)
--- a/thunk.c
+++ b/thunk.c
@@ -147,11 +147,37 @@ const argtype *thunk_convert(void *dst, const void *src,
     case TYPE_ULONG:
     case TYPE_PTRVOID:
         if (to_host) {
-            *(uint64_t *)dst = tswap32(*(uint32_t *)src);
+            if (type == TYPE_LONG) {
+                /* sign extension */
+                *(uint64_t *)dst = (int32_t)tswap32(*(uint32_t *)src);
+            } else {
+                *(uint64_t *)dst = tswap32(*(uint32_t *)src);
+            }
         } else {
             *(uint32_t *)dst = tswap32(*(uint64_t *)src & 0xffffffff);
         }
         break;
+#elif HOST_LONG_BITS == 64 && TARGET_ABI_BITS == 64
+    case TYPE_LONG:
+    case TYPE_ULONG:
+    case TYPE_PTRVOID:
+        *(uint64_t *)dst = tswap64(*(uint64_t *)src);
+        break;
+#elif HOST_LONG_BITS == 32 && TARGET_ABI_BITS == 64
+    case TYPE_LONG:
+    case TYPE_ULONG:
+    case TYPE_PTRVOID:
+        if (to_host) {
+            *(uint32_t *)dst = tswap64(*(uint64_t *)src);
+        } else {
+            if (type == TYPE_LONG) {
+                /* sign extension */
+                *(uint64_t *)dst = tswap64(*(int32_t *)src);
+            } else {
+                *(uint64_t *)dst = tswap64(*(uint32_t *)src);
+            }
+        }
+        break;
 #else
 #warning unsupported conversion
 #endif