Slightly better documentation for LUAI_MAXALIGN

This commit is contained in:
Roberto I
2026-03-09 16:23:03 -03:00
parent 10eb89d114
commit 9e501d9855
2 changed files with 15 additions and 4 deletions

View File

@@ -736,10 +736,17 @@
/* /*
@@ LUAI_MAXALIGN defines fields that, when used in a union, ensure @@ LUAI_MAXALIGN defines fields that ensure proper alignment for
** maximum alignment for the other items in that union. ** memory areas offered by Lua (e.g., userdata memory).
** Add fields to it if you need alignment for non-ISO objects.
*/ */
#if defined(LLONG_MAX)
/* use ISO C99 stuff */
#define LUAI_MAXALIGN long double u; void *s; long long l
#else
/* use only C89 stuff */
#define LUAI_MAXALIGN lua_Number n; double u; void *s; lua_Integer i; long l #define LUAI_MAXALIGN lua_Number n; double u; void *s; lua_Integer i; long l
#endif
/* }================================================================== */ /* }================================================================== */

View File

@@ -3915,8 +3915,12 @@ like any Lua object.
This function creates and pushes on the stack a new full userdata, This function creates and pushes on the stack a new full userdata,
with @id{nuvalue} associated Lua values, called @id{user values}, with @id{nuvalue} associated Lua values, called @id{user values},
plus an associated block of raw memory with @id{size} bytes. plus an associated block of raw memory with @id{size} bytes.
(The user values can be set and read with the functions
@Lid{lua_setiuservalue} and @Lid{lua_getiuservalue}.) The user values can be set and read with the functions
@Lid{lua_setiuservalue} and @Lid{lua_getiuservalue}.
The block of memory is suitably aligned for any @N{ISO C} object.
(See macro @id{LUAI_MAXALIGN} in file @id{luaconf.h} for other
alignment requirements.)
The function returns the address of the block of memory. The function returns the address of the block of memory.
Lua ensures that this address is valid as long as Lua ensures that this address is valid as long as