summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Pall <mike>2017-04-07 12:27:09 +0200
committerMike Pall <mike>2017-04-07 12:27:09 +0200
commitf2e2a3f757629c520ebcac44ba7fb12cb07e56e2 (patch)
tree53477bf4935278c2df459a7368d06c3bb9839729
parentef23b70eb64f67c6e6606098baad3cb0ba98d1c3 (diff)
downloadluajit2-f2e2a3f757629c520ebcac44ba7fb12cb07e56e2.tar.gz
From Lua 5.3: Add lua_isyieldable().
Contributed by François Perrad.
-rw-r--r--src/lj_api.c5
-rw-r--r--src/lua.h3
2 files changed, 8 insertions, 0 deletions
diff --git a/src/lj_api.c b/src/lj_api.c
index 3c1a07bc..c417af7e 100644
--- a/src/lj_api.c
+++ b/src/lj_api.c
@@ -1113,6 +1113,11 @@ LUALIB_API int luaL_callmeta(lua_State *L, int idx, const char *field)
/* -- Coroutine yield and resume ------------------------------------------ */
+LUA_API int lua_isyieldable(lua_State *L)
+{
+ return cframe_canyield(L->cframe);
+}
+
LUA_API int lua_yield(lua_State *L, int nresults)
{
void *cf = L->cframe;
diff --git a/src/lua.h b/src/lua.h
index 0c653f56..615e0e36 100644
--- a/src/lua.h
+++ b/src/lua.h
@@ -351,6 +351,9 @@ LUA_API int lua_loadx (lua_State *L, lua_Reader reader, void *dt,
LUA_API const lua_Number *lua_version (lua_State *L);
LUA_API void lua_copy (lua_State *L, int fromidx, int toidx);
+/* From Lua 5.3. */
+LUA_API int lua_isyieldable (lua_State *L);
+
struct lua_Debug {
int event;