2011-08-23 Chris Sutcliffe <ir0nh34d@users.sourceforge.net>

* tlsmthread.c: Update to reflect changes in tlssup.c.
        * tlssup.c: code clean-up.
This commit is contained in:
Chris Sutcliffe 2011-08-23 22:27:35 +00:00
parent 58ef30a4e7
commit 99724a3258
3 changed files with 16 additions and 41 deletions

View File

@ -1,3 +1,8 @@
2011-08-23 Chris Sutcliffe <ir0nh34d@users.sourceforge.net>
* tlsmthread.c: Update to reflect changes in tlssup.c.
* tlssup.c: code clean-up.
2011-08-20 Chris Sutcliffe <ir0nh34d@users.sourceforge.net>
* include/_mingw.h: Increment version to 3.19.

View File

@ -17,43 +17,16 @@ int __mingwthr_remove_key_dtor (DWORD key);
extern int ___w64_mingwthr_remove_key_dtor (DWORD key);
extern int ___w64_mingwthr_add_key_dtor (DWORD key, void (*dtor)(void *));
#ifndef _WIN64
#define MINGWM10_DLL "mingwm10.dll"
typedef int (*fMTRemoveKeyDtor)(DWORD key);
typedef int (*fMTKeyDtor)(DWORD key, void (*dtor)(void *));
extern fMTRemoveKeyDtor __mingw_gMTRemoveKeyDtor;
extern fMTKeyDtor __mingw_gMTKeyDtor;
extern int __mingw_usemthread_dll;
#endif
int
__mingwthr_remove_key_dtor (DWORD key)
{
#ifndef _WIN64
if (!__mingw_usemthread_dll)
#endif
return ___w64_mingwthr_remove_key_dtor (key);
#ifndef _WIN64
if (__mingw_gMTRemoveKeyDtor)
return (*__mingw_gMTRemoveKeyDtor) (key);
return 0;
#endif
return ___w64_mingwthr_remove_key_dtor (key);
}
int
__mingwthr_key_dtor (DWORD key, void (*dtor)(void *))
{
if (dtor)
{
#ifndef _WIN64
if (!__mingw_usemthread_dll)
#endif
return ___w64_mingwthr_add_key_dtor (key, dtor);
#ifndef _WIN64
if (__mingw_gMTKeyDtor)
return (*__mingw_gMTKeyDtor) (key, dtor);
#endif
}
return ___w64_mingwthr_add_key_dtor (key, dtor);
return 0;
}

View File

@ -60,9 +60,9 @@ _CRTALLOC(".tls") const IMAGE_TLS_DIRECTORY _tls_used = {
#ifndef __CRT_THREAD
#ifdef HAVE_ATTRIBUTE_THREAD
#define __CRT_THREAD __declspec(thread)
#define __CRT_THREAD __declspec(thread)
#else
#define __CRT_THREAD __thread
#define __CRT_THREAD __thread
#endif
#endif
@ -84,7 +84,6 @@ BOOL WINAPI
__dyn_tls_init (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
{
_PVFV *pfunc;
int nfuncs, ifunc;
/* We don't let us trick here. */
if (_CRT_MT != 2)
@ -97,10 +96,8 @@ __dyn_tls_init (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
return TRUE;
}
nfuncs = &__xd_z - (&__xd_a + 1);
for (ifunc = 0; ifunc < nfuncs; ++ifunc)
for (pfunc = &__xd_a + 1; pfunc != &__xd_z; ++pfunc)
{
pfunc = (&__xd_a + 1) + ifunc;
if (*pfunc != NULL)
(*pfunc)();
}
@ -127,7 +124,7 @@ __tlregdtor (_PVFV func)
{
TlsDtorNode *pnode = (TlsDtorNode *) malloc (sizeof (TlsDtorNode));
if (pnode == NULL)
return -1;
return -1;
pnode->count = 0;
pnode->next = dtor_list;
dtor_list = pnode;
@ -160,13 +157,13 @@ __dyn_tls_dtor (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
for (pnode = dtor_list; pnode != NULL; pnode = pnext)
{
for (i = pnode->count - 1; i >= 0; --i)
{
if (pnode->funcs[i] != NULL)
(*pnode->funcs[i])();
}
{
if (pnode->funcs[i] != NULL)
(*pnode->funcs[i])();
}
pnext = pnode->next;
if (pnext != NULL)
free ((void *) pnode);
free ((void *) pnode);
}
}
#endif