** This function can be called asynchronously (e.g. during a signal), ** under "reasonable" assumptions. ** Fields 'oldpc', 'basehookcount', and 'hookcount' (set by ** 'resethookcount') are for debug only, and it is no problem if they ** get arbitrary values (causes at most one wrong hook call). 'hookmask' ** is an atomic value. We assume that pointers are atomic too (e.g., gcc ** ensures that for
| 133 | ** always checked before being called (see 'luaD_hook'). |
| 134 | */ |
| 135 | LUA_API void lua_sethook (lua_State *L, lua_Hook func, int mask, int count) { |
| 136 | if (func == NULL || mask == 0) { /* turn off hooks? */ |
| 137 | mask = 0; |
| 138 | func = NULL; |
| 139 | } |
| 140 | if (isLua(L->ci)) |
| 141 | L->oldpc = L->ci->u.l.savedpc; |
| 142 | L->hook = func; |
| 143 | L->basehookcount = count; |
| 144 | resethookcount(L); |
| 145 | L->hookmask = cast_byte(mask); |
| 146 | if (mask) |
| 147 | settraps(L->ci); /* to trace inside 'luaV_execute' */ |
| 148 | } |
| 149 | |
| 150 | |
| 151 | LUA_API lua_Hook lua_gethook (lua_State *L) { |
no test coverage detected