diff options
author | Mike Pall <mike> | 2011-11-14 14:15:57 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2011-11-14 14:18:25 +0100 |
commit | 71d00a56dbab6c29c0346093dbe530d7b7608be4 (patch) | |
tree | 5e28e19b4d2f20168d5ee0e4fe500b1e2b233c1c /src/lj_ccall.c | |
parent | e9eb4fdb4a08baaa2d9190187a6c38d5b3f8b091 (diff) | |
download | luajit-71d00a56dbab6c29c0346093dbe530d7b7608be4.tar.gz luajit-71d00a56dbab6c29c0346093dbe530d7b7608be4.tar.bz2 luajit-71d00a56dbab6c29c0346093dbe530d7b7608be4.zip |
FFI: Add callback support (for x86/x64).
Diffstat (limited to 'src/lj_ccall.c')
-rw-r--r-- | src/lj_ccall.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/lj_ccall.c b/src/lj_ccall.c index c1c04b6f..5ed1bf5b 100644 --- a/src/lj_ccall.c +++ b/src/lj_ccall.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include "lj_gc.h" | 10 | #include "lj_gc.h" |
11 | #include "lj_err.h" | 11 | #include "lj_err.h" |
12 | #include "lj_str.h" | 12 | #include "lj_str.h" |
13 | #include "lj_tab.h" | ||
13 | #include "lj_ctype.h" | 14 | #include "lj_ctype.h" |
14 | #include "lj_cconv.h" | 15 | #include "lj_cconv.h" |
15 | #include "lj_cdata.h" | 16 | #include "lj_cdata.h" |
@@ -290,7 +291,7 @@ | |||
290 | } | 291 | } |
291 | 292 | ||
292 | #else | 293 | #else |
293 | #error "missing calling convention definitions for this architecture" | 294 | #error "Missing calling convention definitions for this architecture" |
294 | #endif | 295 | #endif |
295 | 296 | ||
296 | #ifndef CCALL_HANDLE_STRUCTRET2 | 297 | #ifndef CCALL_HANDLE_STRUCTRET2 |
@@ -649,7 +650,13 @@ int lj_ccall_func(lua_State *L, GCcdata *cd) | |||
649 | int gcsteps, ret; | 650 | int gcsteps, ret; |
650 | cc.func = (void (*)(void))cdata_getptr(cdataptr(cd), sz); | 651 | cc.func = (void (*)(void))cdata_getptr(cdataptr(cd), sz); |
651 | gcsteps = ccall_set_args(L, cts, ct, &cc); | 652 | gcsteps = ccall_set_args(L, cts, ct, &cc); |
653 | cts->cb.slot = ~0u; | ||
652 | lj_vm_ffi_call(&cc); | 654 | lj_vm_ffi_call(&cc); |
655 | if (cts->cb.slot != ~0u) { /* Blacklist function that called a callback. */ | ||
656 | TValue tv; | ||
657 | setlightudV(&tv, (void *)cc.func); | ||
658 | setboolV(lj_tab_set(L, cts->miscmap, &tv), 1); | ||
659 | } | ||
653 | gcsteps += ccall_get_results(L, cts, ct, &cc, &ret); | 660 | gcsteps += ccall_get_results(L, cts, ct, &cc, &ret); |
654 | #if LJ_TARGET_X86 && LJ_ABI_WIN | 661 | #if LJ_TARGET_X86 && LJ_ABI_WIN |
655 | /* Automatically detect __stdcall and fix up C function declaration. */ | 662 | /* Automatically detect __stdcall and fix up C function declaration. */ |