summaryrefslogtreecommitdiff
path: root/src/lj_ccall.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lj_ccall.c')
-rw-r--r--src/lj_ccall.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/lj_ccall.c b/src/lj_ccall.c
index 03f0ec06..6d5156fb 100644
--- a/src/lj_ccall.c
+++ b/src/lj_ccall.c
@@ -14,6 +14,7 @@
14#include "lj_cconv.h" 14#include "lj_cconv.h"
15#include "lj_cdata.h" 15#include "lj_cdata.h"
16#include "lj_ccall.h" 16#include "lj_ccall.h"
17#include "lj_trace.h"
17 18
18/* Target-specific handling of register arguments. */ 19/* Target-specific handling of register arguments. */
19#if LJ_TARGET_X86 20#if LJ_TARGET_X86
@@ -127,7 +128,7 @@ static int ccall_set_args(lua_State *L, CTState *cts, CType *ct,
127#if LJ_TARGET_X86 128#if LJ_TARGET_X86
128 /* x86 has several different calling conventions. */ 129 /* x86 has several different calling conventions. */
129 cc->resx87 = 0; 130 cc->resx87 = 0;
130 switch ((ct->info >> CTSHIFT_CCONV) & CTMASK_CCONV) { 131 switch (ctype_cconv(ct->info)) {
131 case CTCC_FASTCALL: maxgpr = 2; break; 132 case CTCC_FASTCALL: maxgpr = 2; break;
132 case CTCC_THISCALL: maxgpr = 1; break; 133 case CTCC_THISCALL: maxgpr = 1; break;
133 default: maxgpr = 0; break; 134 default: maxgpr = 0; break;
@@ -352,6 +353,13 @@ int lj_ccall_func(lua_State *L, GCcdata *cd)
352 gcsteps = ccall_set_args(L, cts, ct, &cc); 353 gcsteps = ccall_set_args(L, cts, ct, &cc);
353 lj_vm_ffi_call(&cc); 354 lj_vm_ffi_call(&cc);
354 gcsteps += ccall_get_results(L, cts, ct, &cc, &ret); 355 gcsteps += ccall_get_results(L, cts, ct, &cc, &ret);
356#if LJ_TARGET_X86 && LJ_ABI_WIN
357 /* Automatically detect __stdcall and fix up C function declaration. */
358 if (cc.spadj && ctype_cconv(ct->info) == CTCC_CDECL) {
359 CTF_INSERT(ct->info, CCONV, CTCC_STDCALL);
360 lj_trace_abort(G(L));
361 }
362#endif
355 while (gcsteps-- > 0) 363 while (gcsteps-- > 0)
356 lj_gc_check(L); 364 lj_gc_check(L);
357 return ret; 365 return ret;