From: env Date: Wed, 13 Jul 2005 06:54:30 +0000 (+0000) Subject: ENV: Windows porting. X-Git-Tag: V3_0_1~19 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=37e78b227be34686fd6473fc49797ed4459c76aa;p=modules%2Fkernel.git ENV: Windows porting. --- diff --git a/src/Container/Component_i.cxx b/src/Container/Component_i.cxx index 86763cb89..01ad220b8 100644 --- a/src/Container/Component_i.cxx +++ b/src/Container/Component_i.cxx @@ -32,13 +32,21 @@ #include "RegistryConnexion.hxx" #include "OpUtil.hxx" #include +#ifndef WNT #include +#endif #include #include "utilities.h" +#ifndef WNT #include #include #include +#else +#include +int SIGUSR11 = 1000; +#endif + using namespace std; @@ -322,11 +330,21 @@ bool Engines_Component_i::Kill_impl() // << dec ) ; bool RetVal = false ; +#ifndef WNT if ( _ThreadId > 0 && pthread_self() != _ThreadId ) { RetVal = Killer( _ThreadId , 0 ) ; _ThreadId = (pthread_t ) -1 ; } + +#else + if ( _ThreadId > 0 && pthread_self().p != _ThreadId->p ) + { + RetVal = Killer( *_ThreadId , 0 ) ; + _ThreadId = (pthread_t* ) 0 ; + } + +#endif return RetVal ; } @@ -346,11 +364,19 @@ bool Engines_Component_i::Stop_impl() bool RetVal = false ; +#ifndef WNT if ( _ThreadId > 0 && pthread_self() != _ThreadId ) { RetVal = Killer( _ThreadId , 0 ) ; _ThreadId = (pthread_t ) -1 ; } +#else + if ( _ThreadId > 0 && pthread_self().p != _ThreadId->p ) + { + RetVal = Killer( *_ThreadId , 0 ) ; + _ThreadId = (pthread_t* ) 0 ; + } +#endif return RetVal ; } @@ -369,7 +395,11 @@ bool Engines_Component_i::Suspend_impl() << dec << " _ThreadId " << _ThreadId ); bool RetVal = false ; +#ifndef WNT if ( _ThreadId > 0 && pthread_self() != _ThreadId ) +#else + if ( _ThreadId > 0 && pthread_self().p != _ThreadId->p ) +#endif { if ( _Sleeping ) { @@ -377,7 +407,12 @@ bool Engines_Component_i::Suspend_impl() } else { +#ifndef WNT RetVal = Killer( _ThreadId ,SIGINT ) ; +#else + RetVal = Killer( *_ThreadId ,SIGINT ) ; +#endif + } } return RetVal ; @@ -397,7 +432,11 @@ bool Engines_Component_i::Resume_impl() << " machineName " << GetHostname().c_str()<< " _id " << hex << _id << dec << " _ThreadId " << _ThreadId ); bool RetVal = false ; +#ifndef WNT if ( _ThreadId > 0 && pthread_self() != _ThreadId ) +#else + if ( _ThreadId > 0 && pthread_self().p != _ThreadId->p ) +#endif { if ( _Sleeping ) { @@ -425,7 +464,11 @@ CORBA::Long Engines_Component_i::CpuUsed_impl() { if ( _ThreadId > 0 ) { +#ifndef WNT if ( pthread_self() != _ThreadId ) +#else + if ( pthread_self().p != _ThreadId->p ) +#endif { if ( _Sleeping ) { @@ -434,7 +477,11 @@ CORBA::Long Engines_Component_i::CpuUsed_impl() { // Get Cpu in the appropriate thread with that object !... theEngines_Component = this ; +#ifndef WNT Killer( _ThreadId ,SIGUSR1 ) ; +#else + Killer( *_ThreadId ,SIGUSR11 ) ; +#endif } cpu = _ThreadCpuUsed ; } @@ -508,7 +555,13 @@ void Engines_Component_i::beginService(const char *serviceName) { MESSAGE(pthread_self() << "Send BeginService notification for " <p = pthread_self().p ; + _ThreadId->x = pthread_self().x ; +#endif _StartUsed = 0 ; _StartUsed = CpuUsed_impl() ; _ThreadCpuUsed = 0 ; @@ -602,7 +655,11 @@ char* Engines_Component_i::nodeName() bool Engines_Component_i::Killer( pthread_t ThreadId , int signum ) { +#ifndef WNT if ( ThreadId ) +#else + if ( ThreadId.p ) +#endif { if ( signum == 0 ) { @@ -667,6 +724,7 @@ void Engines_Component_i::SetCurCpu() long Engines_Component_i::CpuUsed() { long cpu = 0 ; +#ifndef WNT struct rusage usage ; if ( _ThreadId || _Executed ) { @@ -686,6 +744,11 @@ long Engines_Component_i::CpuUsed() // << _ThreadId << " " << _serviceName<< " _StartUsed " // << _StartUsed << endl ; } +#else + // NOT implementet yet +#endif + + return cpu ; } diff --git a/src/Container/Container_i.cxx b/src/Container/Container_i.cxx index d1f27369a..681532b53 100644 --- a/src/Container/Container_i.cxx +++ b/src/Container/Container_i.cxx @@ -28,15 +28,26 @@ //#define private public #include +#ifndef WNT #include CORBA_SERVER_HEADER(SALOME_Component) +#else +#include +#endif #include "SALOME_Container_i.hxx" #include "SALOME_Component_i.hxx" #include "SALOME_NamingService.hxx" #include "OpUtil.hxx" #include #include +#ifndef WNT #include #include +#else +#include "../../adm/win32/SALOME_WNT.hxx" +#include +#include +int SIGUSR1 = 1000; +#endif #include #include "Container_init_python.hxx" @@ -54,7 +65,12 @@ char ** _ArgV ; // Other Containers are started via start_impl of FactoryServer extern "C" {void ActSigIntHandler() ; } +#ifndef WNT extern "C" {void SigIntHandler(int, siginfo_t *, void *) ; } +#else + extern "C" {void SigIntHandler( int ) ; } +#endif + const char *Engines_Container_i::_defaultContainerName="FactoryServer"; map Engines_Container_i::_cntInstances_map; @@ -277,7 +293,11 @@ Engines_Container_i::load_component_Library(const char* componentName) } void* handle; +#ifndef WNT handle = dlopen( impl_name.c_str() , RTLD_LAZY ) ; +#else + handle = dlopen( impl_name.c_str() , 0 ) ; +#endif if ( handle ) { _library_map[impl_name] = handle; @@ -528,6 +548,7 @@ bool Engines_Container_i::Kill_impl() INFOS("==============================================================="); //exit( 0 ) ; ASSERT(0); + return false; } //============================================================================= @@ -787,11 +808,15 @@ string Engines_Container_i::BuildContainerNameForNS(const char *ContainerName, void ActSigIntHandler() { +#ifndef WNT struct sigaction SigIntAct ; SigIntAct.sa_sigaction = &SigIntHandler ; SigIntAct.sa_flags = SA_SIGINFO ; - // DEBUG 03.02.2005 : the first parameter of sigaction is not a mask of signals (SIGINT | SIGUSR1) : - // it must be only one signal ===> one call for SIGINT and an other one for SIGUSR1 +#endif + +// DEBUG 03.02.2005 : the first parameter of sigaction is not a mask of signals (SIGINT | SIGUSR1) : +// it must be only one signal ===> one call for SIGINT and an other one for SIGUSR1 +#ifndef WNT if ( sigaction( SIGINT , &SigIntAct, NULL ) ) { perror("SALOME_Container main ") ; exit(0) ; @@ -801,10 +826,16 @@ void ActSigIntHandler() exit(0) ; } INFOS(pthread_self() << "SigIntHandler activated") ; +#else + signal( SIGINT, SigIntHandler ); + signal( SIGUSR1, SigIntHandler ); +#endif + } void SetCpuUsed() ; +#ifndef WNT void SigIntHandler(int what , siginfo_t * siginfo , void * toto ) { @@ -835,6 +866,33 @@ void SigIntHandler(int what , siginfo_t * siginfo , return ; } } +#else // Case WNT +void SigIntHandler( int what ) { + MESSAGE( pthread_self() << "SigIntHandler what " << what << endl ); + if ( _Sleeping ) { + _Sleeping = false ; + MESSAGE("SigIntHandler END sleeping.") ; + return ; + } + else { + ActSigIntHandler() ; + if ( what == SIGUSR1 ) { + SetCpuUsed() ; + } + else { + _Sleeping = true ; + MESSAGE("SigIntHandler BEGIN sleeping.") ; + int count = 0 ; + while( _Sleeping ) { + Sleep( 1000 ) ; + count += 1 ; + } + MESSAGE("SigIntHandler LEAVE sleeping after " << count << " s.") ; + } + return ; + } +} +#endif //============================================================================= /*! diff --git a/src/Container/SALOME_Component_i.hxx b/src/Container/SALOME_Component_i.hxx index 205eabd75..b30f87aa4 100644 --- a/src/Container/SALOME_Component_i.hxx +++ b/src/Container/SALOME_Component_i.hxx @@ -32,7 +32,9 @@ #include #include #include +#ifndef WNT #include +#endif #include #include #include @@ -42,7 +44,21 @@ class RegistryConnexion; -class Engines_Component_i: public virtual POA_Engines::Component, +#if defined CONTAINER_EXPORTS +#if defined WIN32 +#define CONTAINER_EXPORT __declspec( dllexport ) +#else +#define CONTAINER_EXPORT +#endif +#else +#if defined WNT +#define CONTAINER_EXPORT __declspec( dllimport ) +#else +#define CONTAINER_EXPORT +#endif +#endif + +class CONTAINER_EXPORT Engines_Component_i: public virtual POA_Engines::Component, public virtual PortableServer::RefCountServantBase { public: @@ -121,7 +137,11 @@ protected: std::map_fieldsDict; private: +#ifndef WNT pthread_t _ThreadId ; +#else + pthread_t* _ThreadId ; +#endif long _StartUsed ; long _ThreadCpuUsed ; bool _Executed ; diff --git a/src/Container/SALOME_ContainerManager.cxx b/src/Container/SALOME_ContainerManager.cxx index 77cebf354..8d4aaaa34 100644 --- a/src/Container/SALOME_ContainerManager.cxx +++ b/src/Container/SALOME_ContainerManager.cxx @@ -2,7 +2,9 @@ #include "SALOME_NamingService.hxx" #include "OpUtil.hxx" #include +#ifndef WNT #include +#endif #include #define TIME_OUT_TO_LAUNCH_CONT 21 @@ -83,7 +85,11 @@ Engines::Container_ptr SALOME_ContainerManager::FindOrStartContainer(const char else { int count=TIME_OUT_TO_LAUNCH_CONT; while ( CORBA::is_nil(ret) && count ) { +#ifndef WNT sleep( 1 ) ; +#else + Sleep(1000); +#endif count-- ; if ( count != 10 ) MESSAGE( count << ". Waiting for FactoryServer on " << theMachine); diff --git a/src/Container/SALOME_ContainerManager.hxx b/src/Container/SALOME_ContainerManager.hxx index 9293f1881..a34b6b467 100644 --- a/src/Container/SALOME_ContainerManager.hxx +++ b/src/Container/SALOME_ContainerManager.hxx @@ -11,7 +11,21 @@ class SALOME_NamingService; -class SALOME_ContainerManager: public POA_Engines::ContainerManager, +#if defined CONTAINER_EXPORTS +#if defined WIN32 +#define CONTAINER_EXPORT __declspec( dllexport ) +#else +#define CONTAINER_EXPORT +#endif +#else +#if defined WNT +#define CONTAINER_EXPORT __declspec( dllimport ) +#else +#define CONTAINER_EXPORT +#endif +#endif + +class CONTAINER_EXPORT SALOME_ContainerManager: public POA_Engines::ContainerManager, public PortableServer::RefCountServantBase { private: SALOME_ResourcesManager _ResManager; diff --git a/src/Container/SALOME_Container_i.hxx b/src/Container/SALOME_Container_i.hxx index 06e1f1aa8..b1dc79e80 100644 --- a/src/Container/SALOME_Container_i.hxx +++ b/src/Container/SALOME_Container_i.hxx @@ -35,7 +35,9 @@ #include #include #include +#ifndef WNT #include +#endif #include #include #include @@ -43,7 +45,22 @@ class SALOME_NamingService; -class Engines_Container_i: public virtual POA_Engines::Container, + +#if defined CONTAINER_EXPORTS +#if defined WIN32 +#define CONTAINER_EXPORT __declspec( dllexport ) +#else +#define CONTAINER_EXPORT +#endif +#else +#if defined WNT +#define CONTAINER_EXPORT __declspec( dllimport ) +#else +#define CONTAINER_EXPORT +#endif +#endif + +class CONTAINER_EXPORT Engines_Container_i: public virtual POA_Engines::Container, public virtual PortableServer::RefCountServantBase { public: