evg-zhabotinsky / yieldhook

A slight modification of Lua's debug.sethook() to set yielding hooks from Lua code. Packaged as a library.
7 stars 0 forks source link

[FEATURE] Add support for compiling for LuaJIT #1

Open FoxieFlakey opened 3 years ago

FoxieFlakey commented 3 years ago

please add support for compiling for LuaJIT not only for Lua5.3

FoxieFlakey commented 3 years ago

because it wont compile for LuaJIT

FoxieFlakey commented 3 years ago

Compilation fail with

cc -O3 -I/usr/include/luajit-2.1 -fPIC -shared -o yieldhook.so yieldhook.c -s
yieldhook.c: In function ‘hookf’:
yieldhook.c:67:3: warning: implicit declaration of function ‘lua_rawgetp’; did you mean ‘lua_rawgeti’? [-Wimplicit-function-declaration]
   67 |   lua_rawgetp(L, LUA_REGISTRYINDEX, &HOOKKEY);
      |   ^~~~~~~~~~~
      |   lua_rawgeti
yieldhook.c:69:7: error: void value not ignored as it ought to be
   69 |   if (lua_rawget(L, -2) == LUA_TFUNCTION) {  /* is there a hook function? */
      |       ^~~~~~~~~~~~~~~~~
yieldhook.c:21:29: error: ‘LUA_HOOKTAILCALL’ undeclared (first use in this function); did you mean ‘LUA_HOOKTAILRET’?
   21 | #define LUA_MASKYIELD (1 << LUA_HOOKTAILCALL)
      |                             ^~~~~~~~~~~~~~~~
yieldhook.c:77:32: note: in expansion of macro ‘LUA_MASKYIELD’
   77 |       && (lua_get