lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Thu, Jul 9, 2020 at 5:48 PM Lubos Uhliarik <luhliari@redhat.com> wrote:
>
> Hi Joseph,
>
> thanks for your answer! Is it still possible to get nres in the old way?
>
> The problem is, httpd is not possible to build with new Lua 5.4, since in mod_lua
> there are like 5 lua_resume calls. There is already macro:
>
> #define lua_resume(a,b)    lua_resume(a, NULL, b)
>
> Is there any chance, to solve this issue only by using macro? Something like:
>
> #if LUA_VERSION_NUM > 503
> #define lua_resume(a,b)    lua_resume(a, NULL, b, NULL)
> #else
> #define lua_resume(a,b)    lua_resume(a, NULL, b)
> #endif
>
>
> lua_gettop(L) is in the code used like 7 times and it is far away from lua_resume
> function calls, so I suppose it won't be so easy to rewrite it, if lua_gettop can NOT
> be used anymore. Or is it possible to use lua_gettop like in version 5.3 and pass NULL to the
> fourth param, as I mentioned above?

You can't pass NULL since it's unconditionally written to, but you can
pass the address of a dummy int instead. If you're okay with using a
GNU extension, you can use a statement expression to do that easily,
like this:

#define lua_resume(a,b) ({int nres; lua_resume(a, NULL, b, &nres); })

By the way, I'm slightly concerned that mod_lua always ignores the
stack after calling lua_resume, but that new #define is no worse than
the code that it was using before for Lua 5.3 and below.

Joseph C. Sible