aboutsummaryrefslogtreecommitdiff
path: root/thunk.c
diff options
context:
space:
mode:
authorbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2007-11-11 19:31:34 +0000
committerbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2007-11-11 19:31:34 +0000
commit70499c989f434cba8bc2104da9f6ca162c4a937b (patch)
tree44b2fb2202f1f241c78590fb7576834121b5c8b5 /thunk.c
parent6a3b9cc9c5c52808435402a0b422e67f2ea9875c (diff)
better than nothing 64 bit support - added sign extension for TYPE_LONG
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3605 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'thunk.c')
-rw-r--r--thunk.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/thunk.c b/thunk.c
index 0347d6d049..dc9e315d7d 100644
--- 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