Пример #1
0
BOOL WINAPI DllMain(HINSTANCE hModule, DWORD dwReason, LPVOID lpReserved)
{
	switch (dwReason) {
	case DLL_PROCESS_ATTACH:
		thread_once(&init_once,	internal_idevice_init);
		break;
	case DLL_PROCESS_DETACH:
		thread_once(&deinit_once, internal_idevice_deinit);
		break;
	default:
		break;
	}
	return 1;
}
Пример #2
0
void xpush_context(xcontext_t *context)
{
    xcontext_t *top_context;
    thread_once(&exception_stack_key_once, *exception_stack_alloc);
    top_context = (xcontext_t *)thread_getspecific(exception_stack_key);
    context->next = top_context;
    thread_setspecific(exception_stack_key, context);
    context->handled = true;
    context->in_finally = false;
}
Пример #3
0
static void *internal_linux_callback_wrapper(void *parg)
{
	thread_t *t = (thread_t *)parg;
	
	thread_once(&_tls_control, internal_tls_init);
	pthread_setspecific(_tls, t);
	
	if (t) {
		t->thread_id = getpid();
		t->callback(parg);
	}
	
	pthread_exit(NULL);
}
Пример #4
0
static unsigned __stdcall internal_win32_callback_wrapper(void *parg)
{
	thread_t *t = (thread_t *)parg;
	
	thread_once(&_tls_control, internal_tls_init);
	TlsSetValue(_tls, t);
	
	if (t) { t->callback(parg); }
	
	while (t->thread == (HANDLE)-1) {
		YieldProcessor();
		_ReadWriteBarrier();
	}
	
	return 0;
}
Пример #5
0
void xpop_context()
{
    xcontext_t *top_cxt, *context;
    thread_once(&exception_stack_key_once, *exception_stack_alloc);
    top_cxt = (xcontext_t *)thread_getspecific(exception_stack_key);
    context = top_cxt->next;
    thread_setspecific(exception_stack_key, context);
    if (!top_cxt->handled) {
        if (context) {
            xraise_context(context, top_cxt->excode, top_cxt->msg);
        }
        else {
            XEXIT(ERROR_TYPES[top_cxt->excode], top_cxt->msg);
        }
    }
}
Пример #6
0
void xraise(int excode, const char *const msg)
{
    xcontext_t *top_context;
    thread_once(&exception_stack_key_once, *exception_stack_alloc);
    top_context = (xcontext_t *)thread_getspecific(exception_stack_key);

    if (!top_context) {
        XEXIT(ERROR_TYPES[excode], msg);
    }
    else if (!top_context->in_finally) {
        xraise_context(top_context, excode, msg);
    }
    else if (top_context->handled) {
        top_context->msg = msg;
        top_context->excode = excode;
        top_context->handled = false;
    }
}
Пример #7
0
/**
 * The wrapper calls for thread creation attempt to store the thread_t 
 * pointer in thread-local storage.  When thread_self is called that
 * data is retreived (if it can be), otherwise an empty thread_t structure
 * is created and filled with the proper handle.
 */
thread_t *thread_self()
{
	thread_t *t;
	
	thread_once(&_tls_control, internal_tls_init);
#ifdef ACE_WINDOWS
	t = (thread_t *)TlsGetValue(_tls);
	
	if (!t)
	{
		t = (thread_t *)malloc(sizeof(thread_t));
		
		if (!t) exit(ENOMEM);
		
		memset(t, 0, sizeof(thread_t));
		t->thread = GetCurrentThread();
		
		TlsSetValue(_tls, t);
	}
#else
	t = (thread_t *)pthread_getspecific(_tls);

	if (!t)
	{
		t = malloc(sizeof(thread_t));
		
		if (!t) exit(ENOMEM);
		
		memset(t, 0, sizeof(thread_t));
		t->thread = pthread_self();
		
		pthread_setspecific(_tls, t);
	}
#endif

	return t;
}
Пример #8
0
static void __attribute__((destructor)) libimobiledevice_deinitialize(void)
{
	thread_once(&deinit_once, internal_idevice_deinit);
}