annotate OrthancFramework/SharedLibrary/DllMain.cpp @ 4118:a0c30785b7d7

simplifying OrthancFramework/SharedLibrary/CMakeLists.txt
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 07 Jul 2020 14:53:00 +0200
parents 50cb0fb99e34
children bf7b9edf6b81
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4106
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
1 /**
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
4 * Department, University Hospital of Liege, Belgium
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
6 *
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
7 * This program is free software: you can redistribute it and/or
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
8 * modify it under the terms of the GNU General Public License as
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
9 * published by the Free Software Foundation, either version 3 of the
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
10 * License, or (at your option) any later version.
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
11 *
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
12 * In addition, as a special exception, the copyright holders of this
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
13 * program give permission to link the code of its release with the
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
15 * that use the same license as the "OpenSSL" library), and distribute
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
16 * the linked executables. You must obey the GNU General Public License
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
17 * in all respects for all of the code used other than "OpenSSL". If you
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
18 * modify file(s) with this exception, you may extend this exception to
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
19 * your version of the file(s), but you are not obligated to do so. If
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
20 * you do not wish to do so, delete this exception statement from your
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
21 * version. If you delete this exception statement from all source files
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
22 * in the program, then also delete it here.
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
23 *
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
24 * This program is distributed in the hope that it will be useful, but
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
27 * General Public License for more details.
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
28 *
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
29 * You should have received a copy of the GNU General Public License
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
31 **/
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
32
50cb0fb99e34 added license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4063
diff changeset
33
4063
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 /**
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 This file merges 2 files:
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 ${BOOST_SOURCES_DIR}/libs/thread/src/win32/tss_dll.cpp
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 ${OPENSSL_SOURCES_DIR}/crypto/dllmain.c
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 **/
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 #if defined(_WIN32) || defined(__CYGWIN__)
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 # ifdef __CYGWIN__
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 # include <windows.h>
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 # endif
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 #include "e_os.h"
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 #include "crypto/cryptlib.h"
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 {
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 switch (fdwReason)
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 {
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 case DLL_PROCESS_ATTACH:
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 //OPENSSL_cpuid_setup(); // TODO - Is this necessary?
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 break;
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 case DLL_THREAD_ATTACH:
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 break;
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 case DLL_THREAD_DETACH:
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 OPENSSL_thread_stop();
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 break;
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 case DLL_PROCESS_DETACH:
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 break;
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 }
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 return TRUE;
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 }
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 #endif
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 namespace boost
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 {
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 void tss_cleanup_implemented()
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 {
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 /*
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 This function's sole purpose is to cause a link error in cases where
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 automatic tss cleanup is not implemented by Boost.Threads as a
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 reminder that user code is responsible for calling the necessary
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 functions at the appropriate times (and for implementing an a
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 tss_cleanup_implemented() function to eliminate the linker's
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 missing symbol error).
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 If Boost.Threads later implements automatic tss cleanup in cases
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 where it currently doesn't (which is the plan), the duplicate
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 symbol error will warn the user that their custom solution is no
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 longer needed and can be removed.
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 */
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 }
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 }
e00f3d089991 shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94