commit ff106c028ca944ee5e95b005628e2669b87bcaf2
parent d738c8d18bcc5651109b3a46103d6aa983772e68
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Mon, 12 Dec 2022 14:08:28 -0300
Merge branch 'master' into nextversion
Diffstat:
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/lgc.c b/lgc.c
@@ -1614,12 +1614,16 @@ static void incstep (lua_State *L, global_State *g) {
}
/*
-** performs a basic GC step if collector is running
+** Performs a basic GC step if collector is running. (If collector is
+** not running, set a reasonable debt to avoid it being called at
+** every single check.)
*/
void luaC_step (lua_State *L) {
global_State *g = G(L);
lua_assert(!g->gcemergency);
- if (gcrunning(g)) { /* running? */
+ if (!gcrunning(g)) /* not running? */
+ luaE_setdebt(g, -2000);
+ else {
switch (g->gckind) {
case KGC_INC:
incstep(L, g);
diff --git a/lmathlib.c b/lmathlib.c
@@ -267,7 +267,7 @@ static int math_type (lua_State *L) {
/* try to find an integer type with at least 64 bits */
-#if (ULONG_MAX >> 31 >> 31) >= 3
+#if ((ULONG_MAX >> 31) >> 31) >= 3
/* 'long' has at least 64 bits */
#define Rand64 unsigned long
@@ -277,9 +277,9 @@ static int math_type (lua_State *L) {
/* there is a 'long long' type (which must have at least 64 bits) */
#define Rand64 unsigned long long
-#elif (LUA_MAXUNSIGNED >> 31 >> 31) >= 3
+#elif ((LUA_MAXUNSIGNED >> 31) >> 31) >= 3
-/* 'lua_Integer' has at least 64 bits */
+/* 'lua_Unsigned' has at least 64 bits */
#define Rand64 lua_Unsigned
#endif
@@ -500,12 +500,12 @@ static lua_Number I2d (Rand64 x) {
/* convert a 'Rand64' to a 'lua_Unsigned' */
static lua_Unsigned I2UInt (Rand64 x) {
- return ((lua_Unsigned)trim32(x.h) << 31 << 1) | (lua_Unsigned)trim32(x.l);
+ return (((lua_Unsigned)trim32(x.h) << 31) << 1) | (lua_Unsigned)trim32(x.l);
}
/* convert a 'lua_Unsigned' to a 'Rand64' */
static Rand64 Int2I (lua_Unsigned n) {
- return packI((lu_int32)(n >> 31 >> 1), (lu_int32)n);
+ return packI((lu_int32)((n >> 31) >> 1), (lu_int32)n);
}
#endif /* } */