/**
* Mutex for multithread check.
*/
-#ifdef WIN32
-/* _glthread_DECLARE_STATIC_MUTEX is broken on windows. There will be race! */
-#define CHECK_MULTITHREAD_LOCK()
-#define CHECK_MULTITHREAD_UNLOCK()
-#else
u_mutex_declare_static(ThreadCheckMutex);
-#define CHECK_MULTITHREAD_LOCK() u_mutex_lock(ThreadCheckMutex)
-#define CHECK_MULTITHREAD_UNLOCK() u_mutex_unlock(ThreadCheckMutex)
-#endif
/**
* We should call this periodically from a function such as glXMakeCurrent
if (ThreadSafe)
return;
- CHECK_MULTITHREAD_LOCK();
+ u_mutex_lock(ThreadCheckMutex);
if (firstCall) {
u_current_init_tsd();
u_current_set(NULL);
u_current_set_user(NULL);
}
- CHECK_MULTITHREAD_UNLOCK();
+ u_mutex_unlock(ThreadCheckMutex);
}
#else
*/
#ifdef WIN32
-static void InsteadOf_exit(int nCode)
-{
- DWORD dwErr = GetLastError();
-}
-
unsigned long
u_thread_self(void)
{
tsd->key = TlsAlloc();
if (tsd->key == TLS_OUT_OF_INDEXES) {
perror(INIT_TSD_ERROR);
- InsteadOf_exit(-1);
+ exit(-1);
}
tsd->initMagic = INIT_MAGIC;
}
}
if (TlsSetValue(tsd->key, ptr) == 0) {
perror(SET_TSD_ERROR);
- InsteadOf_exit(-1);
+ exit(-1);
}
}
/* http://locklessinc.com/articles/pthreads_on_windows/ */
#define u_mutex_declare_static(name) \
- /* static */ u_mutex name = {(void*)-1, -1, 0, 0, 0, 0}
+ static u_mutex name = {(PCRITICAL_SECTION_DEBUG)-1, -1, 0, 0, 0, 0}
#define u_mutex_init(name) InitializeCriticalSection(&name)
#define u_mutex_destroy(name) DeleteCriticalSection(&name)