Example #1
0
void _jit_thread_init(void)
{
#if defined(JIT_THREADS_PTHREAD)
	static pthread_once_t once_control = PTHREAD_ONCE_INIT;
	pthread_once(&once_control, init_pthread);
#elif defined(JIT_THREADS_WIN32)
	static LONG volatile once_control = 0;
	if(!InterlockedExchange((PLONG)&once_control, 1))
	{
		init_win32_thread();
	}
#endif
}
Example #2
0
void _jit_thread_init(void)
{
#if defined(JIT_THREADS_PTHREAD)
	static pthread_once_t once_control = PTHREAD_ONCE_INIT;
	pthread_once(&once_control, init_pthread);
#elif defined(JIT_THREADS_WIN32)
	static LONG volatile once_control = 0;
	switch(InterlockedExchange(&once_control, 1))
	{
	case 0:
		init_win32_thread();
		InterlockedExchange(&once_control, 2);
		break;
	case 1:
		while(InterlockedCompareExchange(&once_control, 2, 2) != 2)
		{
		}
		break;
	}
#endif
}