From 7fd5ebb18c1d83e06f37f515f8f65345f064eef1 Mon Sep 17 00:00:00 2001 From: env Date: Wed, 13 Jul 2005 07:10:09 +0000 Subject: [PATCH] ENV: Windows porting. --- .../SALOME_DataTypeCatalog_impl.cxx | 4 ++ src/GenericObj/SALOME_GenericObj_i.cc | 4 ++ src/Logger/SALOME_Logger_Server.cxx | 16 ++++++- src/Logger/SALOME_Trace.cxx | 12 ++++++ .../SALOME_ModuleCatalog_Acomponent_impl.cxx | 16 ++++++- .../SALOME_ModuleCatalog_impl.cxx | 34 +++++++++++++-- .../NamingService_WaitForServerReadiness.cxx | 8 ++++ src/NamingService/SALOME_NamingService.cxx | 4 ++ src/NamingService/SALOME_NamingService.hxx | 16 ++++++- src/Notification/NOTIFICATION.hxx | 19 ++++++++- src/Notification/NOTIFICATION_Consumer.hxx | 16 ++++++- src/Notification/NOTIFICATION_Supplier.hxx | 16 ++++++- src/Registry/RegistryConnexion.cxx | 6 ++- src/Registry/RegistryConnexion.hxx | 16 ++++++- src/Registry/RegistryService.cxx | 6 +++ .../SALOME_LoadRateManager.hxx | 17 +++++++- .../SALOME_ResourcesManager.cxx | 33 ++++++++++++++- .../SALOME_ResourcesManager.hxx | 18 +++++++- .../SALOME_RessourcesCatalog_impl.cxx | 4 ++ src/SALOMELocalTrace/LocalTraceBufferPool.hxx | 20 ++++++++- src/SALOMELocalTrace/LocalTraceCollector.cxx | 41 ++++++++++++++---- src/SALOMELocalTrace/LocalTraceCollector.hxx | 4 +- src/SALOMELocalTrace/utilities.h | 7 ++++ .../SALOMETraceCollector.cxx | 42 +++++++++++++++++-- .../SALOMETraceCollector.hxx | 2 +- .../TraceCollector_WaitForServerReadiness.cxx | 8 ++++ src/Utils/OpUtil.hxx | 18 +++++++- src/Utils/Utils_CommException.hxx | 2 +- src/Utils/Utils_DESTRUCTEUR_GENERIQUE.cxx | 26 ++++++------ src/Utils/Utils_Identity.cxx | 2 +- src/Utils/Utils_Identity.hxx | 15 ++++++- src/Utils/Utils_Mutex.cxx | 12 +++++- src/Utils/Utils_Mutex.hxx | 18 +++++++- src/Utils/Utils_ORB_INIT.hxx | 16 ++++++- src/Utils/Utils_SALOME_Exception.cxx | 5 +++ src/Utils/Utils_SALOME_Exception.hxx | 15 ++++++- src/Utils/Utils_SignalsHandler.h | 18 +++++++- src/Utils/duplicate.cxx | 1 + 38 files changed, 479 insertions(+), 58 deletions(-) diff --git a/src/DataTypeCatalog/SALOME_DataTypeCatalog_impl.cxx b/src/DataTypeCatalog/SALOME_DataTypeCatalog_impl.cxx index cb5337e67..13f3584f2 100644 --- a/src/DataTypeCatalog/SALOME_DataTypeCatalog_impl.cxx +++ b/src/DataTypeCatalog/SALOME_DataTypeCatalog_impl.cxx @@ -310,7 +310,11 @@ SALOME_DataTypeCatalogImpl::_verify_data_type(ListOfParserDataType datatypelist) // Parse if parents data type name of a data type are defined in the // datatype catalog +#ifndef WNT for (unsigned int ind = 0; ind < _datatype_list.size(); ind++) +#else + for (ind = 0; ind < _datatype_list.size(); ind++) +#endif { // Scrute data type parents // MESSAGE("Treatment of " << _datatype_list[ind].Parserdata_name); diff --git a/src/GenericObj/SALOME_GenericObj_i.cc b/src/GenericObj/SALOME_GenericObj_i.cc index e5281e72b..90b7ac39f 100644 --- a/src/GenericObj/SALOME_GenericObj_i.cc +++ b/src/GenericObj/SALOME_GenericObj_i.cc @@ -41,7 +41,11 @@ GenericObj_i::GenericObj_i(PortableServer::POA_ptr thePOA): myRefCounter(1){ MESSAGE("GenericObj_i::GenericObj_i() - this = "< using namespace std; +#ifdef WNT +#include +#endif + ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// @@ -53,7 +57,11 @@ int SALOME_Trace::Initialize(CORBA::ORB_ptr theOrb) { // searchin for naming service for 0.25*40=10 seconds for (i = 1; i <= NumberOfTries; i++) { +#ifndef WNT if (i != 1) nanosleep(&ts_req,&ts_rem); +#else + if (i != 1) Sleep(TIMESleep / 1000000); +#endif try{ if(CORBA::is_nil(obj)) obj = theOrb->resolve_initial_references("RootPOA"); @@ -84,7 +92,11 @@ int SALOME_Trace::Initialize(CORBA::ORB_ptr theOrb) { name[0].id=CORBA::string_dup("Logger"); for(i = 1; i <= NumberOfTries; i++){ +#ifndef WNT if (i != 1) nanosleep(&ts_req, &ts_rem); +#else + if (i != 1) Sleep(TIMESleep / 1000000); +#endif try { obj = inc->resolve(name); if (!CORBA::is_nil(obj)) m_pInterfaceLogger = SALOME_Logger::Logger::_narrow(obj); diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.cxx index ad1c34169..228c49538 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.cxx @@ -493,16 +493,24 @@ void SALOME_ModuleCatalog_AcomponentImpl::duplicate // duplicate out Parameters _length = S_in.ServiceoutParameter.length(); S_out.ServiceoutParameter.length(_length); - + +#ifndef WNT for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++) +#else + for (ind2 = 0; ind2 < _length ; ind2 ++) +#endif duplicate(S_out.ServiceoutParameter[ind2], S_in.ServiceoutParameter[ind2]); // duplicate in DataStreamParameters _length = S_in.ServiceinDataStreamParameter.length(); S_out.ServiceinDataStreamParameter.length(_length); - + +#ifndef WNT for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++) +#else + for (ind2 = 0; ind2 < _length ; ind2 ++) +#endif duplicate(S_out.ServiceinDataStreamParameter[ind2], S_in.ServiceinDataStreamParameter[ind2]); @@ -511,7 +519,11 @@ void SALOME_ModuleCatalog_AcomponentImpl::duplicate if(MYDEBUG) SCRUTE(_length); S_out.ServiceoutDataStreamParameter.length(_length); +#ifndef WNT for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++) +#else + for (ind2 = 0; ind2 < _length ; ind2 ++) +#endif duplicate(S_out.ServiceoutDataStreamParameter[ind2], S_in.ServiceoutDataStreamParameter[ind2]); } diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx index 845e341dc..0c63992f0 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx @@ -251,7 +251,11 @@ SALOME_ModuleCatalogImpl::GetComponentList() // The components in the general catalog are taken only if they're // not defined in the personal catalog +#ifndef WNT for(unsigned int ind=0; ind < _general_module_list.size();ind++){ +#else + for(ind=0; ind < _general_module_list.size();ind++){ +#endif _find = false; for(unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++){ // searching if the component is already defined in @@ -312,7 +316,11 @@ SALOME_ModuleCatalogImpl::GetComponentIconeList() // The components in the general catalog are taken only if they're // not defined in the personal catalog +#ifndef WNT for(unsigned int ind=0; ind < _general_module_list.size();ind++){ +#else + for(ind=0; ind < _general_module_list.size();ind++){ +#endif _find = false; for(unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++){ // searching if the component is aleready defined in @@ -403,7 +411,11 @@ SALOME_ModuleCatalogImpl::GetTypedComponentList(SALOME_ModuleCatalog::ComponentT // The components in the general catalog are taken only if they're // not defined in the personal catalog +#ifndef WNT for (unsigned int ind=0; ind < _general_module_list.size();ind++) +#else + for (ind=0; ind < _general_module_list.size();ind++) +#endif { _find = false; @@ -662,16 +674,24 @@ void SALOME_ModuleCatalogImpl::duplicate // duplicate out Parameters _length = S_parser.outParameters.size(); S_corba.ServiceoutParameter.length(_length); - + +#ifndef WNT for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++) +#else + for (ind2 = 0; ind2 < _length ; ind2 ++) +#endif duplicate(S_corba.ServiceoutParameter[ind2], S_parser.outParameters[ind2]); // duplicate in DataStreamParameters _length = S_parser.inDataStreamParameters.size(); S_corba.ServiceinDataStreamParameter.length(_length); - + +#ifndef WNT for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++) +#else + for (ind2 = 0; ind2 < _length ; ind2 ++) +#endif duplicate(S_corba.ServiceinDataStreamParameter[ind2], S_parser.inDataStreamParameters[ind2]); @@ -679,8 +699,12 @@ void SALOME_ModuleCatalogImpl::duplicate _length = S_parser.outDataStreamParameters.size(); if(MYDEBUG) SCRUTE(_length); S_corba.ServiceoutDataStreamParameter.length(_length); - + +#ifndef WNT for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++) +#else + for (ind2 = 0; ind2 < _length ; ind2 ++) +#endif duplicate(S_corba.ServiceoutDataStreamParameter[ind2], S_parser.outDataStreamParameters[ind2]); } @@ -790,7 +814,11 @@ SALOME_ModuleCatalogImpl::_verify_path_prefix(ParserPathPrefixes & pathList) } // Parse if a computer name is twice in the list of computers +#ifndef WNT for (unsigned int ind = 0; ind < _machine_list.size(); ind++) +#else + for (ind = 0; ind < _machine_list.size(); ind++) +#endif { for (unsigned int ind1 = ind+1 ; ind1 < _machine_list.size(); ind1++) { diff --git a/src/NamingService/NamingService_WaitForServerReadiness.cxx b/src/NamingService/NamingService_WaitForServerReadiness.cxx index 6108b2dc3..6b1503670 100644 --- a/src/NamingService/NamingService_WaitForServerReadiness.cxx +++ b/src/NamingService/NamingService_WaitForServerReadiness.cxx @@ -79,13 +79,21 @@ void NamingService_WaitForServerReadiness(SALOME_NamingService* NS, break; // server found, no more try to do } MESSAGE("Server "<< serverName <<" not yet ready, waiting..."); +#ifndef WNT int a = nanosleep(&ts_req,&ts_rem); // wait before retry +#else + Sleep(TIMESleep/1000000); +#endif } } catch( ServiceUnreachable& ) { MESSAGE("CORBA::COMM_FAILURE: Naming Service not yet ready, waiting..."); +#ifndef WNT int a = nanosleep(&ts_req,&ts_rem); // wait before retry +#else + Sleep(TIMESleep/1000000); +#endif } } if (!found) diff --git a/src/NamingService/SALOME_NamingService.cxx b/src/NamingService/SALOME_NamingService.cxx index f39bb93e1..0a4af7c3c 100644 --- a/src/NamingService/SALOME_NamingService.cxx +++ b/src/NamingService/SALOME_NamingService.cxx @@ -702,7 +702,11 @@ char* SALOME_NamingService::Current_Directory() char* return_Path = new char[length_path +2]; return_Path[0] = '/' ; return_Path[1] = '\0' ; +#ifndef WNT for (int k = 0 ; k remove( _Id ) ; } _Id = 0 ; +#ifndef WNT delete [] _Ior; +#else + delete [] (char*) _Ior; +#endif _Ior = 0; _SessionName = ""; _Name = "" ; @@ -121,7 +125,7 @@ void RegistryConnexion::add( const char *aName ) infos.pid = lesInfos.pid() ; infos.machine = CORBA::string_dup( lesInfos.host_char() ) ; infos.adip = CORBA::string_dup( lesInfos.adip() ) ; - infos.uid = lesInfos.uid() ; + infos.uid = (long)lesInfos.uid() ; infos.pwname = CORBA::string_dup( lesInfos.pwname() ) ; infos.tc_start = lesInfos.start() ; infos.tc_hello = 0 ; diff --git a/src/Registry/RegistryConnexion.hxx b/src/Registry/RegistryConnexion.hxx index 5b945cd41..c241618ef 100644 --- a/src/Registry/RegistryConnexion.hxx +++ b/src/Registry/RegistryConnexion.hxx @@ -37,7 +37,21 @@ #include CORBA_CLIENT_HEADER(SALOME_Registry) #include -class RegistryConnexion +#if defined REGISTRY_EXPORTS +#if defined WIN32 +#define REGISTRY_EXPORT __declspec( dllexport ) +#else +#define REGISTRY_EXPORT +#endif +#else +#if defined WNT +#define REGISTRY_EXPORT __declspec( dllimport ) +#else +#define REGISTRY_EXPORT +#endif +#endif + +class REGISTRY_EXPORT RegistryConnexion { protected : const char* _Ior ; // engine ior diff --git a/src/Registry/RegistryService.cxx b/src/Registry/RegistryService.cxx index 8aed1d77f..0992377c3 100644 --- a/src/Registry/RegistryService.cxx +++ b/src/Registry/RegistryService.cxx @@ -35,7 +35,9 @@ extern "C" # include } +#ifndef WNT #include +#endif using namespace std; /* ------------------------------*/ @@ -70,7 +72,11 @@ RegistryService::~RegistryService() _Compteur = -1 ; if ( _SessionName ) { +#ifndef WNT delete [] _SessionName ; +#else + delete [] (char*)_SessionName ; +#endif _SessionName = 0 ; } END_OF("RegistryService::~RegistryService()") ; diff --git a/src/ResourcesManager/SALOME_LoadRateManager.hxx b/src/ResourcesManager/SALOME_LoadRateManager.hxx index 9a5d98441..ab45f35c1 100644 --- a/src/ResourcesManager/SALOME_LoadRateManager.hxx +++ b/src/ResourcesManager/SALOME_LoadRateManager.hxx @@ -5,7 +5,22 @@ #include CORBA_CLIENT_HEADER(SALOME_ContainerManager) #include -class SALOME_LoadRateManager + +#if defined RESOURCESMANAGER_EXPORTS +#if defined WIN32 +#define RESOURCESMANAGER_EXPORT __declspec( dllexport ) +#else +#define RESOURCESMANAGER_EXPORT +#endif +#else +#if defined WNT +#define RESOURCESMANAGER_EXPORT __declspec( dllimport ) +#else +#define RESOURCESMANAGER_EXPORT +#endif +#endif + +class RESOURCESMANAGER_EXPORT SALOME_LoadRateManager { public: std::string FindBest(const Engines::MachineList& hosts); diff --git a/src/ResourcesManager/SALOME_ResourcesManager.cxx b/src/ResourcesManager/SALOME_ResourcesManager.cxx index 244bd96ff..388cc4987 100644 --- a/src/ResourcesManager/SALOME_ResourcesManager.cxx +++ b/src/ResourcesManager/SALOME_ResourcesManager.cxx @@ -6,7 +6,12 @@ #include #include +#ifndef WNT #include +#else +#include +#include +#endif #include #include #include @@ -176,6 +181,26 @@ string SALOME_ResourcesManager::FindBest(const Engines::MachineList& listOfMachi return _dynamicResourcesSelecter.FindBest(listOfMachines); } +bool Engines_Container_i::isPythonContainer(const char* ContainerName) +{ + bool ret=false; + int len=strlen(ContainerName); + if(len>=2) + if(strcmp(ContainerName+len-2,"Py")==0) + ret=true; + return ret; +} + +bool isPythonContainer(const char* ContainerName) +{ + bool ret=false; + int len=strlen(ContainerName); + if(len>=2) + if(strcmp(ContainerName+len-2,"Py")==0) + ret=true; + return ret; +} + string SALOME_ResourcesManager::BuildTempFileToLaunchRemoteContainer(const string& machine,const char *containerName) { _TmpFileName=BuildTemporaryFileName(); @@ -198,7 +223,7 @@ string SALOME_ResourcesManager::BuildTempFileToLaunchRemoteContainer(const strin tempOutputFile << "source " << resInfo.PreReqFilePath << endl; // ! env vars tempOutputFile << (*(resInfo.ModulesPath.find("KERNEL"))).second << "/bin/salome/"; - if(Engines_Container_i::isPythonContainer(containerName)) + if(isPythonContainer(containerName)) tempOutputFile << "SALOME_ContainerPy.py "; else tempOutputFile << "SALOME_Container "; @@ -374,7 +399,13 @@ string SALOME_ResourcesManager::BuildTemporaryFileName() const char *temp=new char[19]; strcpy(temp,"/tmp/command"); strcat(temp,"XXXXXX"); +#ifndef WNT mkstemp(temp); +#else + char aPID[80]; + itoa(getpid(), aPID, 10); + strcat(temp,aPID); +#endif string command(temp); delete [] temp; command += ".sh"; diff --git a/src/ResourcesManager/SALOME_ResourcesManager.hxx b/src/ResourcesManager/SALOME_ResourcesManager.hxx index c0b6ef385..c62c86e70 100644 --- a/src/ResourcesManager/SALOME_ResourcesManager.hxx +++ b/src/ResourcesManager/SALOME_ResourcesManager.hxx @@ -11,10 +11,26 @@ #include #include + + +#if defined RESOURCESMANAGER_EXPORTS +#if defined WIN32 +#define RESOURCESMANAGER_EXPORT __declspec( dllexport ) +#else +#define RESOURCESMANAGER_EXPORT +#endif +#else +#if defined WNT +#define RESOURCESMANAGER_EXPORT __declspec( dllimport ) +#else +#define RESOURCESMANAGER_EXPORT +#endif +#endif + //WARNING the call of BuildTempFileToLaunchRemoteContainer and RmTmpFile must be done in a critical section to be sure to be clean. //Only one thread should use the SALOME_ResourcesManager class in a SALOME session. -class SALOME_ResourcesManager +class RESOURCESMANAGER_EXPORT SALOME_ResourcesManager { public: //! standard constructor diff --git a/src/RessourcesCatalog/SALOME_RessourcesCatalog_impl.cxx b/src/RessourcesCatalog/SALOME_RessourcesCatalog_impl.cxx index 5a1d7bed4..28be74c37 100644 --- a/src/RessourcesCatalog/SALOME_RessourcesCatalog_impl.cxx +++ b/src/RessourcesCatalog/SALOME_RessourcesCatalog_impl.cxx @@ -227,7 +227,11 @@ SALOME_RessourcesCatalogImpl::_verify_ressources(ListOfParserressources ressourc _machine_list.push_back(ressourceslist[ind].Parsername); // Parse if a computer name is twice in the list of computers +#ifndef WNT for (unsigned int ind = 0; ind < _machine_list.size(); ind++) +#else + for (ind = 0; ind < _machine_list.size(); ind++) +#endif { for (unsigned int ind1 = ind+1 ; ind1 < _machine_list.size(); ind1++) { diff --git a/src/SALOMELocalTrace/LocalTraceBufferPool.hxx b/src/SALOMELocalTrace/LocalTraceBufferPool.hxx index 597b218e8..bd19b33c1 100644 --- a/src/SALOMELocalTrace/LocalTraceBufferPool.hxx +++ b/src/SALOMELocalTrace/LocalTraceBufferPool.hxx @@ -34,7 +34,23 @@ #define ABORT_MESS 1 // for traceType field in struct LocalTrace_TraceInfo #define NORMAL_MESS 0 -struct LocalTrace_TraceInfo +#if defined SALOMELOCALTRACE_EXPORTS +#if defined WIN32 +#define SALOMELOCALTRACE_EXPORT __declspec( dllexport ) +#else +#define SALOMELOCALTRACE_EXPORT +#endif +#else +#if defined WNT +#define SALOMELOCALTRACE_EXPORT __declspec( dllimport ) +#else +#define SALOMELOCALTRACE_EXPORT +#endif +#endif + + + +struct SALOMELOCALTRACE_EXPORT LocalTrace_TraceInfo { char trace[MAX_TRACE_LENGTH]; pthread_t threadId; @@ -42,7 +58,7 @@ struct LocalTrace_TraceInfo int position; // to check sequence }; -class LocalTraceBufferPool +class SALOMELOCALTRACE_EXPORT LocalTraceBufferPool { public: static LocalTraceBufferPool* instance(); diff --git a/src/SALOMELocalTrace/LocalTraceCollector.cxx b/src/SALOMELocalTrace/LocalTraceCollector.cxx index e150db6d9..5ff0874d3 100644 --- a/src/SALOMELocalTrace/LocalTraceCollector.cxx +++ b/src/SALOMELocalTrace/LocalTraceCollector.cxx @@ -38,7 +38,7 @@ using namespace std; LocalTraceCollector* LocalTraceCollector::_singleton = 0; pthread_mutex_t LocalTraceCollector::_singletonMutex; int LocalTraceCollector::_threadToClose = 0; -pthread_t LocalTraceCollector::_threadId = 0; // used to control single run +pthread_t* LocalTraceCollector::_threadId = 0; // used to control single run int LocalTraceCollector::_toFile = 0; std::string LocalTraceCollector::_fileName = ""; @@ -117,14 +117,21 @@ void* LocalTraceCollector::run(void *bid) if (! _threadId) // only one run { isOKtoRun = 1; - _threadId = pthread_self(); + if(_threadId == 0) { + _threadId = new pthread_t; + } + *_threadId = pthread_self(); } else cout << "----- Comment est-ce possible de passer la ? -------" <insert(NORMAL_MESS,"end of trace "); //needed to wake up thread if (_threadId) { - int ret = pthread_join(_threadId, NULL); + int ret = pthread_join(*_threadId, NULL); if (ret) cout << "error close LocalTraceCollector : "<< ret << endl; else cout << "LocalTraceCollector destruction OK" << endl; } diff --git a/src/SALOMELocalTrace/LocalTraceCollector.hxx b/src/SALOMELocalTrace/LocalTraceCollector.hxx index d9ce36f5f..01c5f35e8 100644 --- a/src/SALOMELocalTrace/LocalTraceCollector.hxx +++ b/src/SALOMELocalTrace/LocalTraceCollector.hxx @@ -32,7 +32,7 @@ //! See SALOMETraceCollector instead of LocalTraceCollector for SALOME usage -class LocalTraceCollector +class SALOMELOCALTRACE_EXPORT LocalTraceCollector { public: static LocalTraceCollector* instance(int typeTrace=0); @@ -47,7 +47,7 @@ class LocalTraceCollector static int _toFile; static LocalTraceCollector* _singleton; static pthread_mutex_t _singletonMutex; - static pthread_t _threadId; + static pthread_t* _threadId; static std::string _fileName; }; diff --git a/src/SALOMELocalTrace/utilities.h b/src/SALOMELocalTrace/utilities.h index d29e35a5b..654f61506 100644 --- a/src/SALOMELocalTrace/utilities.h +++ b/src/SALOMELocalTrace/utilities.h @@ -60,10 +60,17 @@ #define INFOS(msg) {MESS_BEGIN("- Trace ") << msg << MESS_END} #define PYSCRIPT(msg) {MESS_INIT("---PYSCRIPT--- ") << msg << MESS_END} #define INTERRUPTION(msg) {MESS_BEGIN("- INTERRUPTION: ")<< msg << MESS_ABORT} +#ifdef WNT +#define IMMEDIATE_ABORT(code) {std::cout <putMessage(LogMsg); @@ -202,14 +215,22 @@ void* SALOMETraceCollector::run(void *bid) } break; case 1 : // --- trace to file +#ifndef WNT traceFile << "INTERRUPTION from thread " << myTrace.threadId +#else + traceFile << "INTERRUPTION from thread " << (void*)&myTrace.threadId +#endif << " : " << myTrace.trace; traceFile.close(); // no break here ! case 0 : // --- trace to standard output default : // --- on standard output, too cout << flush ; +#ifndef WNT cerr << "INTERRUPTION from thread " << myTrace.threadId +#else + cerr << "INTERRUPTION from thread " << (void*)&myTrace.threadId +#endif << " : " << myTrace.trace; cerr << flush ; exit(1); @@ -223,7 +244,11 @@ void* SALOMETraceCollector::run(void *bid) case 2 : // --- trace collection via CORBA { stringstream aMessage(""); +#ifndef WNT aMessage << "th. " << myTrace.threadId +#else + aMessage << "th. " << (void*)&myTrace.threadId +#endif << " " << myTrace.trace; CORBA::String_var LogMsg = CORBA::string_dup(aMessage.str().c_str()); @@ -231,12 +256,20 @@ void* SALOMETraceCollector::run(void *bid) } break; case 1 : // --- trace to file +#ifndef WNT traceFile << "th. " << myTrace.threadId +#else + traceFile << "th. " << (void*)&myTrace.threadId +#endif << " " << myTrace.trace; break; case 0 : // --- trace to standard output default : // --- on standard output, too +#ifndef WNT cout << "th. " << myTrace.threadId << " " << myTrace.trace; +#else + cout << "th. " << &myTrace.threadId << " " << myTrace.trace; +#endif break; } } @@ -245,6 +278,7 @@ void* SALOMETraceCollector::run(void *bid) if (_toFile==1) traceFile.close(); } pthread_exit(NULL); + return NULL; } // ============================================================================ @@ -260,7 +294,7 @@ SALOMETraceCollector:: ~SALOMETraceCollector() myTraceBuffer->insert(NORMAL_MESS,"end of trace "); //needed to wake up thread if (_threadId) { - int ret = pthread_join(_threadId, NULL); + int ret = pthread_join(*_threadId, NULL); if (ret) cout << "error close SALOMETraceCollector : "<< ret << endl; else cout << "SALOMETraceCollector destruction OK" << endl; } diff --git a/src/SALOMETraceCollector/SALOMETraceCollector.hxx b/src/SALOMETraceCollector/SALOMETraceCollector.hxx index 7d1b4bbb8..d75806da1 100644 --- a/src/SALOMETraceCollector/SALOMETraceCollector.hxx +++ b/src/SALOMETraceCollector/SALOMETraceCollector.hxx @@ -48,7 +48,7 @@ class SALOMETraceCollector static int _toFile; static SALOMETraceCollector* _singleton; static pthread_mutex_t _singletonMutex; - static pthread_t _threadId; + static pthread_t* _threadId; static std::string _fileName; static CORBA::ORB_ptr _orb; }; diff --git a/src/SALOMETraceCollector/TraceCollector_WaitForServerReadiness.cxx b/src/SALOMETraceCollector/TraceCollector_WaitForServerReadiness.cxx index 5512ea926..2545cbce5 100644 --- a/src/SALOMETraceCollector/TraceCollector_WaitForServerReadiness.cxx +++ b/src/SALOMETraceCollector/TraceCollector_WaitForServerReadiness.cxx @@ -28,6 +28,10 @@ #include #include +#ifdef WNT +#include +#endif + using namespace std; // ============================================================================ @@ -109,7 +113,11 @@ CORBA::Object_ptr TraceCollector_WaitForServerReadiness(CORBA::ORB_ptr orb, cout << "Caught exception: Naming Service can't found Logger"; } } +#ifndef WNT int a = nanosleep(&ts_req,&ts_rem); +#else + Sleep(TIMESleep / 1000000); +#endif cout << "TraceCollector_WaitForServerReadiness: retry look for" << serverName << endl; } diff --git a/src/Utils/OpUtil.hxx b/src/Utils/OpUtil.hxx index 086aa0040..7c3293b7c 100644 --- a/src/Utils/OpUtil.hxx +++ b/src/Utils/OpUtil.hxx @@ -27,9 +27,23 @@ #ifndef _OPUTIL_HXX #define _OPUTIL_HXX +#if defined UTILS_EXPORTS +#if defined WIN32 +#define UTILS_EXPORT __declspec( dllexport ) +#else +#define UTILS_EXPORT +#endif +#else +#if defined WNT +#define UTILS_EXPORT __declspec( dllimport ) +#else +#define UTILS_EXPORT +#endif +#endif + #include -std::string GetHostname(); -const char *duplicate(const char * const); +UTILS_EXPORT std::string GetHostname(); +UTILS_EXPORT const char *duplicate(const char * const); #endif diff --git a/src/Utils/Utils_CommException.hxx b/src/Utils/Utils_CommException.hxx index c559355d4..388445bfc 100644 --- a/src/Utils/Utils_CommException.hxx +++ b/src/Utils/Utils_CommException.hxx @@ -31,7 +31,7 @@ # include "Utils_SALOME_Exception.hxx" -class CommException : public SALOME_Exception +class UTILS_EXPORT CommException : public SALOME_Exception { public : CommException( void ); diff --git a/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.cxx b/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.cxx index b600d8ac1..3296da6d2 100644 --- a/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.cxx +++ b/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.cxx @@ -50,13 +50,13 @@ std::list *DESTRUCTEUR_GENERIQUE_::Destructeurs=0 ; /*! \class ATEXIT_ * - * Mécanisme pour faire exécuter une seule fois DESTRUCTEUR_GENERIQUE_::Nettoyage - * à la fin du traitement : creation d'un singleton statique de l'objet + * M‰canisme pour faire ex‰cuter une seule fois DESTRUCTEUR_GENERIQUE_::Nettoyage + * € la fin du traitement : creation d'un singleton statique de l'objet * tres specialise ATEXIT_. * - * La création d'un objet de type ATEXIT_ entraîne l'inscription de la fonction - * Nettoyage() par atexit(). Il suffit donc de créer un singleton statique du type ATEXIT_ - * pour effectuer cet enregistrement une seule fois indépendament de l'utilisateur. + * La cr‰ation d'un objet de type ATEXIT_ entraŽne l'inscription de la fonction + * Nettoyage() par atexit(). Il suffit donc de cr‰er un singleton statique du type ATEXIT_ + * pour effectuer cet enregistrement une seule fois ind‰pendament de l'utilisateur. */ //CCRT @@ -67,10 +67,10 @@ class ATEXIT_ { public : /*! - * Allocation dynamique de Destructeurs, une liste chaînée de DESTRUCTEUR_GENERIQUE_* et enregistrement + * Allocation dynamique de Destructeurs, une liste chaŽn‰e de DESTRUCTEUR_GENERIQUE_* et enregistrement * de la fonction Nettoyage() par atexit(). * - * La liste chaînée Destructeurs est détruite dans la fonction Nettoyage. + * La liste chaŽn‰e Destructeurs est d‰truite dans la fonction Nettoyage. */ //CCRT ATEXIT_( void ) ATEXIT_( bool Make_ATEXIT ) @@ -81,9 +81,9 @@ public : ASSERT (DESTRUCTEUR_GENERIQUE_::Destructeurs==0); if(MYDEBUG) MESSAGE("Construction ATEXIT"); // message necessaire pour utiliser logger dans Nettoyage (cf.BUG KERNEL4561) DESTRUCTEUR_GENERIQUE_::Destructeurs = - new std::list ; // Destructeurs alloué dynamiquement (cf. ci-dessous) , - // il est utilisé puis détruit par la fonction Nettoyage - int cr = atexit( Nettoyage ); // exécute Nettoyage lors de exit, après la destruction des données statiques ! + new std::list ; // Destructeurs allou‰ dynamiquement (cf. ci-dessous) , + // il est utilis‰ puis d‰truit par la fonction Nettoyage + int cr = atexit( Nettoyage ); // ex‰cute Nettoyage lors de exit, aprˆs la destruction des donn‰es statiques ! ASSERT(cr==0) ; ATEXIT_Done = true ; } @@ -102,10 +102,10 @@ static ATEXIT_ nettoyage = ATEXIT_( false ); /* singleton statique */ /*! - * traitement effectué : - * -# exécution de tous les objets de type DESTRUCTEUR_DE_ stockés dans la liste Destructeurs (ce qui détruit les + * traitement effectu‰ : + * -# ex‰cution de tous les objets de type DESTRUCTEUR_DE_ stock‰s dans la liste Destructeurs (ce qui d‰truit les * singletons correspondant) ; - * -# puis destruction de tous les objets de type DESTRUCTEUR_DE_ stockés dans la liste Destructeurs; + * -# puis destruction de tous les objets de type DESTRUCTEUR_DE_ stock‰s dans la liste Destructeurs; * -# destruction de la liste Destructeurs. */ diff --git a/src/Utils/Utils_Identity.cxx b/src/Utils/Utils_Identity.cxx index f6ae3019f..daa27b0ee 100644 --- a/src/Utils/Utils_Identity.cxx +++ b/src/Utils/Utils_Identity.cxx @@ -174,7 +174,7 @@ const char* const Identity::name (void) const #ifndef WNT const struct utsname &Identity::hostid(void) const #else - const char* const hostid(void) const + const char* const Identity::hostid(void) const #endif { return _hostid ; diff --git a/src/Utils/Utils_Identity.hxx b/src/Utils/Utils_Identity.hxx index 9f4ca4704..9dd4db080 100644 --- a/src/Utils/Utils_Identity.hxx +++ b/src/Utils/Utils_Identity.hxx @@ -41,7 +41,20 @@ extern "C" #endif } -class Identity +#if defined UTILS_EXPORTS +#if defined WIN32 +#define UTILS_EXPORT __declspec( dllexport ) +#else +#define UTILS_EXPORT +#endif +#else +#if defined WNT +#define UTILS_EXPORT __declspec( dllimport ) +#else +#define UTILS_EXPORT +#endif +#endif +class UTILS_EXPORT Identity { protected : diff --git a/src/Utils/Utils_Mutex.cxx b/src/Utils/Utils_Mutex.cxx index 0aa3e4514..ef5881212 100644 --- a/src/Utils/Utils_Mutex.cxx +++ b/src/Utils/Utils_Mutex.cxx @@ -44,8 +44,12 @@ Utils_Mutex::~Utils_Mutex() void Utils_Mutex::lock() { pthread_mutex_lock( &myHelperMutex ); - + +#ifndef WNT if ( myCount > 0 && myThread == pthread_self() ) { +#else + if ( myCount > 0 && myThread.p == pthread_self().p ) { +#endif myCount++; } else { @@ -62,8 +66,12 @@ void Utils_Mutex::lock() void Utils_Mutex::unlock() { pthread_mutex_lock( &myHelperMutex ); - + +#ifndef WNT if ( myThread == pthread_self() ) { +#else + if ( myThread.p == pthread_self().p ) { +#endif if ( myCount && (--myCount) < 1 ) { myCount = 0; pthread_mutex_unlock( &myMutex ); diff --git a/src/Utils/Utils_Mutex.hxx b/src/Utils/Utils_Mutex.hxx index d33df2211..0d692099d 100644 --- a/src/Utils/Utils_Mutex.hxx +++ b/src/Utils/Utils_Mutex.hxx @@ -30,7 +30,21 @@ #include -class Utils_Mutex +#if defined UTILS_EXPORTS +#if defined WIN32 +#define UTILS_EXPORT __declspec( dllexport ) +#else +#define UTILS_EXPORT +#endif +#else +#if defined WNT +#define UTILS_EXPORT __declspec( dllimport ) +#else +#define UTILS_EXPORT +#endif +#endif + +class UTILS_EXPORT Utils_Mutex { public: Utils_Mutex(); @@ -46,7 +60,7 @@ private: int myCount; }; -class Utils_Locker +class UTILS_EXPORT Utils_Locker { public: Utils_Locker( Utils_Mutex* ); diff --git a/src/Utils/Utils_ORB_INIT.hxx b/src/Utils/Utils_ORB_INIT.hxx index 1a5c822db..345e2a292 100644 --- a/src/Utils/Utils_ORB_INIT.hxx +++ b/src/Utils/Utils_ORB_INIT.hxx @@ -34,12 +34,26 @@ #include "Utils_CommException.hxx" +#if defined UTILS_EXPORTS +#if defined WIN32 +#define UTILS_EXPORT __declspec( dllexport ) +#else +#define UTILS_EXPORT +#endif +#else +#if defined WNT +#define UTILS_EXPORT __declspec( dllimport ) +#else +#define UTILS_EXPORT +#endif +#endif + /*! * Ce composant prend en charge la connexion et la deconnexion a l'orb * Il est souhaitable de l'utiliser dans un SINGLETON. */ -class ORB_INIT +class UTILS_EXPORT ORB_INIT { private : diff --git a/src/Utils/Utils_SALOME_Exception.cxx b/src/Utils/Utils_SALOME_Exception.cxx index dcb4ed95c..b8cb4267d 100644 --- a/src/Utils/Utils_SALOME_Exception.cxx +++ b/src/Utils/Utils_SALOME_Exception.cxx @@ -29,12 +29,17 @@ #include #include "Utils_SALOME_Exception.hxx" #include "utilities.h" + +#ifndef WNT extern "C" { +#endif #include #include #include +#ifndef WNT } +#endif const char* duplicate( const char *const str ) ; diff --git a/src/Utils/Utils_SALOME_Exception.hxx b/src/Utils/Utils_SALOME_Exception.hxx index 9ab9c9c3c..c870618aa 100644 --- a/src/Utils/Utils_SALOME_Exception.hxx +++ b/src/Utils/Utils_SALOME_Exception.hxx @@ -34,8 +34,21 @@ # define LOCALIZED(message) #message , __FILE__ , __LINE__ +#if defined UTILS_EXPORTS +#if defined WIN32 +#define UTILS_EXPORT __declspec( dllexport ) +#else +#define UTILS_EXPORT +#endif +#else +#if defined WNT +#define UTILS_EXPORT __declspec( dllimport ) +#else +#define UTILS_EXPORT +#endif +#endif -class SALOME_Exception : public std::exception +class UTILS_EXPORT SALOME_Exception : public std::exception { private : diff --git a/src/Utils/Utils_SignalsHandler.h b/src/Utils/Utils_SignalsHandler.h index 475dcf18e..44228ba87 100644 --- a/src/Utils/Utils_SignalsHandler.h +++ b/src/Utils/Utils_SignalsHandler.h @@ -22,11 +22,25 @@ #define _UTILS_SIGNALSHANDLER_H_ +#if defined UTILS_EXPORTS +#if defined WIN32 +#define UTILS_EXPORT __declspec( dllexport ) +#else +#define UTILS_EXPORT +#endif +#else +#if defined WNT +#define UTILS_EXPORT __declspec( dllimport ) +#else +#define UTILS_EXPORT +#endif +#endif + #include typedef void (*TSigHandler)(int); -class Utils_SignalsHandler{ +class UTILS_EXPORT Utils_SignalsHandler{ public: Utils_SignalsHandler(); ~Utils_SignalsHandler(); @@ -40,7 +54,7 @@ class Utils_SignalsHandler{ }; -class Utils_CASSignalsHandler: private Utils_SignalsHandler{ +class UTILS_EXPORT Utils_CASSignalsHandler: private Utils_SignalsHandler{ public: Utils_CASSignalsHandler(); }; diff --git a/src/Utils/duplicate.cxx b/src/Utils/duplicate.cxx index b1e449ce4..b611ba64c 100644 --- a/src/Utils/duplicate.cxx +++ b/src/Utils/duplicate.cxx @@ -37,6 +37,7 @@ extern "C" #include } #include "utilities.h" +#include "OpUtil.hxx" using namespace std; -- 2.39.2