diff options
author | Jose <jose@zeroc.com> | 2012-07-26 17:13:54 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2012-07-26 17:13:54 +0200 |
commit | ad088c09c2a5022eb12dbea4523242e05c5d7bdd (patch) | |
tree | cc69971ee6374439033067c698c5589f978864a7 /cpp/src/IceUtil | |
parent | vsadding - fix for update reverse dependencies (diff) | |
download | ice-ad088c09c2a5022eb12dbea4523242e05c5d7bdd.tar.bz2 ice-ad088c09c2a5022eb12dbea4523242e05c5d7bdd.tar.xz ice-ad088c09c2a5022eb12dbea4523242e05c5d7bdd.zip |
MinGW & Ruby-1.9 updates
Diffstat (limited to 'cpp/src/IceUtil')
-rw-r--r-- | cpp/src/IceUtil/Exception.cpp | 8 | ||||
-rw-r--r-- | cpp/src/IceUtil/FileUtil.cpp | 31 | ||||
-rw-r--r-- | cpp/src/IceUtil/InputUtil.cpp | 8 | ||||
-rw-r--r-- | cpp/src/IceUtil/Makefile | 29 | ||||
-rw-r--r-- | cpp/src/IceUtil/Random.cpp | 8 | ||||
-rw-r--r-- | cpp/src/IceUtil/RecMutex.cpp | 4 | ||||
-rw-r--r-- | cpp/src/IceUtil/Thread.cpp | 2 | ||||
-rw-r--r-- | cpp/src/IceUtil/Time.cpp | 10 |
8 files changed, 77 insertions, 23 deletions
diff --git a/cpp/src/IceUtil/Exception.cpp b/cpp/src/IceUtil/Exception.cpp index 350df152b29..fac85e5e01e 100644 --- a/cpp/src/IceUtil/Exception.cpp +++ b/cpp/src/IceUtil/Exception.cpp @@ -14,7 +14,7 @@ #include <ostream> #include <cstdlib> -#if defined(__GNUC__) && !defined(__sun) && !defined(__FreeBSD__) +#if defined(__GNUC__) && !defined(__sun) && !defined(__FreeBSD__) && !defined(__MINGW32__) # include <execinfo.h> # include <cxxabi.h> #endif @@ -52,7 +52,7 @@ public: Init init; -#if defined(__GNUC__) && !defined(__sun) && !defined(__FreeBSD__) +#if defined(__GNUC__) && !defined(__sun) && !defined(__FreeBSD__) && !defined(__MINGW32__) string getStackTrace() { @@ -183,7 +183,7 @@ getStackTrace() IceUtil::Exception::Exception() : _file(0), _line(0) -#if defined(__GNUC__) && !defined(__sun) && !defined(__FreeBSD__) +#if defined(__GNUC__) && !defined(__sun) && !defined(__FreeBSD__) && !defined(__MINGW32__) , _stackTrace(getStackTrace()) #endif { @@ -192,7 +192,7 @@ IceUtil::Exception::Exception() : IceUtil::Exception::Exception(const char* file, int line) : _file(file), _line(line) -#if defined(__GNUC__) && !defined(__sun) && !defined(__FreeBSD__) +#if defined(__GNUC__) && !defined(__sun) && !defined(__FreeBSD__) && !defined(__MINGW32__) , _stackTrace(getStackTrace()) #endif { diff --git a/cpp/src/IceUtil/FileUtil.cpp b/cpp/src/IceUtil/FileUtil.cpp index 0888ff8281c..b69e8d6b20a 100644 --- a/cpp/src/IceUtil/FileUtil.cpp +++ b/cpp/src/IceUtil/FileUtil.cpp @@ -170,7 +170,7 @@ IceUtilInternal::unlink(const string& path) int IceUtilInternal::close(int fd) { -#if defined(_MSC_VER) && (_MSC_VER >= 1400) +#if defined(_MSC_VER) && (_MSC_VER >= 1400) || defined(__MINGW32__) return _close(fd); #else return ::close(fd); @@ -197,6 +197,12 @@ IceUtilInternal::FileLock::FileLock(const std::string& path) : throw IceUtil::FileLockException(__FILE__, __LINE__, GetLastError(), _path); } +#ifdef __MINGW32__ + if(::LockFile(_fd, 0, 0, 0, 0) == 0) + { + throw IceUtil::FileLockException(__FILE__, __LINE__, GetLastError(), _path); + } +#else OVERLAPPED overlaped; overlaped.Internal = 0; overlaped.InternalHigh = 0; @@ -208,6 +214,7 @@ IceUtilInternal::FileLock::FileLock(const std::string& path) : ::CloseHandle(_fd); throw IceUtil::FileLockException(__FILE__, __LINE__, GetLastError(), _path); } +#endif // // In Windows implementation we don't write the process pid to the file, as is // not posible to read the file from other process while it is locked here. @@ -310,14 +317,23 @@ IceUtilInternal::ifstream::open(const string& path, ios_base::openmode mode) #else -IceUtilInternal::ifstream::ifstream(const string& path, ios_base::openmode mode) : std::ifstream(IceUtil::stringToWstring(path).c_str(), mode) +IceUtilInternal::ifstream::ifstream(const string& path, ios_base::openmode mode) : +#ifdef __MINGW32__ + std::ifstream(path.c_str(), mode) +#else + std::ifstream(IceUtil::stringToWstring(path).c_str(), mode) +#endif { } void IceUtilInternal::ifstream::open(const string& path, ios_base::openmode mode) { +#ifdef __MINGW32__ + std::ifstream::open(path.c_str(), mode); +#else std::ifstream::open(IceUtil::stringToWstring(path).c_str(), mode); +#endif } #endif @@ -371,14 +387,23 @@ IceUtilInternal::ofstream::open(const string& path, ios_base::openmode mode) #else -IceUtilInternal::ofstream::ofstream(const string& path, ios_base::openmode mode) : std::ofstream(IceUtil::stringToWstring(path).c_str(), mode) +IceUtilInternal::ofstream::ofstream(const string& path, ios_base::openmode mode) : +#ifdef __MINGW32__ + std::ofstream(path.c_str(), mode) +#else + std::ofstream(IceUtil::stringToWstring(path).c_str(), mode) +#endif { } void IceUtilInternal::ofstream::open(const string& path, ios_base::openmode mode) { +#ifdef __MINGW32__ + std::ofstream::open(path.c_str(), mode); +#else std::ofstream::open(IceUtil::stringToWstring(path).c_str(), mode); +#endif } #endif diff --git a/cpp/src/IceUtil/InputUtil.cpp b/cpp/src/IceUtil/InputUtil.cpp index 1b29658afbe..8f5edab81f9 100644 --- a/cpp/src/IceUtil/InputUtil.cpp +++ b/cpp/src/IceUtil/InputUtil.cpp @@ -11,7 +11,7 @@ #include <stdlib.h> #include <errno.h> -#if defined(_MSC_VER) && (_MSC_VER < 1300) +#if (defined(_MSC_VER) && (_MSC_VER < 1300) ) || (__MINGW32__) #include <limits.h> #endif @@ -25,7 +25,9 @@ using namespace IceUtil; namespace IceUtilInternal { -#if (defined(_MSC_VER) && (_MSC_VER < 1300)) + +#if defined(__MINGW32__) || (defined(_MSC_VER) && (_MSC_VER < 1300)) + // // The VC60 runtime does not include _strtoi64, so we provide our own implementation // @@ -177,7 +179,7 @@ Int64 strToInt64(const char* s, char** endptr, int base) { #if defined(_WIN32) -# if (defined(_MSC_VER) && (_MSC_VER < 1300)) +# if defined(__MINGW32__) || (defined(_MSC_VER) && (_MSC_VER < 1300)) return strToInt64Impl(s, endptr, base); # else return _strtoi64(s, endptr, base); diff --git a/cpp/src/IceUtil/Makefile b/cpp/src/IceUtil/Makefile index 4fb25718adf..a3e19c0914f 100644 --- a/cpp/src/IceUtil/Makefile +++ b/cpp/src/IceUtil/Makefile @@ -9,11 +9,17 @@ top_srcdir = ../.. -LIBFILENAME = $(call mklibfilename,IceUtil,$(VERSION)) -SONAME = $(call mksoname,IceUtil,$(SOVERSION)) -LIBNAME = $(call mklibname,IceUtil) +include $(top_srcdir)/config/Make.rules.common -TARGETS = $(call mklibtargets,$(libdir)/$(LIBFILENAME),$(libdir)/$(SONAME),$(libdir)/$(LIBNAME)) +ifeq ($(MinGW), yes) + DLLNAME = $(top_srcdir)/bin/iceutil$(COMPSUFFIX)$(SOVERSION)$(LIBSUFFIX).dll + TARGETS = $(DLLNAME) $(LIBNAME) +else + LIBFILENAME = $(call mklibfilename,IceUtil,$(VERSION)) + SONAME = $(call mksoname,IceUtil,$(SOVERSION)) + LIBNAME = $(call mklibname,IceUtil) + TARGETS = $(call mklibtargets,$(libdir)/$(LIBFILENAME),$(libdir)/$(SONAME),$(libdir)/$(LIBNAME)) +endif OBJS = ArgVector.o \ Cond.o \ @@ -21,7 +27,6 @@ OBJS = ArgVector.o \ CountDownLatch.o \ CtrlCHandler.o \ Exception.o \ - FileUtil.o \ InputUtil.o \ Options.o \ OutputUtil.o \ @@ -35,7 +40,8 @@ OBJS = ArgVector.o \ Timer.o \ UUID.o \ Unicode.o \ - MutexProtocol.o + MutexProtocol.o \ + FileUtil.o SRCS = $(OBJS:.o=.cpp) @@ -43,8 +49,15 @@ include $(top_srcdir)/config/Make.rules CPPFLAGS := $(CPPFLAGS) $(ICEUTIL_FLAGS) -DICE_UTIL_API_EXPORTS -I.. -LINKWITH := $(STLPORT_LIBS) $(ICEUTIL_OS_LIBS) +LINKWITH := $(ICEUTIL_OS_LIBS) +ifeq ($(MinGW), yes) +$(DLLNAME): $(OBJS) + $(CXX) -shared $(LDFLAGS) -o $(DLLNAME) $(OBJS) $(LINKWITH) + +install:: all + $(call installprogram,$(DLLNAME),$(install_bindir)) +else ifeq ($(STATICLIBS),yes) $(libdir)/$(LIBNAME): $(OBJS) rm -f $@ @@ -62,9 +75,9 @@ $(libdir)/$(LIBNAME): $(libdir)/$(SONAME) rm -f $@ ln -s $(SONAME) $@ endif - install:: all $(call installlib,$(install_libdir),$(libdir),$(LIBFILENAME),$(SONAME),$(LIBNAME)) +endif include .depend diff --git a/cpp/src/IceUtil/Random.cpp b/cpp/src/IceUtil/Random.cpp index e82a55d93ab..d47d424357f 100644 --- a/cpp/src/IceUtil/Random.cpp +++ b/cpp/src/IceUtil/Random.cpp @@ -44,7 +44,7 @@ namespace // Mutex* staticMutex = 0; #ifdef _WIN32 -HCRYPTPROV context = NULL; +HCRYPTPROV context = 0; #else int fd = -1; #endif @@ -61,10 +61,10 @@ public: ~Init() { #ifdef _WIN32 - if(context != NULL) + if(context != 0) { CryptReleaseContext(context, 0); - context = NULL; + context = 0; } #else if(fd != -1) @@ -102,7 +102,7 @@ IceUtilInternal::generateRandom(char* buffer, int size) // IceUtilInternal::MutexPtrLock<IceUtil::Mutex> lock(staticMutex); - if(context == NULL) + if(context == 0) { if(!CryptAcquireContext(&context, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) { diff --git a/cpp/src/IceUtil/RecMutex.cpp b/cpp/src/IceUtil/RecMutex.cpp index c632f4b7b63..9558a6fed2b 100644 --- a/cpp/src/IceUtil/RecMutex.cpp +++ b/cpp/src/IceUtil/RecMutex.cpp @@ -33,7 +33,11 @@ IceUtil::RecMutex::RecMutex(const IceUtil::MutexProtocol protocol) : void IceUtil::RecMutex::init(const MutexProtocol) { +# ifdef ICE_OS_WINRT InitializeCriticalSectionEx(&_mutex, 0, 0); +# else + InitializeCriticalSection(&_mutex); +# endif } IceUtil::RecMutex::~RecMutex() diff --git a/cpp/src/IceUtil/Thread.cpp b/cpp/src/IceUtil/Thread.cpp index a629586a43b..4c63bd7b0e2 100644 --- a/cpp/src/IceUtil/Thread.cpp +++ b/cpp/src/IceUtil/Thread.cpp @@ -251,7 +251,7 @@ IceUtil::Thread::start(size_t stackSize, int priority) { throw ThreadSyscallException(__FILE__, __LINE__, GetLastError()); } - if(ResumeThread(_handle) == -1) + if(static_cast<int>(ResumeThread(_handle)) == -1) { __decRef(); throw ThreadSyscallException(__FILE__, __LINE__, GetLastError()); diff --git a/cpp/src/IceUtil/Time.cpp b/cpp/src/IceUtil/Time.cpp index 585335191e8..bef48d9ab3d 100644 --- a/cpp/src/IceUtil/Time.cpp +++ b/cpp/src/IceUtil/Time.cpp @@ -95,8 +95,13 @@ IceUtil::Time::now(Clock clock) if(clock == Realtime) { #ifdef _WIN32 +# if defined(_MSC_VER) struct _timeb tb; _ftime(&tb); +# elif defined(__MINGW32__) + struct timeb tb; + ftime(&tb); +# endif return Time(static_cast<Int64>(tb.time) * ICE_INT64(1000000) + tb.millitm * 1000); #else struct timeval tv; @@ -123,8 +128,13 @@ IceUtil::Time::now(Clock clock) } else { +# if defined(_MSC_VER) struct _timeb tb; _ftime(&tb); +# elif defined(__MINGW32__) + struct timeb tb; + ftime(&tb); +# endif return Time(static_cast<Int64>(tb.time) * ICE_INT64(1000000) + tb.millitm * 1000); } #elif defined(__hpux) |