diff --git a/src/pe_tls.ipp b/src/pe_tls.ipp new file mode 100644 index 00000000..c5a18e86 --- /dev/null +++ b/src/pe_tls.ipp @@ -0,0 +1,45 @@ +// (C) Copyright Aaron W. LaFramboise 2004. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +extern "C" void tss_cleanup_implemented(void) +{ + //Don't need to do anything; this function's + //sole purpose is to cause a link error in cases + //where tss cleanup is not implemented by Boost.Threads + //as a reminder that user code is responsible for calling + //on_process_enter(), on_thread_exit(), and + //on_process_exit() at the appropriate times + //and implementing an empty tss_cleanup_implemented() + //function to eliminate the link error. +} + +//Force a TLS directory to be generated even when static TLS is not used. + +extern "C" int _tls_used; + +int dummy() +{ + return _tls_used; +} + +//Report thread and process detach events. + +void NTAPI tls_callback (PVOID, DWORD Reason, PVOID) +{ + if(Reason == DLL_THREAD_DETACH) + on_thread_exit(); + else if(Reason == DLL_PROCESS_DETACH) + { + on_thread_exit(); + on_process_exit(); + } +} + +// Add callback to the TLS callback list in TLS directory. + +#pragma data_seg(push, old_seg) +#pragma data_seg(".CRT$XLB") +DWORD tls_callback_ptr = (DWORD)tls_callback; +#pragma data_seg(pop, old_seg) \ No newline at end of file diff --git a/src/threadmon.cpp b/src/threadmon.cpp index 1d88b503..9c529d8d 100644 --- a/src/threadmon.cpp +++ b/src/threadmon.cpp @@ -176,6 +176,13 @@ } return TRUE; } + #elif defined(BOOST_THREAD_BUILD_LIB) + #if defined(BOOST_MSVC) && (BOOST_MSVC >= 1310) //1310 == VC++ 7.1 + //As currently defined, the following is known + //to work only for VC++ 7.1. + //It is known not to work with VC 6. + #include + #endif #endif // BOOST_THREAD_BUILD_DLL #endif // BOOST_HAS_WINTHREADS