diff options
author | Benoit Foucher <benoit@zeroc.com> | 2004-02-10 23:18:16 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2004-02-10 23:18:16 +0000 |
commit | 61e07f2c8b2110b405e47c8bdc94095e0d754042 (patch) | |
tree | 14a31ba3bfc89b806c81f92f388276f467b46e62 /cpp/src | |
parent | Fixed Win32 build (_win9x -> win9x()) (diff) | |
download | ice-61e07f2c8b2110b405e47c8bdc94095e0d754042.tar.bz2 ice-61e07f2c8b2110b405e47c8bdc94095e0d754042.tar.xz ice-61e07f2c8b2110b405e47c8bdc94095e0d754042.zip |
MacOS X port.
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Freeze/Makefile | 1 | ||||
-rw-r--r-- | cpp/src/FreezeScript/Grammar.y | 1 | ||||
-rw-r--r-- | cpp/src/FreezeScript/Makefile | 1 | ||||
-rw-r--r-- | cpp/src/Glacier/Makefile | 1 | ||||
-rw-r--r-- | cpp/src/Ice/DynamicLibrary.cpp | 7 | ||||
-rw-r--r-- | cpp/src/Ice/FactoryTableDef.cpp | 48 | ||||
-rw-r--r-- | cpp/src/Ice/Makefile | 2 | ||||
-rw-r--r-- | cpp/src/IceBox/Makefile | 3 | ||||
-rw-r--r-- | cpp/src/IcePack/Makefile | 3 | ||||
-rw-r--r-- | cpp/src/IcePatch/Makefile | 2 | ||||
-rw-r--r-- | cpp/src/IceSSL/Makefile | 2 | ||||
-rw-r--r-- | cpp/src/IceSSL/OpenSSLPluginI.cpp | 2 | ||||
-rw-r--r-- | cpp/src/IceStorm/Makefile | 1 | ||||
-rw-r--r-- | cpp/src/IceUtil/CtrlCHandler.cpp | 22 | ||||
-rw-r--r-- | cpp/src/IceUtil/Thread.cpp | 11 | ||||
-rw-r--r-- | cpp/src/IceXML/Makefile | 2 | ||||
-rw-r--r-- | cpp/src/Slice/Grammar.y | 1 | ||||
-rw-r--r-- | cpp/src/Slice/Makefile | 2 | ||||
-rw-r--r-- | cpp/src/icecpp/config.h | 4 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 18 |
20 files changed, 119 insertions, 15 deletions
diff --git a/cpp/src/Freeze/Makefile b/cpp/src/Freeze/Makefile index ff9d5d34791..514bc6d3972 100644 --- a/cpp/src/Freeze/Makefile +++ b/cpp/src/Freeze/Makefile @@ -59,6 +59,7 @@ include $(top_srcdir)/config/Make.rules CPPFLAGS := -I.. $(CPPFLAGS) -DFREEZE_API_EXPORTS $(DB_FLAGS) SLICE2CPPFLAGS := --ice --include-dir Freeze --dll-export FREEZE_API $(SLICE2CPPFLAGS) +LINKWITH := -lIce -lIceUtil $(DB_LIBS) $(libdir)/$(LIBFILENAME): $(OBJS) rm -f $@ diff --git a/cpp/src/FreezeScript/Grammar.y b/cpp/src/FreezeScript/Grammar.y index 225be134a29..9793fc73008 100644 --- a/cpp/src/FreezeScript/Grammar.y +++ b/cpp/src/FreezeScript/Grammar.y @@ -46,7 +46,6 @@ freeze_script_error(const char* s) %} %pure_parser -%name_prefix="freeze_script_" %token TOK_AND %token TOK_OR diff --git a/cpp/src/FreezeScript/Makefile b/cpp/src/FreezeScript/Makefile index 66da1ecd583..0cd511f5a6d 100644 --- a/cpp/src/FreezeScript/Makefile +++ b/cpp/src/FreezeScript/Makefile @@ -45,6 +45,7 @@ HDIR = $(includedir)/FreezeScript include $(top_srcdir)/config/Make.rules CPPFLAGS := -I.. $(CPPFLAGS) $(DB_FLAGS) +BISONFLAGS := --name-prefix "freeze_script_" $(BISONFLAGS) $(TRANSFORMDB): $(TRANSFORM_OBJS) $(COMMON_OBJS) rm -f $@ diff --git a/cpp/src/Glacier/Makefile b/cpp/src/Glacier/Makefile index d9617a3da30..a75d86806a0 100644 --- a/cpp/src/Glacier/Makefile +++ b/cpp/src/Glacier/Makefile @@ -59,6 +59,7 @@ include $(top_srcdir)/config/Make.rules CPPFLAGS := -I.. $(CPPFLAGS) -DGLACIER_API_EXPORTS $(OPENSSL_FLAGS) SLICE2CPPFLAGS := --include-dir Glacier --dll-export GLACIER_API $(SLICE2CPPFLAGS) +LINKWITH := -lIce -lIceUtil $(libdir)/$(LIBFILENAME): $(OBJS) rm -f $@ diff --git a/cpp/src/Ice/DynamicLibrary.cpp b/cpp/src/Ice/DynamicLibrary.cpp index 31705c32f49..c8f7b013309 100644 --- a/cpp/src/Ice/DynamicLibrary.cpp +++ b/cpp/src/Ice/DynamicLibrary.cpp @@ -92,6 +92,13 @@ IceInternal::DynamicLibrary::loadEntryPoint(const string& entryPoint, bool useIc lib += 'd'; # endif lib += ".dll"; +#elif defined(__APPLE__) + lib = "lib" + libName; + if(!version.empty()) + { + lib += "." + version; + } + lib += ".dylib"; #elif defined(__hpux) lib = "lib" + libName; if(!version.empty()) diff --git a/cpp/src/Ice/FactoryTableDef.cpp b/cpp/src/Ice/FactoryTableDef.cpp index c225ffc57c5..1b1db33163a 100644 --- a/cpp/src/Ice/FactoryTableDef.cpp +++ b/cpp/src/Ice/FactoryTableDef.cpp @@ -15,6 +15,10 @@ #include <Ice/FactoryTableDef.h> #include <Ice/UserExceptionFactory.h> +#ifdef __APPLE__ +# include <dlfcn.h> +#endif + namespace Ice { @@ -52,6 +56,28 @@ Ice::FactoryTableDef::getExceptionFactory(const std::string& t) const { IceUtil::Mutex::Lock lock(_m); EFTable::const_iterator i = _eft.find(t); +#ifdef __APPLE__ + if(i == _eft.end()) + { + lock.release(); + + // + // Try to find the symbol, if found this should trigger the + // object static constructors to be called. + // + std::string symbol = "__F"; + for(std::string::const_iterator p = t.begin(); p != t.end(); ++p) + { + symbol += ((*p) == ':') ? '_' : *p; + } + symbol += "__initializer"; + dlsym(RTLD_DEFAULT, symbol.c_str()); + + lock.acquire(); + + i = _eft.find(t); + } +#endif return i != _eft.end() ? i->second.first : IceInternal::UserExceptionFactoryPtr(); } @@ -101,6 +127,28 @@ Ice::FactoryTableDef::getObjectFactory(const std::string& t) const { IceUtil::Mutex::Lock lock(_m); OFTable::const_iterator i = _oft.find(t); +#ifdef __APPLE__ + if(i == _oft.end()) + { + lock.release(); + + // + // Try to find the symbol, if found this should trigger the + // object static constructors to be called. + // + std::string symbol = "__F"; + for(std::string::const_iterator p = t.begin(); p != t.end(); ++p) + { + symbol += ((*p) == ':') ? '_' : *p; + } + symbol += "__initializer"; + dlsym(RTLD_DEFAULT, symbol.c_str()); + + lock.acquire(); + + i = _oft.find(t); + } +#endif return i != _oft.end() ? i->second.first : ObjectFactoryPtr(); } diff --git a/cpp/src/Ice/Makefile b/cpp/src/Ice/Makefile index 3696fa27d42..7b1ec9d5d62 100644 --- a/cpp/src/Ice/Makefile +++ b/cpp/src/Ice/Makefile @@ -130,7 +130,7 @@ include $(top_srcdir)/config/Make.rules CPPFLAGS := -I.. $(CPPFLAGS) -DICE_API_EXPORTS -DICE_PROTOCOL_API_EXPORTS $(BZIP2_FLAGS) SLICE2CPPFLAGS := --ice --include-dir Ice --dll-export ICE_API $(SLICE2CPPFLAGS) -LINKWITH := $(BZIP2_LIBS) $(ICE_OS_LIBS) +LINKWITH := -lIceUtil $(BZIP2_LIBS) $(ICE_OS_LIBS) $(libdir)/$(LIBFILENAME): $(OBJS) rm -f $@ diff --git a/cpp/src/IceBox/Makefile b/cpp/src/IceBox/Makefile index d3f66c080e8..8526357373e 100644 --- a/cpp/src/IceBox/Makefile +++ b/cpp/src/IceBox/Makefile @@ -46,6 +46,7 @@ include $(top_srcdir)/config/Make.rules CPPFLAGS := -I.. $(CPPFLAGS) -DICE_BOX_API_EXPORTS $(DB_FLAGS) SLICE2CPPFLAGS := --ice --dll-export ICE_BOX_API --include-dir IceBox $(SLICE2CPPFLAGS) +LINKWITH := -lIce -lIceUtil $(libdir)/$(LIBFILENAME): $(OBJS) rm -f $@ @@ -61,7 +62,7 @@ $(libdir)/$(LIBNAME): $(libdir)/$(SONAME) $(SERVER): $(SOBJS) $(libdir)/$(LIBNAME) rm -f $@ - $(CXX) $(LDFLAGS) -o $@ $(SOBJS) -lIceBox -lFreeze $(LIBS) $(DB_LIBS) + $(CXX) $(LDFLAGS) -o $@ $(SOBJS) -lIceBox -lFreeze $(LIBS) $(ADMIN): $(AOBJS) $(libdir)/$(LIBNAME) rm -f $@ diff --git a/cpp/src/IcePack/Makefile b/cpp/src/IcePack/Makefile index b45f8431add..26a027a1a02 100644 --- a/cpp/src/IcePack/Makefile +++ b/cpp/src/IcePack/Makefile @@ -102,8 +102,7 @@ include $(top_srcdir)/config/Make.rules CPPFLAGS := -I.. $(CPPFLAGS) -DICE_PACK_API_EXPORTS $(READLINE_FLAGS) ICECPPFLAGS := -I.. $(ICECPPFLAGS) SLICE2CPPFLAGS := --ice --include-dir IcePack --dll-export ICE_PACK_API $(SLICE2CPPFLAGS) - -LINKWITH := -lIceBox +LINKWITH := -lIceBox -lIce -lIceUtil $(libdir)/$(LIBFILENAME): $(LIB_OBJS) rm -f $@ diff --git a/cpp/src/IcePatch/Makefile b/cpp/src/IcePatch/Makefile index dddaefb2242..b3ba9add2b4 100644 --- a/cpp/src/IcePatch/Makefile +++ b/cpp/src/IcePatch/Makefile @@ -49,7 +49,7 @@ include $(top_srcdir)/config/Make.rules CPPFLAGS := -I.. $(CPPFLAGS) -DICE_PATCH_API_EXPORTS $(OPENSSL_FLAGS) $(BZIP2_FLAGS) SLICE2CPPFLAGS := --ice --include-dir IcePatch --dll-export ICE_PATCH_API $(SLICE2CPPFLAGS) -LINKWITH := $(BZIP2_LIBS) +LINKWITH := -lIce -lIceUtil $(OPENSSL_LIBS) $(BZIP2_LIBS) $(libdir)/$(LIBFILENAME): $(OBJS) rm -f $@ diff --git a/cpp/src/IceSSL/Makefile b/cpp/src/IceSSL/Makefile index 457b3594c3e..a58e932ece5 100644 --- a/cpp/src/IceSSL/Makefile +++ b/cpp/src/IceSSL/Makefile @@ -69,7 +69,7 @@ include $(top_srcdir)/config/Make.rules CPPFLAGS := -I.. $(CPPFLAGS) -DICE_SSL_API_EXPORTS $(OPENSSL_FLAGS) SLICE2CPPFLAGS := --ice --include-dir IceSSL --dll-export ICE_SSL_API $(SLICE2CPPFLAGS) -LINKWITH := -lIceXML $(OPENSSL_LIBS) +LINKWITH := -lIceXML -lIce -lIceUtil $(OPENSSL_LIBS) $(libdir)/$(LIBFILENAME): $(OBJS) rm -f $@ diff --git a/cpp/src/IceSSL/OpenSSLPluginI.cpp b/cpp/src/IceSSL/OpenSSLPluginI.cpp index d9dfcf39c2c..b4cc3d60bac 100644 --- a/cpp/src/IceSSL/OpenSSLPluginI.cpp +++ b/cpp/src/IceSSL/OpenSSLPluginI.cpp @@ -151,7 +151,7 @@ idFunction() { #if defined(_WIN32) return static_cast<unsigned long>(GetCurrentThreadId()); -#elif defined(__FreeBSD__) +#elif defined(__FreeBSD__) || defined(__APPLE__) // // On FreeBSD, pthread_t is a pointer to a per-thread structure // diff --git a/cpp/src/IceStorm/Makefile b/cpp/src/IceStorm/Makefile index fc8c962288c..4ecbdcb6e70 100644 --- a/cpp/src/IceStorm/Makefile +++ b/cpp/src/IceStorm/Makefile @@ -74,6 +74,7 @@ include $(top_srcdir)/config/Make.rules CPPFLAGS := -I.. $(CPPFLAGS) -DICE_STORM_API_EXPORTS $(READLINE_FLAGS) ICECPPFLAGS := -I.. $(ICECPPFLAGS) SLICE2CPPFLAGS := --ice --dll-export ICE_STORM_API --include-dir IceStorm $(SLICE2CPPFLAGS) +LINKWITH := -lFreeze -lIce -lIceUtil $(libdir)/$(LIBFILENAME): $(OBJS) rm -f $@ diff --git a/cpp/src/IceUtil/CtrlCHandler.cpp b/cpp/src/IceUtil/CtrlCHandler.cpp index c54efff40b1..887483df5dc 100644 --- a/cpp/src/IceUtil/CtrlCHandler.cpp +++ b/cpp/src/IceUtil/CtrlCHandler.cpp @@ -125,13 +125,22 @@ sigwaitThread(void*) sigaddset(&ctrlCLikeSignals, SIGHUP); sigaddset(&ctrlCLikeSignals, SIGINT); sigaddset(&ctrlCLikeSignals, SIGTERM); - + + // // Run until I'm cancelled (in sigwait()) // for(;;) { int signal = 0; int rc = sigwait(&ctrlCLikeSignals, &signal); +#if defined(__APPLE__) + // + // WORKAROUND: sigwait is not a cancelation point on MacOS X. To cancel this thread, the + // destructor cancels the thread and send a signal to the thread to unblock sigwait, then + // we explicitly test for cancellation. + // + pthread_testcancel(); +#endif // // Some sigwait() implementations incorrectly return EINTR // when interrupted by an unblocked caught signal @@ -203,11 +212,20 @@ CtrlCHandler::~CtrlCHandler() { int rc = pthread_cancel(_tid); assert(rc == 0); +#if defined(__APPLE__) + // + // WORKAROUND: sigwait isn't a cancellation point on MacOS X, see + // comment in sigwaitThread + // + rc = pthread_kill(_tid, SIGTERM); + assert(rc == 0); +#endif void* status = 0; rc = pthread_join(_tid, &status); assert(rc == 0); +#if !defined(__APPLE__) assert(status == PTHREAD_CANCELED); - +#endif { StaticMutex::Lock lock(globalMutex); _handler = 0; diff --git a/cpp/src/IceUtil/Thread.cpp b/cpp/src/IceUtil/Thread.cpp index ba9506965e5..de1d907a4bc 100644 --- a/cpp/src/IceUtil/Thread.cpp +++ b/cpp/src/IceUtil/Thread.cpp @@ -413,9 +413,18 @@ bool IceUtil::ThreadControl::isAlive() const { int policy; + int ret; struct sched_param param; IceUtil::Mutex::Lock lock(_stateMutex); - return pthread_getschedparam(_id, &policy, ¶m) == 0; + + ret = pthread_getschedparam(_id, &policy, ¶m); +#ifdef __APPLE__ + if (ret == 0) + { + ret = pthread_setschedparam(_id, policy, ¶m); + } +#endif + return (ret == 0); } void diff --git a/cpp/src/IceXML/Makefile b/cpp/src/IceXML/Makefile index 31946509f5f..2913bb662e2 100644 --- a/cpp/src/IceXML/Makefile +++ b/cpp/src/IceXML/Makefile @@ -28,7 +28,7 @@ include $(top_srcdir)/config/Make.rules CPPFLAGS := $(CPPFLAGS) -DICE_XML_API_EXPORTS $(EXPAT_FLAGS) -LINKWITH := $(EXPAT_LIBS) +LINKWITH := -lIceUtil $(EXPAT_LIBS) $(libdir)/$(LIBFILENAME): $(OBJS) rm -f $@ diff --git a/cpp/src/Slice/Grammar.y b/cpp/src/Slice/Grammar.y index 704d6bf698e..44119fede24 100644 --- a/cpp/src/Slice/Grammar.y +++ b/cpp/src/Slice/Grammar.y @@ -47,7 +47,6 @@ slice_error(const char* s) %} %pure_parser -%name_prefix="slice_" // // All keyword tokens. Make sure to modify the "keyword" rule in this diff --git a/cpp/src/Slice/Makefile b/cpp/src/Slice/Makefile index 95c20ea2f1d..68a5b9dc6f0 100644 --- a/cpp/src/Slice/Makefile +++ b/cpp/src/Slice/Makefile @@ -34,6 +34,8 @@ SRCS = $(OBJS:.o=.cpp) include $(top_srcdir)/config/Make.rules CPPFLAGS := -I.. $(CPPFLAGS) -DSLICE_API_EXPORTS +LINKWITH := -lIceUtil +BISONFLAGS := --name-prefix "slice_" $(BISONFLAGS) $(libdir)/$(LIBFILENAME): $(OBJS) rm -f $@ diff --git a/cpp/src/icecpp/config.h b/cpp/src/icecpp/config.h index a78e3151a22..b5be9b4dbdb 100644 --- a/cpp/src/icecpp/config.h +++ b/cpp/src/icecpp/config.h @@ -17,7 +17,7 @@ // configure script from the gcc-2.8.1 distribution. // -#if defined(__linux) || defined(__FreeBSD__) || defined(__sun) || defined(__hpux) +#if defined(__linux) || defined(__FreeBSD__) || defined(__sun) || defined(__hpux) || defined(__APPLE__) # define HAVE_INTTYPES_H 1 # define TIME_WITH_SYS_TIME 1 # define HAVE_BCMP 1 @@ -62,7 +62,7 @@ #if defined(_WIN32) # define WCHAR_TYPE_SIZE 2 #elif (defined(__linux) || defined(__FreeBSD__)) && (defined(__i386) || defined(__x86_64) || defined(__sparc)) \ - || defined (__sun) || defined(__hpux) + || defined (__sun) || defined(__hpux) || defined(__APPLE__) # define WCHAR_TYPE_SIZE 4 #else # error "unsupported operating system or platform" diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 40474e6ba9d..c21bdfc428e 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -509,6 +509,15 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) C << eb; C << eb << ";"; C << sp << nl << "static __F__" << name << "__Init __F__" << name << "__i;"; + C << sp << nl << "#ifdef __APPLE__"; + std::string initfuncname = "__F"; + for(std::string::const_iterator p = scope.begin(); p != scope.end(); ++p) + { + initfuncname += ((*p) == ':') ? '_' : *p; + } + initfuncname += name + "__initializer"; + C << nl << "extern \"C\" { void " << initfuncname << "() {} }"; + C << nl << "#endif"; } H.dec(); @@ -2290,6 +2299,15 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p) C << sp; C << nl << "static " << factoryName << "__Init " << factoryName << "__i;"; + C << sp << nl << "#ifdef __APPLE__"; + std::string initfuncname = "__F"; + for(std::string::const_iterator p = scope.begin(); p != scope.end(); ++p) + { + initfuncname += ((*p) == ':') ? '_' : *p; + } + initfuncname += name + "__initializer"; + C << nl << "extern \"C\" { void " << initfuncname << "() {} }"; + C << nl << "#endif"; } } |