wgl: Cope with pre-existing threads.
DllMain is called with DLL_THREAD_ATTACH only by threads created after the DLL is loaded by the process.
This commit is contained in:
parent
c384ccb0c4
commit
76b9da9e98
|
@ -44,6 +44,20 @@ stw_tls_init(void)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static INLINE struct stw_tls_data *
|
||||||
|
stw_tls_data_create()
|
||||||
|
{
|
||||||
|
struct stw_tls_data *data;
|
||||||
|
|
||||||
|
data = CALLOC_STRUCT(stw_tls_data);
|
||||||
|
if (!data)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
data->currentPixelFormat = 0;
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
boolean
|
boolean
|
||||||
stw_tls_init_thread(void)
|
stw_tls_init_thread(void)
|
||||||
{
|
{
|
||||||
|
@ -53,14 +67,9 @@ stw_tls_init_thread(void)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
data = MALLOC(sizeof(*data));
|
data = stw_tls_data_create();
|
||||||
if (!data) {
|
if(!data)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
data->currentPixelFormat = 0;
|
|
||||||
data->currentDC = NULL;
|
|
||||||
data->currentGLRC = 0;
|
|
||||||
|
|
||||||
TlsSetValue(tlsIndex, data);
|
TlsSetValue(tlsIndex, data);
|
||||||
|
|
||||||
|
@ -93,9 +102,23 @@ stw_tls_cleanup(void)
|
||||||
struct stw_tls_data *
|
struct stw_tls_data *
|
||||||
stw_tls_get_data(void)
|
stw_tls_get_data(void)
|
||||||
{
|
{
|
||||||
|
struct stw_tls_data *data;
|
||||||
|
|
||||||
if (tlsIndex == TLS_OUT_OF_INDEXES) {
|
if (tlsIndex == TLS_OUT_OF_INDEXES) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (struct stw_tls_data *) TlsGetValue(tlsIndex);
|
data = (struct stw_tls_data *) TlsGetValue(tlsIndex);
|
||||||
|
if(!data) {
|
||||||
|
/* DllMain is called with DLL_THREAD_ATTACH only by threads created after
|
||||||
|
* the DLL is loaded by the process */
|
||||||
|
|
||||||
|
data = stw_tls_data_create();
|
||||||
|
if(!data)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
TlsSetValue(tlsIndex, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue