aboutsummaryrefslogtreecommitdiff
path: root/src/lj_ccall.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lj_ccall.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/lj_ccall.c b/src/lj_ccall.c
index 2b7ca364..5c252e5b 100644
--- a/src/lj_ccall.c
+++ b/src/lj_ccall.c
@@ -301,7 +301,7 @@
301 unsigned int cl = ccall_classify_struct(cts, ctr); \ 301 unsigned int cl = ccall_classify_struct(cts, ctr); \
302 if ((cl & 4)) { /* Combine float HFA from separate registers. */ \ 302 if ((cl & 4)) { /* Combine float HFA from separate registers. */ \
303 CTSize i = (cl >> 8) - 1; \ 303 CTSize i = (cl >> 8) - 1; \
304 do { ((uint32_t *)dp)[i] = cc->fpr[i].u32; } while (i--); \ 304 do { ((uint32_t *)dp)[i] = cc->fpr[i].lo; } while (i--); \
305 } else { \ 305 } else { \
306 if (cl > 1) sp = (uint8_t *)&cc->fpr[0]; \ 306 if (cl > 1) sp = (uint8_t *)&cc->fpr[0]; \
307 memcpy(dp, sp, ctr->size); \ 307 memcpy(dp, sp, ctr->size); \
@@ -359,6 +359,13 @@
359 } \ 359 } \
360 } 360 }
361 361
362#if LJ_BE
363#define CCALL_HANDLE_RET \
364 if (ctype_isfp(ctr->info) && ctr->size == sizeof(float)) \
365 sp = (uint8_t *)&cc->fpr[0].f;
366#endif
367
368
362#elif LJ_TARGET_PPC 369#elif LJ_TARGET_PPC
363/* -- PPC calling conventions --------------------------------------------- */ 370/* -- PPC calling conventions --------------------------------------------- */
364 371
@@ -1033,9 +1040,16 @@ static int ccall_set_args(lua_State *L, CTState *cts, CType *ct,
1033 *(int32_t *)dp = d->size == 1 ? (int32_t)*(int8_t *)dp : 1040 *(int32_t *)dp = d->size == 1 ? (int32_t)*(int8_t *)dp :
1034 (int32_t)*(int16_t *)dp; 1041 (int32_t)*(int16_t *)dp;
1035 } 1042 }
1043#if LJ_TARGET_ARM64 && LJ_BE
1044 if (isfp && d->size == sizeof(float))
1045 ((float *)dp)[1] = ((float *)dp)[0]; /* Floats occupy high slot. */
1046#endif
1047#if LJ_TARGET_MIPS64 || (LJ_TARGET_ARM64 && LJ_BE)
1048 if ((ctype_isinteger_or_bool(d->info) || ctype_isenum(d->info)
1036#if LJ_TARGET_MIPS64 1049#if LJ_TARGET_MIPS64
1037 if ((ctype_isinteger_or_bool(d->info) || ctype_isenum(d->info) || 1050 || (isfp && nsp == 0)
1038 (isfp && nsp == 0)) && d->size <= 4) { 1051#endif
1052 ) && d->size <= 4) {
1039 *(int64_t *)dp = (int64_t)*(int32_t *)dp; /* Sign-extend to 64 bit. */ 1053 *(int64_t *)dp = (int64_t)*(int32_t *)dp; /* Sign-extend to 64 bit. */
1040 } 1054 }
1041#endif 1055#endif