From fb22c7350df80e04399cad7a2a6d60d713cad7f1 Mon Sep 17 00:00:00 2001 From: vsr Date: Fri, 20 Jan 2017 15:54:32 +0300 Subject: [PATCH] Patch for MacOS (from SALOME forum) --- src/bases/DynLibLoaderGNU.cxx | 4 ++++ src/bases/chrono.cxx | 10 +++++----- src/bases/chrono.hxx | 8 ++++---- src/pmml/Test/BasicMainTest.hxx | 6 +++--- src/runtime/CppContainer.cxx | 4 ++++ src/runtime/RuntimeSALOME.cxx | 4 ++-- src/runtime/RuntimeSALOME.hxx | 2 ++ src/runtime/XMLNode.cxx | 3 +++ src/yacsloader/driver.cxx | 14 +++++++------- src/yacsloader/pmml/BasicMainTest.hxx | 6 +++--- 10 files changed, 37 insertions(+), 24 deletions(-) diff --git a/src/bases/DynLibLoaderGNU.cxx b/src/bases/DynLibLoaderGNU.cxx index e62213886..b3e607209 100644 --- a/src/bases/DynLibLoaderGNU.cxx +++ b/src/bases/DynLibLoaderGNU.cxx @@ -24,7 +24,11 @@ using namespace YACS::BASES; +#if defined(__APPLE__) +const char DynLibLoaderGNU::_extForDynLib[]=".dylib"; +#else const char DynLibLoaderGNU::_extForDynLib[]=".so"; +#endif DynLibLoaderGNU::DynLibLoaderGNU(const std::string& libNameWithoutExtension):_libName(libNameWithoutExtension), _handleOnLoadedLib(0) diff --git a/src/bases/chrono.cxx b/src/bases/chrono.cxx index 5bceee79c..7182b35b9 100644 --- a/src/bases/chrono.cxx +++ b/src/bases/chrono.cxx @@ -62,20 +62,20 @@ void counters::stats() -chrono::chrono(int i) : _ctr(i), _run(true) +salome_chrono::salome_chrono(int i) : _ctr(i), _run(true) { - //DEBTRACE("chrono::chrono " << _ctr << " " << _run); + //DEBTRACE("salome_chrono::salome_chrono " << _ctr << " " << _run); _start = clock(); } -chrono::~chrono() +salome_chrono::~salome_chrono() { if (_run) stop(); } -void chrono::stop() +void salome_chrono::stop() { - //DEBTRACE("chrono::stop " << _ctr << " " << _run); + //DEBTRACE("salome_chrono::stop " << _ctr << " " << _run); if (_run) { _run = false; diff --git a/src/bases/chrono.hxx b/src/bases/chrono.hxx index e16fb3ec3..9f6e8f4da 100644 --- a/src/bases/chrono.hxx +++ b/src/bases/chrono.hxx @@ -50,11 +50,11 @@ protected: int _nbChrono; }; -class YACSBASES_EXPORT chrono +class YACSBASES_EXPORT salome_chrono { public: - chrono(int i); - ~chrono(); + salome_chrono(int i); + ~salome_chrono(); void stop(); protected: bool _run; @@ -79,7 +79,7 @@ static timeval tv; #ifdef CHRONODEF #define CHRONO(i) counters::_ctrs[i]._ctrNames = (char *)__FILE__; \ counters::_ctrs[i]._ctrLines = __LINE__; \ - chrono aChrono##i(i); + salome_chrono aChrono##i(i); #define CHRONOSTOP(i) aChrono##i.stop(); diff --git a/src/pmml/Test/BasicMainTest.hxx b/src/pmml/Test/BasicMainTest.hxx index cf007a4b3..0ab9abe3f 100755 --- a/src/pmml/Test/BasicMainTest.hxx +++ b/src/pmml/Test/BasicMainTest.hxx @@ -32,7 +32,7 @@ #include #include -#ifndef WIN32 +#if !defined WIN32 && !defined __APPLE__ #include #endif @@ -45,7 +45,7 @@ int main(int argc, char* argv[]) { -#ifndef WIN32 +#if !defined WIN32 && !defined __APPLE__ fpu_control_t cw = _FPU_DEFAULT & ~(_FPU_MASK_IM | _FPU_MASK_ZM | _FPU_MASK_OM); _FPU_SETCW(cw); #endif @@ -57,7 +57,7 @@ int main(int argc, char* argv[]) controller.addListener( &result ); // --- Add a listener that print dots as test run. -#ifdef WIN32 +#if !defined WIN32 && !defined __APPLE__ CPPUNIT_NS::TextTestProgressListener progress; #else CPPUNIT_NS::BriefTestProgressListener progress; diff --git a/src/runtime/CppContainer.cxx b/src/runtime/CppContainer.cxx index af5aec92a..d3e8b5015 100644 --- a/src/runtime/CppContainer.cxx +++ b/src/runtime/CppContainer.cxx @@ -324,7 +324,11 @@ LocalLibrary LocalContainer::loadComponentLibrary(const std::string & aCompName } #ifndef WIN32 +#ifdef __APPLE__ + std::string impl_name = std::string ("lib") + aCompName + std::string("Local.dylib"); +#else std::string impl_name = std::string ("lib") + aCompName + std::string("Local.so"); +#endif if(sprefix != "") impl_name = sprefix + std::string("/") + impl_name; #else diff --git a/src/runtime/RuntimeSALOME.cxx b/src/runtime/RuntimeSALOME.cxx index 7fbeb28d3..31985cf2f 100644 --- a/src/runtime/RuntimeSALOME.cxx +++ b/src/runtime/RuntimeSALOME.cxx @@ -139,8 +139,8 @@ void RuntimeSALOME::setRuntime(long flags, int argc, char* argv[]) // singleton RuntimeSALOME* YACS::ENGINE::getSALOMERuntime() { - YASSERT(Runtime::_singleton); - return dynamic_cast< RuntimeSALOME* >(Runtime::_singleton); + YASSERT(RuntimeSALOME::getSingleton()); + return dynamic_cast< RuntimeSALOME* >(RuntimeSALOME::getSingleton()); } /** diff --git a/src/runtime/RuntimeSALOME.hxx b/src/runtime/RuntimeSALOME.hxx index c34b9594a..d9ba31c23 100644 --- a/src/runtime/RuntimeSALOME.hxx +++ b/src/runtime/RuntimeSALOME.hxx @@ -74,6 +74,8 @@ namespace YACS class YACSRUNTIMESALOME_EXPORT RuntimeSALOME: public Runtime { + static Runtime* getSingleton() { return Runtime::_singleton; } + public: enum diff --git a/src/runtime/XMLNode.cxx b/src/runtime/XMLNode.cxx index b562d2610..856df28e4 100644 --- a/src/runtime/XMLNode.cxx +++ b/src/runtime/XMLNode.cxx @@ -37,6 +37,9 @@ #include #define chmod _chmod #endif +#ifdef __APPLE__ +#include // for mkdtemp +#endif //#define _DEVDEBUG_ #include "YacsTrace.hxx" diff --git a/src/yacsloader/driver.cxx b/src/yacsloader/driver.cxx index 7d377c8cc..2a898e860 100644 --- a/src/yacsloader/driver.cxx +++ b/src/yacsloader/driver.cxx @@ -41,7 +41,7 @@ #include #include -#ifdef WIN32 +#if defined WIN32 || defined __APPLE__ #else #include #endif @@ -58,7 +58,7 @@ const char *argp_program_bug_address =""; static char doc[] ="driver -- a SALOME YACS graph executor"; static char args_doc[] = "graph.xml"; -#ifdef WIN32 +#if defined WIN32 || defined __APPLE__ #else static struct argp_option options[] = { @@ -157,14 +157,14 @@ void UnLoadObserversPluginIfAny() #endif } -#ifdef WIN32 +#if defined WIN32 || defined __APPLE__ static int #else static error_t #endif parse_opt (int key, char *arg, struct argp_state *state) { -#ifdef WIN32 +#if defined WIN32 || defined __APPLE__ #else // Get the input argument from argp_parse, which we // know is a pointer to our arguments structure. @@ -242,14 +242,14 @@ parse_opt (int key, char *arg, struct argp_state *state) } // Our argp parser. -#ifdef WIN32 +#if defined WIN32 || defined __APPLE__ #else static struct argp argp = { options, parse_opt, args_doc, doc }; #endif void timer(std::string msg) { -#ifdef WIN32 +#if defined WIN32 || defined __APPLE__ #else struct timeval tv; gettimeofday(&tv,NULL); @@ -367,7 +367,7 @@ int main (int argc, char* argv[]) myArgs.init_ports.clear(); // Parse our arguments; every option seen by parse_opt will be reflected in arguments. -#ifdef WIN32 +#if defined WIN32 || defined __APPLE__ #else argp_parse (&argp, argc, argv, 0, 0, &myArgs); std::cerr << "graph = " << myArgs.args[0]; diff --git a/src/yacsloader/pmml/BasicMainTest.hxx b/src/yacsloader/pmml/BasicMainTest.hxx index cf007a4b3..26038678c 100755 --- a/src/yacsloader/pmml/BasicMainTest.hxx +++ b/src/yacsloader/pmml/BasicMainTest.hxx @@ -32,7 +32,7 @@ #include #include -#ifndef WIN32 +#if !defined WIN32 && !defined __APPLE__ #include #endif @@ -45,7 +45,7 @@ int main(int argc, char* argv[]) { -#ifndef WIN32 +#if !defined WIN32 && !defined __APPLE__ fpu_control_t cw = _FPU_DEFAULT & ~(_FPU_MASK_IM | _FPU_MASK_ZM | _FPU_MASK_OM); _FPU_SETCW(cw); #endif @@ -57,7 +57,7 @@ int main(int argc, char* argv[]) controller.addListener( &result ); // --- Add a listener that print dots as test run. -#ifdef WIN32 +#if defined WIN32 || defined __APPLE__ CPPUNIT_NS::TextTestProgressListener progress; #else CPPUNIT_NS::BriefTestProgressListener progress; -- 2.39.2