From bee331e23dcfed961e64b68e392ca468dc3a1a65 Mon Sep 17 00:00:00 2001 From: Francois Perrad Date: Fri, 24 Mar 2017 10:53:03 +0100 Subject: [PATCH] add lua_isyieldable() from 5.3 --- src/lj_api.c | 5 +++++ src/lua.h | 3 +++ 2 files changed, 8 insertions(+) diff --git a/src/lj_api.c b/src/lj_api.c index e76cf8fe..1c40beba 100644 --- a/src/lj_api.c +++ b/src/lj_api.c @@ -1110,6 +1110,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;