summaryrefslogtreecommitdiffstats
path: root/winsup/mingw/tlssup.c
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/mingw/tlssup.c')
-rw-r--r--winsup/mingw/tlssup.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/winsup/mingw/tlssup.c b/winsup/mingw/tlssup.c
index e1685f5fc..4a152b45b 100644
--- a/winsup/mingw/tlssup.c
+++ b/winsup/mingw/tlssup.c
@@ -84,6 +84,7 @@ 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)
@@ -96,8 +97,12 @@ __dyn_tls_init (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
return TRUE;
}
- for (pfunc = &__xd_a + 1; pfunc != &__xd_z; ++pfunc)
+ /* Use the nfuncs variable to iterate the TLS functions instead of pfunc to
+ avoid nasty compiler optimizations when comparing two global pointers. */
+ nfuncs = &__xd_z - (&__xd_a + 1);
+ for (ifunc=0; ifunc < nfuncs; ++ifunc)
{
+ pfunc = (&__xd_a + 1) + ifunc;
if (*pfunc != NULL)
(*pfunc)();
}