diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-06-18 16:52:22 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-06-18 16:52:22 -0300 |
commit | be73f72fcc944a8ebae2c60d2ce84139acb011b9 (patch) | |
tree | 6ba1154c224a4b7af9e5202b4b52e43706faddb1 /manual | |
parent | 3cd9b56ae6002b4ef28d2467abd119606ae625d3 (diff) | |
download | lua-be73f72fcc944a8ebae2c60d2ce84139acb011b9.tar.gz lua-be73f72fcc944a8ebae2c60d2ce84139acb011b9.tar.bz2 lua-be73f72fcc944a8ebae2c60d2ce84139acb011b9.zip |
New function 'setCstacklimit'
Added new functions to dynamically set the C-stack limit
('lua_setCstacklimit' in the C-API, 'debug.setCstacklimit' in Lua).
Diffstat (limited to 'manual')
-rw-r--r-- | manual/manual.of | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/manual/manual.of b/manual/manual.of index 725b12ad..e9416956 100644 --- a/manual/manual.of +++ b/manual/manual.of | |||
@@ -4803,6 +4803,20 @@ calling @Lid{lua_yield} with @id{nresults} equal to zero | |||
4803 | 4803 | ||
4804 | } | 4804 | } |
4805 | 4805 | ||
4806 | @APIEntry{int (lua_setCstacklimit) (lua_State *L, unsigned int limit);| | ||
4807 | @apii{0,0,-} | ||
4808 | |||
4809 | Sets a new limit for the C stack. | ||
4810 | This limit controls how deeply nested calls can go in Lua, | ||
4811 | with the intent of avoiding a stack overflow. | ||
4812 | Returns the old limit in case of success, | ||
4813 | or zero in case of error. | ||
4814 | For more details about this function, | ||
4815 | see @Lid{debug.setCstacklimit}, | ||
4816 | its equivalent in the standard library. | ||
4817 | |||
4818 | } | ||
4819 | |||
4806 | @APIEntry{void lua_sethook (lua_State *L, lua_Hook f, int mask, int count);| | 4820 | @APIEntry{void lua_sethook (lua_State *L, lua_Hook f, int mask, int count);| |
4807 | @apii{0,0,-} | 4821 | @apii{0,0,-} |
4808 | 4822 | ||
@@ -8516,6 +8530,34 @@ to the userdata @id{u} plus a boolean, | |||
8516 | 8530 | ||
8517 | } | 8531 | } |
8518 | 8532 | ||
8533 | @LibEntry{debug.setCstacklimit (limit)| | ||
8534 | |||
8535 | Sets a new limit for the C stack. | ||
8536 | This limit controls how deeply nested calls can go in Lua, | ||
8537 | with the intent of avoiding a stack overflow. | ||
8538 | A limit too small restricts recursive calls pointlessly; | ||
8539 | a limit too large exposes the interpreter to stack-overflow crashes. | ||
8540 | Unfortunately, there is no way to know a priori | ||
8541 | the maximum safe limit for a platform. | ||
8542 | |||
8543 | Each call made from Lua code counts one unit. | ||
8544 | Other operations (e.g., calls made from C to Lua or resuming a coroutine) | ||
8545 | may have a higher cost. | ||
8546 | |||
8547 | This function has the following restrictions: | ||
8548 | @description{ | ||
8549 | @item{It can only be called from the main coroutine (thread);} | ||
8550 | @item{It cannot be called while handling a stack-overflow error;} | ||
8551 | @item{@id{limit} must be less than 40000;} | ||
8552 | @item{@id{limit} cannot be less than the amount of C stack in use.} | ||
8553 | } | ||
8554 | In case of success, | ||
8555 | this function returns the old limit. | ||
8556 | In case of error, | ||
8557 | it returns @false. | ||
8558 | |||
8559 | } | ||
8560 | |||
8519 | @LibEntry{debug.sethook ([thread,] hook, mask [, count])| | 8561 | @LibEntry{debug.sethook ([thread,] hook, mask [, count])| |
8520 | 8562 | ||
8521 | Sets the given function as the debug hook. | 8563 | Sets the given function as the debug hook. |