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 // this header is only used by the deprecated GaudiKernel/LoadFactoryEntries.h
0029 // but we want to make sure nobody else is using it
0030 #if !defined( GAUDIKERNEL_LOADFACTORYENTRIES_H )
0031 # warning "deprecated header file, not to be used"
0032 #endif
0033
0034 #include "GaudiKernel/Kernel.h"
0035 #include "GaudiKernel/System.h"
0036
0037 #if !defined( __APPLE__ )
0038 class GaudiDll {
0039 GaudiDll() {}
0040
0041 public:
0042 static void initialize( void* hinstDLL );
0043 static void finalize( void* hinstDLL );
0044 };
0045 #endif
0046
0047 #if defined( _WIN32 ) && defined( _DLL )
0048 namespace win {
0049 // Avoid conflicts between Windows' headers and MSG.
0050 # ifndef NOMSG
0051 # define NOMSG
0052 # ifndef NOGDI
0053 # define NOGDI
0054 # endif
0055 # endif
0056 # include <windows.h>
0057 } // namespace win
0058
0059 win::BOOL APIENTRY DllMain( win::HINSTANCE hinstDLL, // handle to DLL module
0060 win::DWORD fdwReason, // reason for calling function
0061 win::LPVOID lpvReserved // reserved
0062 ) {
0063 System::setModuleHandle( hinstDLL );
0064 switch ( fdwReason ) {
0065 case DLL_PROCESS_ATTACH: {
0066 GaudiDll::initialize( hinstDLL );
0067 } break;
0068 case DLL_THREAD_ATTACH:
0069 break;
0070 case DLL_THREAD_DETACH:
0071 break;
0072 case DLL_PROCESS_DETACH: {
0073 GaudiDll::finalize( hinstDLL );
0074 // Since the System class is shared now, we may no longer close the
0075 // Process handle! M.F.
0076 // win::CloseHandle(System::processHandle());
0077 } break;
0078 }
0079 return TRUE;
0080 }
0081 #elif __linux
0082 static void _init() __attribute__( ( constructor ) );
0083 static void _fini() __attribute__( ( destructor ) );
0084
0085 static void _init() { GaudiDll::initialize( 0 ); }
0086 static void _fini() { GaudiDll::finalize( 0 ); }
0087 #elif defined( __APPLE__ )
0088 static void _init() __attribute__( ( constructor ) );
0089 static void _fini() __attribute__( ( destructor ) );
0090
0091 static void _init() {
0092 // FIXME GaudiDll::initialize(0);
0093 }
0094 static void _fini() {
0095 // FIXME GaudiDll::finalize(0);
0096 }
0097
0098 #endif // WIN32
0099
0100 #endif // SYSTEM_DLLMAIN_ICPP