From a1690e62abbbc14dbd6768fdd2ecca4ef4c9698f Mon Sep 17 00:00:00 2001 From: Chris Sutcliffe Date: Wed, 30 Nov 2011 23:49:46 +0000 Subject: [PATCH] 2011-11-30 Rodrigo Rivas Costa * tlssup.c (__dyn_tls_init): Reapply patch from 3105314. Thank you to Earnie for creating the patch file. --- winsup/mingw/ChangeLog | 6 ++++++ winsup/mingw/tlssup.c | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/winsup/mingw/ChangeLog b/winsup/mingw/ChangeLog index 4d7e6ced7..e0cdd738f 100644 --- a/winsup/mingw/ChangeLog +++ b/winsup/mingw/ChangeLog @@ -1,3 +1,9 @@ +2011-11-30 Rodrigo Rivas Costa + + * tlssup.c (__dyn_tls_init): Reapply patch from 3105314. + + Thank you to Earnie for creating the patch file. + 2011-11-26 Keith Marshall Clean up DIRENT errno handling; make it more POSIX conformant. 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)(); } -- 2.43.5