diff options
author | Kyle Evans <kevans@FreeBSD.org> | 2021-01-14 05:56:18 +0000 |
---|---|---|
committer | Kyle Evans <kevans@FreeBSD.org> | 2021-01-14 05:56:18 +0000 |
commit | 0495ed398c4f64013bab2327eb13a303e1f90c13 (patch) | |
tree | a3100af4498f59c50af29bbc0f48034d5cc92765 /contrib/lua/src/lapi.h | |
parent | 7ae27c2d6c4fe4f21e1219bb5d8a37cfc932337b (diff) | |
parent | 0ea45b9cd43ce1247eb3eee9bfd5cee3d19068e7 (diff) | |
download | src-0495ed398c4f64013bab2327eb13a303e1f90c13.tar.gz src-0495ed398c4f64013bab2327eb13a303e1f90c13.zip |
contrib/lua: update to 5.4.2
Merge commit '0ea45b9cd43ce1247eb3eee9bfd5cee3d19068e7' into main
Diffstat (limited to 'contrib/lua/src/lapi.h')
-rw-r--r-- | contrib/lua/src/lapi.h | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/contrib/lua/src/lapi.h b/contrib/lua/src/lapi.h index 8e16ad53d999..41216b270902 100644 --- a/contrib/lua/src/lapi.h +++ b/contrib/lua/src/lapi.h @@ -1,5 +1,5 @@ /* -** $Id: lapi.h,v 2.9.1.1 2017/04/19 17:20:42 roberto Exp $ +** $Id: lapi.h $ ** Auxiliary functions from Lua API ** See Copyright Notice in lua.h */ @@ -11,14 +11,37 @@ #include "llimits.h" #include "lstate.h" + +/* Increments 'L->top', checking for stack overflows */ #define api_incr_top(L) {L->top++; api_check(L, L->top <= L->ci->top, \ "stack overflow");} + +/* +** If a call returns too many multiple returns, the callee may not have +** stack space to accommodate all results. In this case, this macro +** increases its stack space ('L->ci->top'). +*/ #define adjustresults(L,nres) \ - { if ((nres) == LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; } + { if ((nres) <= LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; } + +/* Ensure the stack has at least 'n' elements */ #define api_checknelems(L,n) api_check(L, (n) < (L->top - L->ci->func), \ "not enough elements in the stack") +/* +** To reduce the overhead of returning from C functions, the presence of +** to-be-closed variables in these functions is coded in the CallInfo's +** field 'nresults', in a way that functions with no to-be-closed variables +** with zero, one, or "all" wanted results have no overhead. Functions +** with other number of wanted results, as well as functions with +** variables to be closed, have an extra check. +*/ + +#define hastocloseCfunc(n) ((n) < LUA_MULTRET) + +#define codeNresults(n) (-(n) - 3) + #endif |