Example #1
0
Boolean AttachElastosDll()
{
#ifdef _win32
    ECode ec = NOERROR;
#endif
    pthread_mutexattr_t recursiveAttr;

    InitTLS();
    InitMIL();

    Elastos::IPC::InitROT();
    Elastos::IPC::InitProxyEntry();

    Elastos::RPC::InitROT_RPC();
    Elastos::RPC::InitProxyEntry();

    pthread_mutexattr_init(&recursiveAttr);
    pthread_mutexattr_settype(&recursiveAttr, PTHREAD_MUTEX_RECURSIVE);
    if (pthread_mutex_init(&g_LocModListLock, &recursiveAttr)) {
        goto E_FAIL_EXIT;
    }
    pthread_mutexattr_destroy(&recursiveAttr);

    return TRUE;

E_FAIL_EXIT:
    return FALSE;
}
void WINAPI StoreTLS(DWORD value)
{
  LPVOID tlsData;
  DWORD *data;

  tlsData = ::TlsGetValue(s_TlsCleanup.index());
  if (tlsData == nullptr) {
    // this can happen for threads started before this dll was loaded
    tlsData = InitTLS();
    if (tlsData == nullptr) {
      Logger::Instance().error("failed to store tls data");
      return;
    }
  }

  data = (DWORD*)tlsData;

  (*data) = value;
}