diff options
Diffstat (limited to '')
-rw-r--r-- | src/lj_ccall.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/lj_ccall.c b/src/lj_ccall.c index 9001cb5a..00e753b9 100644 --- a/src/lj_ccall.c +++ b/src/lj_ccall.c | |||
@@ -348,7 +348,6 @@ | |||
348 | goto done; \ | 348 | goto done; \ |
349 | } else { \ | 349 | } else { \ |
350 | nfpr = CCALL_NARG_FPR; /* Prevent reordering. */ \ | 350 | nfpr = CCALL_NARG_FPR; /* Prevent reordering. */ \ |
351 | if (LJ_TARGET_OSX && d->size < 8) goto err_nyi; \ | ||
352 | } \ | 351 | } \ |
353 | } else { /* Try to pass argument in GPRs. */ \ | 352 | } else { /* Try to pass argument in GPRs. */ \ |
354 | if (!LJ_TARGET_OSX && (d->info & CTF_ALIGN) > CTALIGN_PTR) \ | 353 | if (!LJ_TARGET_OSX && (d->info & CTF_ALIGN) > CTALIGN_PTR) \ |
@@ -359,7 +358,6 @@ | |||
359 | goto done; \ | 358 | goto done; \ |
360 | } else { \ | 359 | } else { \ |
361 | ngpr = maxgpr; /* Prevent reordering. */ \ | 360 | ngpr = maxgpr; /* Prevent reordering. */ \ |
362 | if (LJ_TARGET_OSX && d->size < 8) goto err_nyi; \ | ||
363 | } \ | 361 | } \ |
364 | } | 362 | } |
365 | 363 | ||
@@ -1023,7 +1021,7 @@ static int ccall_set_args(lua_State *L, CTState *cts, CType *ct, | |||
1023 | CCALL_HANDLE_STRUCTARG | 1021 | CCALL_HANDLE_STRUCTARG |
1024 | } else if (ctype_iscomplex(d->info)) { | 1022 | } else if (ctype_iscomplex(d->info)) { |
1025 | CCALL_HANDLE_COMPLEXARG | 1023 | CCALL_HANDLE_COMPLEXARG |
1026 | } else { | 1024 | } else if (!(CCALL_PACK_STACKARG && ctype_isenum(d->info))) { |
1027 | sz = CTSIZE_PTR; | 1025 | sz = CTSIZE_PTR; |
1028 | } | 1026 | } |
1029 | n = (sz + CTSIZE_PTR-1) / CTSIZE_PTR; /* Number of GPRs or stack slots needed. */ | 1027 | n = (sz + CTSIZE_PTR-1) / CTSIZE_PTR; /* Number of GPRs or stack slots needed. */ |
@@ -1033,12 +1031,12 @@ static int ccall_set_args(lua_State *L, CTState *cts, CType *ct, | |||
1033 | /* Otherwise pass argument on stack. */ | 1031 | /* Otherwise pass argument on stack. */ |
1034 | if (CCALL_ALIGN_STACKARG) { /* Align argument on stack. */ | 1032 | if (CCALL_ALIGN_STACKARG) { /* Align argument on stack. */ |
1035 | MSize align = (1u << ctype_align(d->info)) - 1; | 1033 | MSize align = (1u << ctype_align(d->info)) - 1; |
1036 | if (rp) | 1034 | if (rp || (CCALL_PACK_STACKARG && isva && align < CTSIZE_PTR-1)) |
1037 | align = CTSIZE_PTR-1; | 1035 | align = CTSIZE_PTR-1; |
1038 | nsp = (nsp + align) & ~align; | 1036 | nsp = (nsp + align) & ~align; |
1039 | } | 1037 | } |
1040 | dp = ((uint8_t *)cc->stack) + nsp; | 1038 | dp = ((uint8_t *)cc->stack) + nsp; |
1041 | nsp += n * CTSIZE_PTR; | 1039 | nsp += CCALL_PACK_STACKARG ? sz : n * CTSIZE_PTR; |
1042 | if (nsp > CCALL_SIZE_STACK) { /* Too many arguments. */ | 1040 | if (nsp > CCALL_SIZE_STACK) { /* Too many arguments. */ |
1043 | err_nyi: | 1041 | err_nyi: |
1044 | lj_err_caller(L, LJ_ERR_FFI_NYICALL); | 1042 | lj_err_caller(L, LJ_ERR_FFI_NYICALL); |
@@ -1053,7 +1051,8 @@ static int ccall_set_args(lua_State *L, CTState *cts, CType *ct, | |||
1053 | } | 1051 | } |
1054 | lj_cconv_ct_tv(cts, d, (uint8_t *)dp, o, CCF_ARG(narg)); | 1052 | lj_cconv_ct_tv(cts, d, (uint8_t *)dp, o, CCF_ARG(narg)); |
1055 | /* Extend passed integers to 32 bits at least. */ | 1053 | /* Extend passed integers to 32 bits at least. */ |
1056 | if (ctype_isinteger_or_bool(d->info) && d->size < 4) { | 1054 | if (ctype_isinteger_or_bool(d->info) && d->size < 4 && |
1055 | (!CCALL_PACK_STACKARG || !((uintptr_t)dp & 3))) { /* Assumes LJ_LE. */ | ||
1057 | if (d->info & CTF_UNSIGNED) | 1056 | if (d->info & CTF_UNSIGNED) |
1058 | *(uint32_t *)dp = d->size == 1 ? (uint32_t)*(uint8_t *)dp : | 1057 | *(uint32_t *)dp = d->size == 1 ? (uint32_t)*(uint8_t *)dp : |
1059 | (uint32_t)*(uint16_t *)dp; | 1058 | (uint32_t)*(uint16_t *)dp; |