| 125 | |
| 126 | |
| 127 | static int auxstatus (lua_State *L, lua_State *co) { |
| 128 | if (L == co) return COS_RUN; |
| 129 | else { |
| 130 | switch (lua_status(co)) { |
| 131 | case LUA_YIELD: |
| 132 | return COS_YIELD; |
| 133 | case LUA_OK: { |
| 134 | lua_Debug ar; |
| 135 | if (lua_getstack(co, 0, &ar)) /* does it have frames? */ |
| 136 | return COS_NORM; /* it is running */ |
| 137 | else if (lua_gettop(co) == 0) |
| 138 | return COS_DEAD; |
| 139 | else |
| 140 | return COS_YIELD; /* initial state */ |
| 141 | } |
| 142 | default: /* some error occurred */ |
| 143 | return COS_DEAD; |
| 144 | } |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | |
| 149 | static int luaB_costatus (lua_State *L) { |
no test coverage detected