Warning, /include/GaudiKernel/DllMain.icpp is written in an unsupported language. File is not indexed.
0001 /***********************************************************************************\
0002 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
0003 * *
0004 * This software is distributed under the terms of the Apache version 2 licence, *
0005 * copied verbatim in the file "LICENSE". *
0006 * *
0007 * In applying this licence, CERN does not waive the privileges and immunities *
0008 * granted to it by virtue of its status as an Intergovernmental Organization *
0009 * or submit itself to any jurisdiction. *
0010 \***********************************************************************************/
0011 //====================================================================
0012 // DllMain.cpp
0013 //--------------------------------------------------------------------
0014 //
0015 // Package : Gaudi/System
0016 //
0017 // Description: The DLL initialisation must be done seperately for
0018 // each DLL.
0019 //
0020 // Author : M.Frank
0021 // Created : 13/1/99
0022 // Changes :
0023 //
0024 //====================================================================
0025 #ifndef SYSTEM_DLLMAIN_ICPP
0026 #define SYSTEM_DLLMAIN_ICPP 1
0027
0028 #include "GaudiKernel/Kernel.h"
0029 #include "GaudiKernel/System.h"
0030
0031 #if !defined( __APPLE__ )
0032 class GaudiDll {
0033 GaudiDll() {}
0034
0035 public:
0036 static void initialize( void* hinstDLL );
0037 static void finalize( void* hinstDLL );
0038 };
0039 #endif
0040
0041 #if defined( _WIN32 ) && defined( _DLL )
0042 namespace win {
0043 // Avoid conflicts between Windows' headers and MSG.
0044 # ifndef NOMSG
0045 # define NOMSG
0046 # ifndef NOGDI
0047 # define NOGDI
0048 # endif
0049 # endif
0050 # include <windows.h>
0051 } // namespace win
0052
0053 win::BOOL APIENTRY DllMain( win::HINSTANCE hinstDLL, // handle to DLL module
0054 win::DWORD fdwReason, // reason for calling function
0055 win::LPVOID lpvReserved // reserved
0056 ) {
0057 System::setModuleHandle( hinstDLL );
0058 switch ( fdwReason ) {
0059 case DLL_PROCESS_ATTACH: {
0060 GaudiDll::initialize( hinstDLL );
0061 } break;
0062 case DLL_THREAD_ATTACH:
0063 break;
0064 case DLL_THREAD_DETACH:
0065 break;
0066 case DLL_PROCESS_DETACH: {
0067 GaudiDll::finalize( hinstDLL );
0068 // Since the System class is shared now, we may no longer close the
0069 // Process handle! M.F.
0070 // win::CloseHandle(System::processHandle());
0071 } break;
0072 }
0073 return TRUE;
0074 }
0075 #elif __linux
0076 static void _init() __attribute__( ( constructor ) );
0077 static void _fini() __attribute__( ( destructor ) );
0078
0079 static void _init() { GaudiDll::initialize( 0 ); }
0080 static void _fini() { GaudiDll::finalize( 0 ); }
0081 #elif defined( __APPLE__ )
0082 static void _init() __attribute__( ( constructor ) );
0083 static void _fini() __attribute__( ( destructor ) );
0084
0085 static void _init() {
0086 // FIXME GaudiDll::initialize(0);
0087 }
0088 static void _fini() {
0089 // FIXME GaudiDll::finalize(0);
0090 }
0091
0092 #endif // WIN32
0093
0094 #endif // SYSTEM_DLLMAIN_ICPP