]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
From Lua 5.3: Add lua_isyieldable().
authorMike Pall <mike>
Fri, 7 Apr 2017 10:27:09 +0000 (12:27 +0200)
committerMike Pall <mike>
Fri, 7 Apr 2017 10:27:09 +0000 (12:27 +0200)
Contributed by François Perrad.

src/lj_api.c
src/lua.h

index 3c1a07bce86cd0020fd9afc2842f1b9b83396cd8..c417af7e71b38f836a41ea9ae01c1028cc7182ea 100644 (file)
@@ -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;
index 0c653f561fa76096a65761ef8addce64658df238..615e0e366acd233e41916e39bbb303ad5b1d1a05 100644 (file)
--- 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;