From 03e9a53d5d2cde4b5c80c8f6258f31cc1f82d222 Mon Sep 17 00:00:00 2001 From: Dwayne Boone Date: Tue, 10 Nov 2009 12:32:48 -0330 Subject: Make GCC supported compiler on Sun --- cpp/src/Ice/Makefile | 2 +- cpp/src/Ice/Network.cpp | 39 ++++++++++++++++++++++++++++++++++----- cpp/src/Ice/Selector.cpp | 2 +- cpp/src/IcePatch2Lib/Util.cpp | 4 ++-- cpp/src/IceSSL/Certificate.cpp | 10 +++++----- cpp/src/IceUtil/Exception.cpp | 8 ++++---- 6 files changed, 47 insertions(+), 18 deletions(-) (limited to 'cpp/src') diff --git a/cpp/src/Ice/Makefile b/cpp/src/Ice/Makefile index 08e5e6749ef..03978520aa1 100644 --- a/cpp/src/Ice/Makefile +++ b/cpp/src/Ice/Makefile @@ -156,7 +156,7 @@ include $(top_srcdir)/config/Make.rules CPPFLAGS := -I.. $(CPPFLAGS) -DICE_API_EXPORTS $(BZIP2_FLAGS) SLICE2CPPFLAGS := --ice --include-dir Ice --dll-export ICE_API $(SLICE2CPPFLAGS) -LINKWITH := -lIceUtil $(BZIP2_LIBS) $(ICE_OS_LIBS) +LINKWITH := -lIceUtil $(BZIP2_LIBS) $(ICONV_LIBS) $(ICE_OS_LIBS) $(libdir)/$(LIBFILENAME): $(OBJS) rm -f $@ diff --git a/cpp/src/Ice/Network.cpp b/cpp/src/Ice/Network.cpp index 089e275f49d..ee60a34585f 100644 --- a/cpp/src/Ice/Network.cpp +++ b/cpp/src/Ice/Network.cpp @@ -51,7 +51,7 @@ using namespace std; using namespace Ice; using namespace IceInternal; -#ifdef __sun +#if defined(__sun) && !defined(__GNUC__) # define INADDR_NONE (in_addr_t)0xffffffff #endif @@ -238,22 +238,51 @@ getLocalAddresses(ProtocolSupport protocol) { if(!(ifr[i].ifr_flags & IFF_LOOPBACK)) // Don't include loopback interface addresses { + // + // On Solaris the above Loopback check does not always work so we double + // check the address below. Solaris also returns duplicate entries that need + // to be filtered out. + // if(ifr[i].ifr_addr.sa_family == AF_INET && protocol != EnableIPv6) { sockaddr_storage addr; memcpy(&addr, &ifr[i].ifr_addr, sizeof(sockaddr_in)); - if(reinterpret_cast(&addr)->sin_addr.s_addr != 0) + struct in_addr* inaddr = &reinterpret_cast(&addr)->sin_addr; + if(inaddr->s_addr != 0 && inaddr->s_addr != htonl(INADDR_LOOPBACK)) { - result.push_back(addr); + unsigned int j; + for(j = 0; j < result.size(); ++j) + { + if(compareAddress(addr, result[j]) == 0) + { + break; + } + } + if(j == result.size()) + { + result.push_back(addr); + } } } else if(ifr[i].ifr_addr.sa_family == AF_INET6 && protocol != EnableIPv4) { sockaddr_storage addr; memcpy(&addr, &ifr[i].ifr_addr, sizeof(sockaddr_in6)); - if(!IN6_IS_ADDR_UNSPECIFIED(&reinterpret_cast(&addr)->sin6_addr)) + struct in6_addr* inaddr6 = &reinterpret_cast(&addr)->sin6_addr; + if(!IN6_IS_ADDR_UNSPECIFIED(inaddr6) && !IN6_IS_ADDR_LOOPBACK(inaddr6)) { - result.push_back(addr); + unsigned int j; + for(j = 0; j < result.size(); ++j) + { + if(compareAddress(addr, result[j]) == 0) + { + break; + } + } + if(j == result.size()) + { + result.push_back(addr); + } } } } diff --git a/cpp/src/Ice/Selector.cpp b/cpp/src/Ice/Selector.cpp index 471b4d686d5..3344ef96245 100644 --- a/cpp/src/Ice/Selector.cpp +++ b/cpp/src/Ice/Selector.cpp @@ -612,7 +612,7 @@ Selector::select(vector >& handlers, int ti { Ice::SocketException ex(__FILE__, __LINE__, IceInternal::getSocketErrno()); - Error out(_instance->initializationData().logger); + Ice::Error out(_instance->initializationData().logger); out << "fatal error: selector failed:\n" << ex; } abort(); diff --git a/cpp/src/IcePatch2Lib/Util.cpp b/cpp/src/IcePatch2Lib/Util.cpp index ca2510a119c..e8699073978 100644 --- a/cpp/src/IcePatch2Lib/Util.cpp +++ b/cpp/src/IcePatch2Lib/Util.cpp @@ -44,7 +44,7 @@ const char* IcePatch2::logFile = "IcePatch2.log"; // #ifdef __sun -extern "C" static int +extern "C" int ice_scandir(const char* dir, struct dirent*** namelist, int (*select)(const struct dirent*), int (*compar)(const void*, const void*)) @@ -101,7 +101,7 @@ ice_scandir(const char* dir, struct dirent*** namelist, return i; } -extern "C" static int +extern "C" int ice_alphasort(const void* v1, const void* v2) { const struct dirent **a = (const struct dirent **)v1; diff --git a/cpp/src/IceSSL/Certificate.cpp b/cpp/src/IceSSL/Certificate.cpp index 6d942d49103..696be65683b 100644 --- a/cpp/src/IceSSL/Certificate.cpp +++ b/cpp/src/IceSSL/Certificate.cpp @@ -85,7 +85,7 @@ CertificateEncodingException::ice_throw() const namespace { -IceUtil::Mutex* mutex = 0; +IceUtil::Mutex* mut = 0; class Init { @@ -93,13 +93,13 @@ public: Init() { - mutex = new IceUtil::Mutex; + mut = new IceUtil::Mutex; } ~Init() { - delete mutex; - mutex = 0; + delete mut; + mut = 0; } }; @@ -146,7 +146,7 @@ ASMUtcTimeToIceUtilTime(const ASN1_UTCTIME* s) // time_t tzone; { - IceUtilInternal::MutexPtrLock sync(mutex); + IceUtilInternal::MutexPtrLock sync(mut); time_t now = time(0); tzone = mktime(localtime(&now)) - mktime(gmtime(&now)); } diff --git a/cpp/src/IceUtil/Exception.cpp b/cpp/src/IceUtil/Exception.cpp index f3e2cc9b750..6ce81a17c23 100644 --- a/cpp/src/IceUtil/Exception.cpp +++ b/cpp/src/IceUtil/Exception.cpp @@ -14,7 +14,7 @@ #include #include -#ifdef __GNUC__ +#if defined(__GNUC__) && !defined(__sun) # include # include #endif @@ -52,7 +52,7 @@ public: Init init; -#ifdef __GNUC__ +#if defined(__GNUC__) && !defined(__sun) string getStackTrace() { @@ -183,7 +183,7 @@ getStackTrace() IceUtil::Exception::Exception() : _file(0), _line(0) -#ifdef __GNUC__ +#if defined(__GNUC__) && !defined(__sun) , _stackTrace(getStackTrace()) #endif { @@ -192,7 +192,7 @@ IceUtil::Exception::Exception() : IceUtil::Exception::Exception(const char* file, int line) : _file(file), _line(line) -#ifdef __GNUC__ +#if defined(__GNUC__) && !defined(__sun) , _stackTrace(getStackTrace()) #endif { -- cgit v1.2.3