extern "C" void * f_nlmMainStub(
	void *		hThread,
	void *		pData)
{
	ARG_DATA *									pArgData = (ARG_DATA *)pData;
	struct LoadDefinitionStructure *		moduleHandle = pArgData->moduleHandle;

	(void)hThread;

	(void)kSetThreadName( (void *)kCurrentThread(),
		(BYTE *)pArgData->pszThreadName);

	nlm_main( pArgData->iArgC, pArgData->ppszArgV);

	Free( pArgData->ppszArgV);
	Free( pArgData->pszArgs);
	Free( pArgData->pszThreadName);
	Free( pArgData);

	gv_bMainRunning = FALSE;

	if( !gv_bUnloadCalled)
	{
		KillMe( moduleHandle);
	}
	
	kExitThread( NULL);
	return( NULL);
}
Exemplo n.º 2
0
BOOL fnUnregisterWithThreadTable(void)
{
        #ifdef MPK_ON
                return fnRemoveThreadInfo(labs((int)kCurrentThread()));
        #else
                return fnRemoveThreadInfo(GetThreadID());
        #endif	//MPK_ON
}
Exemplo n.º 3
0
BOOL fnRemoveThreadCtx(long lTLSIndex)
{
        ThreadContext* tip = NULL;
        ThreadContext* prevt = NULL;

        if (g_tCtxSem)
        {
                #ifdef MPK_ON
                        kSemaphoreWait(g_tCtxSem);
                #else
                        WaitOnLocalSemaphore(g_tCtxSem);
                #endif	//MPK_ON
        }

        #ifdef MPK_ON
                lTLSIndex = labs(kCurrentThread());
        #else
                lTLSIndex = GetThreadID();
        #endif	//MPK_ON

        tip = g_ThreadCtx;
        while(tip) {
                if (tip->tid == lTLSIndex) {
                        if (prevt == NULL)
                                g_ThreadCtx = tip->next;
                        else
                                prevt->next = tip->next;

                        free(tip);
                        tip=NULL;
                        if (g_tCtxSem)
                        {
                                #ifdef MPK_ON
                                        kSemaphoreSignal(g_tCtxSem);
                                #else
                                        SignalLocalSemaphore(g_tCtxSem);
                                #endif	//MPK_ON
                        }
                        return TRUE;
                }
                prevt = tip;
                tip = tip->next;
        }

        if (g_tCtxSem)
        {
                #ifdef MPK_ON
                        kSemaphoreSignal(g_tCtxSem);
                #else
                        SignalLocalSemaphore(g_tCtxSem);
                #endif	//MPK_ON
        }

        return FALSE;       // entry not found
}
Exemplo n.º 4
0
BOOL fnGetHashListAddrs(void **addrs, BOOL *dontTouchHashList)
{
        ThreadInfo*  tip;   
        int index,tid;   

        if (g_tinfoSem) 
        {
                #ifdef MPK_ON
                        kSemaphoreWait(g_tinfoSem);
                #else
                        WaitOnLocalSemaphore(g_tinfoSem);
                #endif	//MPK_ON
        }

        #ifdef MPK_ON
                tid=index = abs(kCurrentThread());
        #else
                tid=index = GetThreadID();
        #endif	//MPK_ON

        index = INDEXOF(index);     // just take the bottom five bits 

        // see if this is already in the table at the index'th offset
        //
        for (tip = g_ThreadInfo[index]; tip != NULL; tip = tip->next)
        {
                if (tip->tid == tid)
                {
                        if (g_tinfoSem)
                        {
                                #ifdef MPK_ON
                                        kSemaphoreSignal(g_tinfoSem);
                                #else
                                        SignalLocalSemaphore(g_tinfoSem);
                                #endif	//MPK_ON
                        }
                        *addrs = tip->m_allocList;
                        *dontTouchHashList = tip->m_dontTouchHashLists;
                        return TRUE;
                }
        }

        if (g_tinfoSem)
        {
                #ifdef MPK_ON
                        kSemaphoreSignal(g_tinfoSem);
                #else
                        SignalLocalSemaphore(g_tinfoSem);
                #endif	//MPK_ON
        }

        return FALSE;
}
Exemplo n.º 5
0
BOOL fnRegisterWithThreadTable(void)
{
        ThreadInfo* tinfo = NULL;

        #ifdef MPK_ON
                tinfo = fnAddThreadInfo(labs((int)kCurrentThread()));
        #else
                tinfo = fnAddThreadInfo(GetThreadID());
        #endif	//MPK_ON
        
        if (!tinfo)
                return FALSE;
        else
                return TRUE;
}
Exemplo n.º 6
0
void* fnGetThreadCtx(long lTLSIndex)
{
        ThreadContext*  tip;   

        if (g_tCtxSem) 
        {
                #ifdef MPK_ON
                        kSemaphoreWait(g_tCtxSem);
                #else
                        WaitOnLocalSemaphore(g_tCtxSem);
                #endif	//MPK_ON
        }

        #ifdef MPK_ON
                lTLSIndex = labs(kCurrentThread());
        #else
                lTLSIndex = GetThreadID();
        #endif	//MPK_ON

        tip = g_ThreadCtx;
        while(tip) {
                if (tip->tid == lTLSIndex) {
                        if (g_tCtxSem)
                        {
                                #ifdef MPK_ON
                                        kSemaphoreSignal(g_tCtxSem);
                                #else
                                        SignalLocalSemaphore(g_tCtxSem);
                                #endif	//MPK_ON
                        }
                        return (tip->tInfo);
                }
                tip=tip->next;
        }

        if (g_tCtxSem)
        {
                #ifdef MPK_ON
                        kSemaphoreSignal(g_tCtxSem);
                #else
                        SignalLocalSemaphore(g_tCtxSem);
                #endif	//MPK_ON
        }

        return NULL;
}
Exemplo n.º 7
0
ThreadContext* fnAddThreadCtx(long lTLSIndex, void *t)
{
        ThreadContext* tip = NULL;
        ThreadContext* temp = NULL;

        if (g_tCtxSem)
        {
                #ifdef MPK_ON
                        kSemaphoreWait(g_tCtxSem);
                #else
                        WaitOnLocalSemaphore(g_tCtxSem);
                #endif	//MPK_ON
        }

        // add a new one to the beginning of the list
        //
        tip = (ThreadContext *) malloc(sizeof(ThreadContext));
        if (tip == NULL)
        {  
                if (g_tCtxSem)
                {
                        #ifdef MPK_ON
                                kSemaphoreSignal(g_tCtxSem);
                        #else
                                SignalLocalSemaphore(g_tCtxSem);
                        #endif	//MPK_ON
                }
                return NULL;
        }

        #ifdef MPK_ON
                lTLSIndex = labs(kCurrentThread());
        #else
                lTLSIndex = GetThreadID();
        #endif	//MPK_ON

        tip->next            =  NULL;
        tip->tid             =  lTLSIndex;
        tip->tInfo			 =  t;

        if(g_ThreadCtx==NULL) {
                g_ThreadCtx = tip;
        } else {
                int count=0;
                //Traverse to the end
                temp = g_ThreadCtx;
                while(temp->next != NULL)
                {
                        temp = temp->next;
                        count++;
                }
                temp->next = tip;
        }

        if (g_tCtxSem)
        {
                #ifdef MPK_ON
                        kSemaphoreSignal(g_tCtxSem);
                #else
                        SignalLocalSemaphore(g_tCtxSem);
                #endif	//MPK_ON
        }
        return tip;
}