|
Boost-Commit : |
From: anthony_at_[hidden]
Date: 2008-09-02 12:56:57
Author: anthonyw
Date: 2008-09-02 12:56:57 EDT (Tue, 02 Sep 2008)
New Revision: 48537
URL: http://svn.boost.org/trac/boost/changeset/48537
Log:
Define a raw DLL main which is called by the C runtime if we're statically linked into a DLL --- fix for issue #2199
Text files modified:
trunk/libs/thread/src/win32/tss_pe.cpp | 46 +++++++++++++++++++++++++++------------
1 files changed, 32 insertions(+), 14 deletions(-)
Modified: trunk/libs/thread/src/win32/tss_pe.cpp
==============================================================================
--- trunk/libs/thread/src/win32/tss_pe.cpp (original)
+++ trunk/libs/thread/src/win32/tss_pe.cpp 2008-09-02 12:56:57 EDT (Tue, 02 Sep 2008)
@@ -26,11 +26,11 @@
{
switch (dwReason)
{
- case DLL_THREAD_DETACH:
- {
- on_thread_exit();
- break;
- }
+ case DLL_THREAD_DETACH:
+ {
+ on_thread_exit();
+ break;
+ }
}
}
@@ -125,10 +125,10 @@
#pragma section(".CRT$XCU",long,read)
#pragma section(".CRT$XTU",long,read)
#pragma section(".CRT$XLC",long,read)
- static __declspec(allocate(".CRT$XLC")) _TLSCB __xl_ca=on_tls_callback;
- static __declspec(allocate(".CRT$XIU"))_PVFV p_tls_prepare = on_tls_prepare;
- static __declspec(allocate(".CRT$XCU"))_PVFV p_process_init = on_process_init;
- static __declspec(allocate(".CRT$XTU"))_PVFV p_process_term = on_process_term;
+ __declspec(allocate(".CRT$XLC")) _TLSCB __xl_ca=on_tls_callback;
+ __declspec(allocate(".CRT$XIU"))_PVFV p_tls_prepare = on_tls_prepare;
+ __declspec(allocate(".CRT$XCU"))_PVFV p_process_init = on_process_init;
+ __declspec(allocate(".CRT$XTU"))_PVFV p_process_term = on_process_term;
#else
#if (_MSC_VER >= 1300) // 1300 == VC++ 7.0
# pragma data_seg(push, old_seg)
@@ -168,6 +168,7 @@
#pragma warning(push)
#pragma warning(disable:4189)
#endif
+
PVAPI on_tls_prepare(void)
{
//The following line has an important side effect:
@@ -239,15 +240,32 @@
{
switch (dwReason)
{
- case DLL_THREAD_DETACH:
- {
- on_thread_exit();
- break;
- }
+ case DLL_THREAD_DETACH:
+ on_thread_exit();
+ break;
}
}
+
+ BOOL WINAPI dll_callback(HANDLE, DWORD dwReason, LPVOID)
+ {
+ switch (dwReason)
+ {
+ case DLL_THREAD_DETACH:
+ on_thread_exit();
+ break;
+ case DLL_PROCESS_DETACH:
+ on_process_exit();
+ break;
+ }
+ return true;
+ }
} //namespace
+extern "C"
+{
+ extern BOOL (WINAPI * const _pRawDllMain)(HANDLE, DWORD, LPVOID)=&dll_callback;
+}
+
extern "C" void tss_cleanup_implemented(void)
{
/*
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk