]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 | ||
11fdf7f2 | 6 | #include <boost/winapi/config.hpp> |
7c673cae FG |
7 | #include <boost/thread/detail/config.hpp> |
8 | ||
9 | ||
92f5a8d4 | 10 | #if defined(BOOST_THREAD_WIN32) && defined(BOOST_THREAD_BUILD_DLL) |
7c673cae FG |
11 | |
12 | #include <boost/thread/detail/tss_hooks.hpp> | |
13 | ||
14 | #include <windows.h> | |
15 | ||
20effc67 | 16 | #if defined(BOOST_BORLANDC) |
7c673cae | 17 | extern "C" BOOL WINAPI DllEntryPoint(HINSTANCE /*hInstance*/, DWORD dwReason, LPVOID /*lpReserved*/) |
20effc67 TL |
18 | #elif defined(BOOST_EMBTC) |
19 | extern "C" int _libmain(DWORD dwReason) | |
7c673cae FG |
20 | #elif defined(_WIN32_WCE) |
21 | extern "C" BOOL WINAPI DllMain(HANDLE /*hInstance*/, DWORD dwReason, LPVOID /*lpReserved*/) | |
22 | #else | |
23 | extern "C" BOOL WINAPI DllMain(HINSTANCE /*hInstance*/, DWORD dwReason, LPVOID /*lpReserved*/) | |
24 | #endif | |
25 | { | |
26 | switch(dwReason) | |
27 | { | |
28 | case DLL_PROCESS_ATTACH: | |
29 | { | |
30 | boost::on_process_enter(); | |
31 | boost::on_thread_enter(); | |
32 | break; | |
33 | } | |
34 | ||
35 | case DLL_THREAD_ATTACH: | |
36 | { | |
37 | boost::on_thread_enter(); | |
38 | break; | |
39 | } | |
40 | ||
41 | case DLL_THREAD_DETACH: | |
42 | { | |
43 | boost::on_thread_exit(); | |
44 | break; | |
45 | } | |
46 | ||
47 | case DLL_PROCESS_DETACH: | |
48 | { | |
49 | boost::on_thread_exit(); | |
50 | boost::on_process_exit(); | |
51 | break; | |
52 | } | |
53 | } | |
54 | ||
55 | return TRUE; | |
56 | } | |
57 | ||
58 | namespace boost | |
59 | { | |
60 | void tss_cleanup_implemented() | |
61 | { | |
62 | /* | |
63 | This function's sole purpose is to cause a link error in cases where | |
64 | automatic tss cleanup is not implemented by Boost.Threads as a | |
65 | reminder that user code is responsible for calling the necessary | |
66 | functions at the appropriate times (and for implementing an a | |
67 | tss_cleanup_implemented() function to eliminate the linker's | |
68 | missing symbol error). | |
69 | ||
70 | If Boost.Threads later implements automatic tss cleanup in cases | |
71 | where it currently doesn't (which is the plan), the duplicate | |
72 | symbol error will warn the user that their custom solution is no | |
73 | longer needed and can be removed. | |
74 | */ | |
75 | } | |
76 | } | |
77 | ||
92f5a8d4 | 78 | #else //defined(BOOST_THREAD_WIN32) && defined(BOOST_THREAD_BUILD_DLL) |
7c673cae FG |
79 | |
80 | #ifdef _MSC_VER | |
81 | // Prevent LNK4221 warning with link=static | |
82 | namespace boost { namespace link_static_warning_inhibit { | |
83 | extern __declspec(dllexport) void foo() { } | |
84 | } } | |
85 | #endif | |
86 | ||
92f5a8d4 | 87 | #endif //defined(BOOST_THREAD_WIN32) && defined(BOOST_THREAD_BUILD_DLL) |