mirror of https://github.com/rusefi/lua.git
'setCstacklimit' renamed to 'setcstacklimit'
Function names in the API use only lowercase letters.
This commit is contained in:
parent
6b2e202df5
commit
03cde80b58
6
ldblib.c
6
ldblib.c
|
@ -437,9 +437,9 @@ static int db_traceback (lua_State *L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int db_setCstacklimit (lua_State *L) {
|
static int db_setcstacklimit (lua_State *L) {
|
||||||
int limit = (int)luaL_checkinteger(L, 1);
|
int limit = (int)luaL_checkinteger(L, 1);
|
||||||
int res = lua_setCstacklimit(L, limit);
|
int res = lua_setcstacklimit(L, limit);
|
||||||
if (res == 0)
|
if (res == 0)
|
||||||
lua_pushboolean(L, 0);
|
lua_pushboolean(L, 0);
|
||||||
else
|
else
|
||||||
|
@ -465,7 +465,7 @@ static const luaL_Reg dblib[] = {
|
||||||
{"setmetatable", db_setmetatable},
|
{"setmetatable", db_setmetatable},
|
||||||
{"setupvalue", db_setupvalue},
|
{"setupvalue", db_setupvalue},
|
||||||
{"traceback", db_traceback},
|
{"traceback", db_traceback},
|
||||||
{"setCstacklimit", db_setCstacklimit},
|
{"setcstacklimit", db_setcstacklimit},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
2
lstate.c
2
lstate.c
|
@ -96,7 +96,7 @@ void luaE_setdebt (global_State *g, l_mem debt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API int lua_setCstacklimit (lua_State *L, unsigned int limit) {
|
LUA_API int lua_setcstacklimit (lua_State *L, unsigned int limit) {
|
||||||
global_State *g = G(L);
|
global_State *g = G(L);
|
||||||
int ccalls;
|
int ccalls;
|
||||||
luaE_freeCI(L); /* release unused CIs */
|
luaE_freeCI(L); /* release unused CIs */
|
||||||
|
|
2
lua.h
2
lua.h
|
@ -462,7 +462,7 @@ LUA_API lua_Hook (lua_gethook) (lua_State *L);
|
||||||
LUA_API int (lua_gethookmask) (lua_State *L);
|
LUA_API int (lua_gethookmask) (lua_State *L);
|
||||||
LUA_API int (lua_gethookcount) (lua_State *L);
|
LUA_API int (lua_gethookcount) (lua_State *L);
|
||||||
|
|
||||||
LUA_API int (lua_setCstacklimit) (lua_State *L, unsigned int limit);
|
LUA_API int (lua_setcstacklimit) (lua_State *L, unsigned int limit);
|
||||||
|
|
||||||
struct lua_Debug {
|
struct lua_Debug {
|
||||||
int event;
|
int event;
|
||||||
|
|
|
@ -4814,7 +4814,7 @@ calling @Lid{lua_yield} with @id{nresults} equal to zero
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@APIEntry{int (lua_setCstacklimit) (lua_State *L, unsigned int limit);|
|
@APIEntry{int (lua_setcstacklimit) (lua_State *L, unsigned int limit);|
|
||||||
@apii{0,0,-}
|
@apii{0,0,-}
|
||||||
|
|
||||||
Sets a new limit for the C stack.
|
Sets a new limit for the C stack.
|
||||||
|
@ -4823,7 +4823,7 @@ with the intent of avoiding a stack overflow.
|
||||||
Returns the old limit in case of success,
|
Returns the old limit in case of success,
|
||||||
or zero in case of error.
|
or zero in case of error.
|
||||||
For more details about this function,
|
For more details about this function,
|
||||||
see @Lid{debug.setCstacklimit},
|
see @Lid{debug.setcstacklimit},
|
||||||
its equivalent in the standard library.
|
its equivalent in the standard library.
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8565,7 +8565,7 @@ to the userdata @id{u} plus a boolean,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@LibEntry{debug.setCstacklimit (limit)|
|
@LibEntry{debug.setcstacklimit (limit)|
|
||||||
|
|
||||||
Sets a new limit for the C stack.
|
Sets a new limit for the C stack.
|
||||||
This limit controls how deeply nested calls can go in Lua,
|
This limit controls how deeply nested calls can go in Lua,
|
||||||
|
@ -8586,10 +8586,10 @@ This function has the following restrictions:
|
||||||
@item{@id{limit} must be less than 40000;}
|
@item{@id{limit} must be less than 40000;}
|
||||||
@item{@id{limit} cannot be less than the amount of C stack in use.}
|
@item{@id{limit} cannot be less than the amount of C stack in use.}
|
||||||
}
|
}
|
||||||
In case of success,
|
If a call does not respect some restriction,
|
||||||
this function returns the old limit.
|
|
||||||
In case of error,
|
|
||||||
it returns @false.
|
it returns @false.
|
||||||
|
Otherwise,
|
||||||
|
the call returns the old limit.
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ print"If this test craches, see its file ('cstack.lua')"
|
||||||
|
|
||||||
-- Segmentation faults in these tests probably result from a C-stack
|
-- Segmentation faults in these tests probably result from a C-stack
|
||||||
-- overflow. To avoid these errors, you can use the function
|
-- overflow. To avoid these errors, you can use the function
|
||||||
-- 'debug.setCstacklimit' to set a smaller limit for the use of
|
-- 'debug.setcstacklimit' to set a smaller limit for the use of
|
||||||
-- C stack by Lua. After finding a reliable limit, you might want
|
-- C stack by Lua. After finding a reliable limit, you might want
|
||||||
-- to recompile Lua with this limit as the value for
|
-- to recompile Lua with this limit as the value for
|
||||||
-- the constant 'LUAI_MAXCCALLS', which defines the default limit.
|
-- the constant 'LUAI_MAXCCALLS', which defines the default limit.
|
||||||
|
@ -19,12 +19,12 @@ print"If this test craches, see its file ('cstack.lua')"
|
||||||
-- higher than 2_000.
|
-- higher than 2_000.
|
||||||
|
|
||||||
|
|
||||||
local origlimit = debug.setCstacklimit(400)
|
local origlimit = debug.setcstacklimit(400)
|
||||||
print("default stack limit: " .. origlimit)
|
print("default stack limit: " .. origlimit)
|
||||||
|
|
||||||
-- change this value for different limits for this test suite
|
-- change this value for different limits for this test suite
|
||||||
local currentlimit = origlimit
|
local currentlimit = origlimit
|
||||||
debug.setCstacklimit(currentlimit)
|
debug.setcstacklimit(currentlimit)
|
||||||
print("current stack limit: " .. currentlimit)
|
print("current stack limit: " .. currentlimit)
|
||||||
|
|
||||||
|
|
||||||
|
@ -102,10 +102,10 @@ end
|
||||||
|
|
||||||
do print("testing changes in C-stack limit")
|
do print("testing changes in C-stack limit")
|
||||||
|
|
||||||
assert(not debug.setCstacklimit(0)) -- limit too small
|
assert(not debug.setcstacklimit(0)) -- limit too small
|
||||||
assert(not debug.setCstacklimit(50000)) -- limit too large
|
assert(not debug.setcstacklimit(50000)) -- limit too large
|
||||||
local co = coroutine.wrap (function ()
|
local co = coroutine.wrap (function ()
|
||||||
return debug.setCstacklimit(400)
|
return debug.setcstacklimit(400)
|
||||||
end)
|
end)
|
||||||
assert(co() == false) -- cannot change C stack inside coroutine
|
assert(co() == false) -- cannot change C stack inside coroutine
|
||||||
|
|
||||||
|
@ -118,26 +118,26 @@ do print("testing changes in C-stack limit")
|
||||||
return n
|
return n
|
||||||
end
|
end
|
||||||
|
|
||||||
assert(debug.setCstacklimit(400) == currentlimit)
|
assert(debug.setcstacklimit(400) == currentlimit)
|
||||||
local lim400 = check()
|
local lim400 = check()
|
||||||
-- a very low limit (given that the several calls to arive here)
|
-- a very low limit (given that the several calls to arive here)
|
||||||
local lowlimit = 38
|
local lowlimit = 38
|
||||||
assert(debug.setCstacklimit(lowlimit) == 400)
|
assert(debug.setcstacklimit(lowlimit) == 400)
|
||||||
assert(check() < lowlimit - 30)
|
assert(check() < lowlimit - 30)
|
||||||
assert(debug.setCstacklimit(600) == lowlimit)
|
assert(debug.setcstacklimit(600) == lowlimit)
|
||||||
local lim600 = check()
|
local lim600 = check()
|
||||||
assert(lim600 == lim400 + 200)
|
assert(lim600 == lim400 + 200)
|
||||||
|
|
||||||
|
|
||||||
-- 'setCstacklimit' works inside protected calls. (The new stack
|
-- 'setcstacklimit' works inside protected calls. (The new stack
|
||||||
-- limit is kept when 'pcall' returns.)
|
-- limit is kept when 'pcall' returns.)
|
||||||
assert(pcall(function ()
|
assert(pcall(function ()
|
||||||
assert(debug.setCstacklimit(400) == 600)
|
assert(debug.setcstacklimit(400) == 600)
|
||||||
assert(check() <= lim400)
|
assert(check() <= lim400)
|
||||||
end))
|
end))
|
||||||
|
|
||||||
assert(check() == lim400)
|
assert(check() == lim400)
|
||||||
assert(debug.setCstacklimit(origlimit) == 400) -- restore original limit
|
assert(debug.setcstacklimit(origlimit) == 400) -- restore original limit
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue