-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-// File : MPIContainer_i.cxx
-// Module : SALOME
#include <iostream>
#include <dlfcn.h>
PortableServer::POA_ptr poa,
char * containerName,
int argc, char *argv[])
- : Engines_Container_i(orb,poa,containerName,argc,argv,false)
+ : Engines_Container_i(orb,poa,containerName,argc,argv,nullptr,false)
{
_id = _poa->activate_object(this);
_NS->init_orb( CORBA::ORB::_duplicate(_orb) ) ;
std::string hostname = Kernel_Utils::GetHostname();
- _containerName = _NS->BuildContainerNameForNS(containerName,hostname.c_str());
+ _containerName = SALOME_NamingService_Abstract::BuildContainerNameForNS(containerName,hostname.c_str());
SCRUTE(_containerName);
_NS->Register(pCont, _containerName.c_str());
{
reason=CORBA::string_dup("");
- pthread_t *th;
+ pthread_t *th = 0;
if(_numproc == 0){
th = new pthread_t[_nbproc];
for(int ip=1;ip<_nbproc;ip++){
// --- try dlopen C++ component
+#ifdef __APPLE__
+ std::string impl_name = std::string ("lib") + aCompName + std::string("Engine.dylib");
+#else
std::string impl_name = std::string ("lib") + aCompName + std::string("Engine.so");
+#endif
_numInstanceMutex.lock(); // lock to be alone
// (see decInstanceCnt, finalize_removal))
}
void* handle;
- handle = dlopen( impl_name.c_str() , RTLD_LAZY ) ;
+ handle = dlopen( impl_name.c_str() , RTLD_LAZY | RTLD_GLOBAL ) ;
if ( handle )
{
_library_map[impl_name] = handle;
PyObject *result = PyObject_CallMethod(pyCont,
(char*)"import_component",
(char*)"s",componentName);
- std::string ret= PyString_AsString(result);
+ std::string ret= PyUnicode_AsUTF8(result);
SCRUTE(ret);
Py_RELEASE_NEW_THREAD;
// Create an instance of component
Engines::EngineComponent_ptr
Engines_MPIContainer_i::create_component_instance_env( const char* componentName,
- const Engines::FieldsDict& env,
+ const Engines::FieldsDict& /*env*/,
CORBA::String_out reason)
{
reason=CORBA::string_dup("");
- pthread_t *th;
+ pthread_t *th = 0;
if(_numproc == 0){
th = new pthread_t[_nbproc];
for(int ip=1;ip<_nbproc;ip++){
PyObject *pyCont = PyDict_GetItemString(globals, "pyCont");
PyObject *result = PyObject_CallMethod(pyCont,
(char*)"create_component_instance",
- (char*)"ssl",
+ (char*)"ss",
aCompName.c_str(),
instanceName.c_str());
const char *ior;
//--- try C++
+#ifdef __APPLE__
+ std::string impl_name = std::string ("lib") + genericRegisterName +std::string("Engine.dylib");
+#else
std::string impl_name = std::string ("lib") + genericRegisterName +std::string("Engine.so");
+#endif
if (_library_map.count(impl_name) != 0) // C++ component
{
void* handle = _library_map[impl_name];
std::string component_registerName =
_containerName + "/" + instanceName;
- // --- Instanciate required CORBA object
+ // --- Instantiate required CORBA object
PortableServer::ObjectId *id ; //not owner, do not delete (nore use var)
id = (MPIComponent_factory) ( _orb, _poa, _id, instanceName.c_str(), aGenRegisterName.c_str() ) ;
Engines::EngineComponent_ptr Engines_MPIContainer_i::load_impl(const char* nameToRegister,
const char* componentName)
{
- pthread_t *th;
+ pthread_t *th = 0;
if(_numproc == 0){
th = new pthread_t[_nbproc];
for(int ip=1;ip<_nbproc;ip++){
std::string absolute_impl_name(_impl_name);
MESSAGE("[" << _numproc << "] absolute_impl_name=" << absolute_impl_name);
- void * handle = dlopen(absolute_impl_name.c_str(), RTLD_LAZY);
+ void * handle = dlopen(absolute_impl_name.c_str(), RTLD_LAZY | RTLD_GLOBAL);
if(!handle){
INFOS("[" << _numproc << "] Can't load shared library : " << absolute_impl_name);
INFOS("[" << _numproc << "] error dlopen: " << dlerror());
Engines::MPIObject_ptr pcptr;
Engines::MPIObject_ptr spcptr;
- pthread_t *th;
+ pthread_t *th = 0;
if(_numproc == 0){
pcptr = (Engines::MPIObject_ptr)component_i;
th = new pthread_t[_nbproc];
void Engines_MPIContainer_i::finalize_removal()
{
- pthread_t *th;
+ pthread_t *th = 0;
if(_numproc == 0){
th = new pthread_t[_nbproc];
for(int ip=1;ip<_nbproc;ip++){