Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
DllMain.icpp
Go to the documentation of this file.
1 //====================================================================
2 // DllMain.cpp
3 //--------------------------------------------------------------------
4 //
5 // Package : Gaudi/System
6 //
7 // Description: The DLL initialisation must be done seperately for
8 // each DLL.
9 //
10 // Author : M.Frank
11 // Created : 13/1/99
12 // Changes :
13 //
14 //====================================================================
15 #ifndef SYSTEM_DLLMAIN_ICPP
16 #define SYSTEM_DLLMAIN_ICPP 1
17 
18 #include "GaudiKernel/Kernel.h"
19 #include "GaudiKernel/System.h"
20 
21 #if !defined( __APPLE__ )
22 class GaudiDll {
23  GaudiDll() {}
24 
25 public:
26  static void initialize( void* hinstDLL );
27  static void finalize( void* hinstDLL );
28 };
29 #endif
30 
31 #if defined( _WIN32 ) && defined( _DLL )
32 namespace win {
33 // Avoid conflicts between Windows' headers and MSG.
34 # ifndef NOMSG
35 # define NOMSG
36 # ifndef NOGDI
37 # define NOGDI
38 # endif
39 # endif
40 # include <windows.h>
41 } // namespace win
42 
43 win::BOOL APIENTRY DllMain( win::HINSTANCE hinstDLL, // handle to DLL module
44  win::DWORD fdwReason, // reason for calling function
45  win::LPVOID lpvReserved // reserved
46 ) {
47  System::setModuleHandle( hinstDLL );
48  switch ( fdwReason ) {
49  case DLL_PROCESS_ATTACH: {
50  GaudiDll::initialize( hinstDLL );
51  } break;
52  case DLL_THREAD_ATTACH:
53  break;
54  case DLL_THREAD_DETACH:
55  break;
56  case DLL_PROCESS_DETACH: {
57  GaudiDll::finalize( hinstDLL );
58  // Since the System class is shared now, we may no longer close the
59  // Process handle! M.F.
60  // win::CloseHandle(System::processHandle());
61  } break;
62  }
63  return TRUE;
64 }
65 #elif __linux
66 static void _init() __attribute__( ( constructor ) );
67 static void _fini() __attribute__( ( destructor ) );
68 
69 static void _init() { GaudiDll::initialize( 0 ); }
70 static void _fini() { GaudiDll::finalize( 0 ); }
71 #elif defined( __APPLE__ )
72 static void _init() __attribute__( ( constructor ) );
73 static void _fini() __attribute__( ( destructor ) );
74 
75 static void _init() {
76  // FIXME GaudiDll::initialize(0);
77 }
78 static void _fini() {
79  // FIXME GaudiDll::finalize(0);
80 }
81 
82 #endif // WIN32
83 
84 #endif // SYSTEM_DLLMAIN_ICPP
#define __attribute__(x)
Definition: System.cpp:89
static void initialize(void *hinstDLL)
GAUDI_API void setModuleHandle(ImageHandle handle)
Attach module handle.
Definition: ModuleInfo.cpp:135
static void finalize(void *hinstDLL)
GaudiDll()
Definition: DllMain.icpp:23