** precall for C functions */
| 521 | ** precall for C functions |
| 522 | */ |
| 523 | l_sinline int precallC (lua_State *L, StkId func, int nresults, |
| 524 | lua_CFunction f) { |
| 525 | int n; /* number of returns */ |
| 526 | CallInfo *ci; |
| 527 | checkstackGCp(L, LUA_MINSTACK, func); /* ensure minimum stack size */ |
| 528 | L->ci = ci = prepCallInfo(L, func, nresults, CIST_C, |
| 529 | L->top.p + LUA_MINSTACK); |
| 530 | lua_assert(ci->top.p <= L->stack_last.p); |
| 531 | if (l_unlikely(L->hookmask & LUA_MASKCALL)) { |
| 532 | int narg = cast_int(L->top.p - func) - 1; |
| 533 | luaD_hook(L, LUA_HOOKCALL, -1, 1, narg); |
| 534 | } |
| 535 | lua_unlock(L); |
| 536 | n = (*f)(L); /* do the actual call */ |
| 537 | lua_lock(L); |
| 538 | api_checknelems(L, n); |
| 539 | luaD_poscall(L, ci, n); |
| 540 | return n; |
| 541 | } |
| 542 | |
| 543 | |
| 544 | /* |
no test coverage detected