Ejemplo n.º 1
0
GCudata *lj_udata_new(lua_State *L, MSize sz, GCtab *env)
{
  GCudata *ud = lj_mem_newt(L, sizeof(GCudata) + sz, GCudata);
  global_State *g = G(L);
  newwhite(g, ud);  /* Not finalized. */
  ud->gct = ~LJ_TUDATA;
  ud->udtype = UDTYPE_USERDATA;
  ud->len = sz;
  /* NOBARRIER: The GCudata is new (marked white). */
  setgcrefnull(ud->metatable);
  setgcref(ud->env, obj2gco(env));
  /* Chain to userdata list (after main thread). */
  setgcrefr(ud->nextgc, mainthread(g)->nextgc);
  setgcref(mainthread(g)->nextgc, obj2gco(ud));
  return ud;
}
Ejemplo n.º 2
0
static VOID
worker_thread(VOID * notused)
{
  int argc = 3;
  char fullfilename[MAX_PATH];
  char directory[MAX_PATH];
  static const char configname[] = "mush.cnf";
  static const char errorlogname[] = "log\\game.log";
  char *argv[3] = { fullfilename, configname, errorlogname };
  char *p;

  if (!GetModuleFileName(NULL, fullfilename, sizeof(fullfilename))) {
    service_error(GetLastError(), "Cannot locate full filename");
    Win32_Exit(1);
  }
/*  remove last part of file name to get working directory */

  strcpy(directory, fullfilename);

  p = strrchr(directory, '\\');
  if (p)
    *p = 0;

/*  make sure we are running in the MUSH directory */

  _chdir(directory);

/*  if running as a service, redirect stderr to a log file. */

  if (threadHandle)
    freopen("log\\game.log", "w", stderr);

/*  handle shutdowns and ctrl-c */

  SetConsoleCtrlHandler(shut_down_handler, TRUE);

/*  start up the main MUSH code */

  exit(mainthread(argc, argv));

}                               /*  end of worker_thread */
Ejemplo n.º 3
0
// Main lua VM debug hook
void LSProfiler::profileHook(lua_State *L, lua_Debug *ar)
{
    // Only process calls from the main thread for now
#ifdef LOOM_ENABLE_JIT
    lua_State *mainL = mainthread(G(L));
#else
    lua_State *mainL = L->l_G->mainthread;
#endif
    if (mainL != L)
        return;

    MethodBase *methodBase = NULL;

    if (ar->event == LUA_HOOKCALL)
    {
        methodBase = getTopMethod(L);

        if (methodBase)
        {
            methodStack.push(methodBase);
            enterMethod(methodBase->getFullMemberName());
        }
    }

    if (ar->event == LUA_HOOKRET)
    {
        methodBase = getTopMethod(L);

        if (methodBase)
        {
            if (methodStack.size())
            {
                methodStack.pop();
                leaveMethod(methodBase->getFullMemberName());
            }
        }
    }
}
Ejemplo n.º 4
0
void *mainthreadptr(){
  mainthread();  
}