1 | // (C) Copyright Michael Glassford 2004. |
---|
2 | // Use, modification and distribution are subject to the |
---|
3 | // Boost Software License, Version 1.0. (See accompanying file |
---|
4 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
---|
5 | |
---|
6 | #include <boost/thread/detail/config.hpp> |
---|
7 | |
---|
8 | #if defined(BOOST_HAS_WINTHREADS) && defined(BOOST_THREAD_BUILD_DLL) |
---|
9 | |
---|
10 | #include <boost/thread/detail/tss_hooks.hpp> |
---|
11 | |
---|
12 | #define WIN32_LEAN_AND_MEAN |
---|
13 | #include <windows.h> |
---|
14 | |
---|
15 | #if defined(__BORLANDC__) |
---|
16 | extern "C" BOOL WINAPI DllEntryPoint(HINSTANCE /*hInstance*/, DWORD dwReason, LPVOID /*lpReserved*/) |
---|
17 | #elif defined(_WIN32_WCE) |
---|
18 | extern "C" BOOL WINAPI DllMain(HANDLE /*hInstance*/, DWORD dwReason, LPVOID /*lpReserved*/) |
---|
19 | #else |
---|
20 | extern "C" BOOL WINAPI DllMain(HINSTANCE /*hInstance*/, DWORD dwReason, LPVOID /*lpReserved*/) |
---|
21 | #endif |
---|
22 | { |
---|
23 | switch(dwReason) |
---|
24 | { |
---|
25 | case DLL_PROCESS_ATTACH: |
---|
26 | { |
---|
27 | on_process_enter(); |
---|
28 | on_thread_enter(); |
---|
29 | break; |
---|
30 | } |
---|
31 | |
---|
32 | case DLL_THREAD_ATTACH: |
---|
33 | { |
---|
34 | on_thread_enter(); |
---|
35 | break; |
---|
36 | } |
---|
37 | |
---|
38 | case DLL_THREAD_DETACH: |
---|
39 | { |
---|
40 | on_thread_exit(); |
---|
41 | break; |
---|
42 | } |
---|
43 | |
---|
44 | case DLL_PROCESS_DETACH: |
---|
45 | { |
---|
46 | on_thread_exit(); |
---|
47 | on_process_exit(); |
---|
48 | break; |
---|
49 | } |
---|
50 | } |
---|
51 | |
---|
52 | return TRUE; |
---|
53 | } |
---|
54 | |
---|
55 | extern "C" void tss_cleanup_implemented(void) |
---|
56 | { |
---|
57 | /* |
---|
58 | This function's sole purpose is to cause a link error in cases where |
---|
59 | automatic tss cleanup is not implemented by Boost.Threads as a |
---|
60 | reminder that user code is responsible for calling the necessary |
---|
61 | functions at the appropriate times (and for implementing an a |
---|
62 | tss_cleanup_implemented() function to eliminate the linker's |
---|
63 | missing symbol error). |
---|
64 | |
---|
65 | If Boost.Threads later implements automatic tss cleanup in cases |
---|
66 | where it currently doesn't (which is the plan), the duplicate |
---|
67 | symbol error will warn the user that their custom solution is no |
---|
68 | longer needed and can be removed. |
---|
69 | */ |
---|
70 | } |
---|
71 | |
---|
72 | #endif //defined(BOOST_HAS_WINTHREADS) && defined(BOOST_THREAD_BUILD_DLL) |
---|