Lua ensures that the memory in a userdata is aligned with values
in ISO C. If you have other objects that require other alignments
(such as 16-bit values), you can redefine the macro LUAI_MAXALIGN, in
luaconf.h. Its standard definition is like this:
#define LUAI_MAXALIGN lua_Number n; double u; void *s; lua_Integer i; long l
Just toss these other objects in this list.
-- Roberto
--
You received this message because you are subscribed to the Google Groups "lua-l" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lua-l+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/lua-l/7d247e5e-5c1d-4ab6-91bf-52c305546e02n%40googlegroups.com.
Lua ensures that the memory in a userdata is aligned with values
in ISO C. If you have other objects that require other alignments
(such as 16-bit values), you can redefine the macro LUAI_MAXALIGN, in
luaconf.h. Its standard definition is like this:
#define LUAI_MAXALIGN lua_Number n; double u; void *s; lua_Integer i; long l
Just toss these other objects in this list.
You can also look at std::align or how sol2 manages this: https://github.com/ThePhD/sol2/blob/develop/include/sol/stack_core.hpp#L129
I would replace the standard Lua allocator with one that when it creates a uservalue uses the (post-C89) 'aligned_alloc' function or whatever the system providesto create a properly aligned object. And of course you'd still have to add one of those Intel-specific types to LUAI_MAXALIGN.
15.02.2026 13:11:18 Andre Leiradella <an...@leiradella.com>:
I think what they meant is you can pass a custom allocator function in lua_newstate() instead of the default one provided by luaL_newstate()