/* Auxiliary function used by several library functions: check for an optional thread as function's first argument and set 'arg' with 1 if this argument is present (so that functions can skip it to access their other arguments)  */
static lua_State* getthread(lua_State *L, int *arg)
/* Auxiliary function used by several library functions: check for an optional thread as function's first argument and set 'arg' with 1 if this argument is present (so that functions can skip it to access their other arguments)  */
static lua_State* getthread(lua_State *L, int *arg)
{
    *arg = 1;
    return lua_tothread(L, 1);
  }
  else {
    *arg = 0;
    return L;
  }
}