lua-users home
lua-l archive

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


On Tue, May 02, 2023 at 02:16:02AM +0100, Andrew Gierth wrote:
> >>>>> "Marc" == Marc Balmer <marc@msys.ch> writes:
> 
>  Marc> None of mine does. But that does not mean that breaking an ABI is
>  Marc> good, especially if the documentation apparently says the ABI
>  Marc> will keep stable for patch releases.
> 
> Exactly. And how are maintainers of OS packages supposed to handle this?
> I'm finding it hard to come up with a workaround - even tricks like
> using a different soname for the new library wouldn't work when part of
> the issue is a (packaged) lua binary being used to load modules
> belonging to an (unpackaged or indepedently packaged) application.
> 

A quick hack that preserves ABI compatibility would be something like,

  --- lua.h.bak	2023-04-13 05:24:29.000000000 -0700
  +++ lua.h	2023-05-02 16:36:08.000000000 -0700
  @@ -166 +166,3 @@
  -LUA_API int        (lua_resetthread) (lua_State *L, lua_State *from);
  +LUA_API int        (lua_resetthread) (lua_State *L);
  +LUA_API int        (lua_resetthread2) (lua_State *L, lua_State *from);
  +#define lua_resetthread(L, from) lua_resetthread2((L), (from))

  --- lstate.c.bak	2023-04-13 05:24:28.000000000 -0700
  +++ lstate.c	2023-05-02 16:37:45.000000000 -0700
  @@ -342 +342,6 @@
  -LUA_API int lua_resetthread (lua_State *L, lua_State *from) {
  +LUA_API int (lua_resetthread) (lua_State *L) {
  +  return lua_resetthread2(L, NULL);
  +}
  +
  +
  +LUA_API int lua_resetthread2 (lua_State *L, lua_State *from) {

API compatibility could be preserved using C99 variadic macros:

  #define lua_resetthread(...) lua_resetthread2(__VA_ARGS__, NULL)
  #define lua_resetthread2(L, from, ...) (lua_resetthread2)((L), (from))

But then there's little incentive for upstream packages to fix their code.
Though, for a distro using clang or GCC you could probably hack together
something using _Pragma that complains loudly at compile time if the default
NULL argument is evaluated.