Keep TlsDestructors within threads.c
This basically makes the threads implementation self-contained in threads.c and threads.h, except for the UIntMap/RWLock implementations.
This commit is contained in:
parent
e5d39a5f4c
commit
fbb4cbbe01
@ -786,8 +786,6 @@ static void alc_init(void);
|
||||
static void alc_deinit(void);
|
||||
static void alc_deinit_safe(void);
|
||||
|
||||
extern UIntMap TlsDestructors;
|
||||
|
||||
#ifndef AL_LIBTYPE_STATIC
|
||||
BOOL APIENTRY DllMain(HINSTANCE hModule, DWORD reason, LPVOID lpReserved)
|
||||
{
|
||||
@ -797,7 +795,6 @@ BOOL APIENTRY DllMain(HINSTANCE hModule, DWORD reason, LPVOID lpReserved)
|
||||
/* Pin the DLL so we won't get unloaded until the process terminates */
|
||||
GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_PIN | GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
|
||||
(WCHAR*)hModule, &hModule);
|
||||
InitUIntMap(&TlsDestructors, ~0);
|
||||
alc_init();
|
||||
break;
|
||||
|
||||
@ -809,7 +806,6 @@ BOOL APIENTRY DllMain(HINSTANCE hModule, DWORD reason, LPVOID lpReserved)
|
||||
alc_deinit();
|
||||
else
|
||||
alc_deinit_safe();
|
||||
ResetUIntMap(&TlsDestructors);
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
|
@ -11,6 +11,7 @@ typedef struct {
|
||||
volatile ALenum read_entry_lock;
|
||||
volatile ALenum write_lock;
|
||||
} RWLock;
|
||||
#define RWLOCK_STATIC_INITIALIZE { 0, 0, AL_FALSE, AL_FALSE, AL_FALSE }
|
||||
|
||||
void RWLockInit(RWLock *lock);
|
||||
void ReadLock(RWLock *lock);
|
||||
|
@ -205,12 +205,17 @@ int almtx_timedlock(almtx_t *mtx, const struct timespec *ts)
|
||||
* function pointer in a ".CRT$XLx" section (where x is a character A to Z)
|
||||
* ensures the CRT will call it similar to DllMain.
|
||||
*/
|
||||
UIntMap TlsDestructors;
|
||||
static UIntMap TlsDestructors = UINTMAP_STATIC_INITIALIZE;
|
||||
|
||||
static void NTAPI altss_callback(void* UNUSED(handle), DWORD reason, void* UNUSED(reserved))
|
||||
{
|
||||
ALsizei i;
|
||||
|
||||
if(reason == DLL_PROCESS_DETACH)
|
||||
{
|
||||
ResetUIntMap(&TlsDestructors);
|
||||
return;
|
||||
}
|
||||
if(reason != DLL_THREAD_DETACH)
|
||||
return;
|
||||
|
||||
|
@ -14,6 +14,8 @@ typedef struct UIntMap {
|
||||
ALsizei limit;
|
||||
RWLock lock;
|
||||
} UIntMap;
|
||||
#define UINTMAP_STATIC_INITIALIZE_N(_n) { NULL, 0, 0, (_n), RWLOCK_STATIC_INITIALIZE }
|
||||
#define UINTMAP_STATIC_INITIALIZE UINTMAP_STATIC_INITIALIZE_N(~0)
|
||||
|
||||
void InitUIntMap(UIntMap *map, ALsizei limit);
|
||||
void ResetUIntMap(UIntMap *map);
|
||||
|
Loading…
x
Reference in New Issue
Block a user