Commit 70499c989f434cba8bc2104da9f6ca162c4a937b

Authored by bellard
1 parent 6a3b9cc9

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
Showing 1 changed file with 27 additions and 1 deletions
... ... @@ -147,11 +147,37 @@ const argtype *thunk_convert(void *dst, const void *src,
147 147 case TYPE_ULONG:
148 148 case TYPE_PTRVOID:
149 149 if (to_host) {
150   - *(uint64_t *)dst = tswap32(*(uint32_t *)src);
  150 + if (type == TYPE_LONG) {
  151 + /* sign extension */
  152 + *(uint64_t *)dst = (int32_t)tswap32(*(uint32_t *)src);
  153 + } else {
  154 + *(uint64_t *)dst = tswap32(*(uint32_t *)src);
  155 + }
151 156 } else {
152 157 *(uint32_t *)dst = tswap32(*(uint64_t *)src & 0xffffffff);
153 158 }
154 159 break;
  160 +#elif HOST_LONG_BITS == 64 && TARGET_ABI_BITS == 64
  161 + case TYPE_LONG:
  162 + case TYPE_ULONG:
  163 + case TYPE_PTRVOID:
  164 + *(uint64_t *)dst = tswap64(*(uint64_t *)src);
  165 + break;
  166 +#elif HOST_LONG_BITS == 32 && TARGET_ABI_BITS == 64
  167 + case TYPE_LONG:
  168 + case TYPE_ULONG:
  169 + case TYPE_PTRVOID:
  170 + if (to_host) {
  171 + *(uint32_t *)dst = tswap64(*(uint64_t *)src);
  172 + } else {
  173 + if (type == TYPE_LONG) {
  174 + /* sign extension */
  175 + *(uint64_t *)dst = tswap64(*(int32_t *)src);
  176 + } else {
  177 + *(uint64_t *)dst = tswap64(*(uint32_t *)src);
  178 + }
  179 + }
  180 + break;
155 181 #else
156 182 #warning unsupported conversion
157 183 #endif
... ...