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