4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-01-18 12:29:32 +08:00

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> 2011-08-20 Chris Sutcliffe <ir0nh34d@users.sourceforge.net>
* include/_mingw.h: Increment version to 3.19. * 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_remove_key_dtor (DWORD key);
extern int ___w64_mingwthr_add_key_dtor (DWORD key, void (*dtor)(void *)); 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 int
__mingwthr_remove_key_dtor (DWORD key) __mingwthr_remove_key_dtor (DWORD key)
{ {
#ifndef _WIN64 return ___w64_mingwthr_remove_key_dtor (key);
if (!__mingw_usemthread_dll)
#endif
return ___w64_mingwthr_remove_key_dtor (key);
#ifndef _WIN64
if (__mingw_gMTRemoveKeyDtor)
return (*__mingw_gMTRemoveKeyDtor) (key);
return 0;
#endif
} }
int int
__mingwthr_key_dtor (DWORD key, void (*dtor)(void *)) __mingwthr_key_dtor (DWORD key, void (*dtor)(void *))
{ {
if (dtor) if (dtor)
{ return ___w64_mingwthr_add_key_dtor (key, 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 0; return 0;
} }

View File

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