summaryrefslogtreecommitdiff
path: root/cpp/src/IceUtil
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2005-09-22 14:01:13 +0000
committerBernard Normier <bernard@zeroc.com>2005-09-22 14:01:13 +0000
commit1fe509c0c26b31ee654dda17be99205362024f68 (patch)
treef0248f6827bece2662cc4899071c52b289c6b85a /cpp/src/IceUtil
parentFix (diff)
downloadice-1fe509c0c26b31ee654dda17be99205362024f68.tar.bz2
ice-1fe509c0c26b31ee654dda17be99205362024f68.tar.xz
ice-1fe509c0c26b31ee654dda17be99205362024f68.zip
Ported IceUtil to VS 2005 Beta 2 x64
Diffstat (limited to 'cpp/src/IceUtil')
-rw-r--r--cpp/src/IceUtil/Base64.cpp18
-rw-r--r--cpp/src/IceUtil/InputUtil.cpp6
-rw-r--r--cpp/src/IceUtil/Thread.cpp11
-rw-r--r--cpp/src/IceUtil/Time.cpp9
-rw-r--r--cpp/src/IceUtil/Unicode.cpp21
5 files changed, 44 insertions, 21 deletions
diff --git a/cpp/src/IceUtil/Base64.cpp b/cpp/src/IceUtil/Base64.cpp
index d8883f2389f..da1001251a9 100644
--- a/cpp/src/IceUtil/Base64.cpp
+++ b/cpp/src/IceUtil/Base64.cpp
@@ -23,9 +23,9 @@ IceUtil::Base64::encode(const vector<unsigned char>& plainSeq)
}
// Reserve enough space for the returned base64 string
- unsigned long base64Bytes = (((plainSeq.size() * 4) / 3) + 1);
- unsigned long newlineBytes = (((base64Bytes * 2) / 76) + 1);
- unsigned long totalBytes = base64Bytes + newlineBytes;
+ size_t base64Bytes = (((plainSeq.size() * 4) / 3) + 1);
+ size_t newlineBytes = (((base64Bytes * 2) / 76) + 1);
+ size_t totalBytes = base64Bytes + newlineBytes;
retval.reserve(totalBytes);
@@ -37,7 +37,7 @@ IceUtil::Base64::encode(const vector<unsigned char>& plainSeq)
unsigned char by6 = 0;
unsigned char by7 = 0;
- for(unsigned long i = 0; i < plainSeq.size(); i += 3)
+ for(size_t i = 0; i < plainSeq.size(); i += 3)
{
by1 = plainSeq[i];
by2 = 0;
@@ -103,7 +103,7 @@ IceUtil::Base64::decode(const string& str)
newStr.reserve(str.length());
- for(unsigned long j = 0; j < str.length(); j++)
+ for(size_t j = 0; j < str.length(); j++)
{
if(isBase64(str[j]))
{
@@ -120,11 +120,11 @@ IceUtil::Base64::decode(const string& str)
// Note: This is how we were previously computing the size of the return
// sequence. The method below is more efficient (and correct).
- // unsigned long lines = str.size() / 78;
- // unsigned long totalBytes = (lines * 76) + (((str.size() - (lines * 78)) * 3) / 4);
+ // size_t lines = str.size() / 78;
+ // size_t totalBytes = (lines * 76) + (((str.size() - (lines * 78)) * 3) / 4);
// Figure out how long the final sequence is going to be.
- unsigned long totalBytes = (newStr.size() * 3 / 4) + 1;
+ size_t totalBytes = (newStr.size() * 3 / 4) + 1;
retval.reserve(totalBytes);
@@ -135,7 +135,7 @@ IceUtil::Base64::decode(const string& str)
char c1, c2, c3, c4;
- for(unsigned long i = 0; i < newStr.length(); i += 4)
+ for(size_t i = 0; i < newStr.length(); i += 4)
{
c1 = 'A';
c2 = 'A';
diff --git a/cpp/src/IceUtil/InputUtil.cpp b/cpp/src/IceUtil/InputUtil.cpp
index 4e0a6f59e88..f554acea2eb 100644
--- a/cpp/src/IceUtil/InputUtil.cpp
+++ b/cpp/src/IceUtil/InputUtil.cpp
@@ -175,14 +175,14 @@ strToInt64Impl(const char* s, char** endptr, int base)
Int64
strToInt64(const char* s, char** endptr, int base)
{
-#if defined(_WIN32)
+#if defined(ICE_64)
+ return strtol(s, endptr, base);
+#elif defined(_WIN32)
# if defined(_MSC_VER) && (_MSC_VER < 1300)
return strToInt64Impl(s, endptr, base);
# else
return _strtoi64(s, endptr, base);
# endif
-#elif defined(ICE_64)
- return strtol(s, endptr, base);
#elif defined(__hpux)
return __strtoll(s, endptr, base);
#else
diff --git a/cpp/src/IceUtil/Thread.cpp b/cpp/src/IceUtil/Thread.cpp
index 38b113382a0..65e1886a7b8 100644
--- a/cpp/src/IceUtil/Thread.cpp
+++ b/cpp/src/IceUtil/Thread.cpp
@@ -168,8 +168,8 @@ IceUtil::Thread::id() const
return _id;
}
-static void*
-startHook(void* arg)
+static unsigned int
+WINAPI startHook(void* arg)
{
try
{
@@ -229,8 +229,11 @@ IceUtil::Thread::start(size_t stackSize)
//
__incRef();
- _handle->handle = (HANDLE)_beginthreadex(
- 0, stackSize, (unsigned int (__stdcall*)(void*))startHook, (LPVOID)this, 0, &_id);
+ _handle->handle =
+ reinterpret_cast<HANDLE>(
+ _beginthreadex(0,
+ static_cast<unsigned int>(stackSize),
+ startHook, this, 0, &_id));
if(_handle->handle == 0)
{
diff --git a/cpp/src/IceUtil/Time.cpp b/cpp/src/IceUtil/Time.cpp
index ebd3f6a56e7..09069e9152e 100644
--- a/cpp/src/IceUtil/Time.cpp
+++ b/cpp/src/IceUtil/Time.cpp
@@ -29,24 +29,25 @@ IceUtil::Time::now()
#ifdef _WIN32
struct _timeb tb;
_ftime(&tb);
- return Time(tb.time * static_cast<Int64>(1000000) + tb.millitm * static_cast<Int64>(1000));
+ return Time(static_cast<Int64>(tb.time) * ICE_INT64(1000000) +
+ tb.millitm * 1000);
#else
struct timeval tv;
gettimeofday(&tv, 0);
- return Time(tv.tv_sec * static_cast<Int64>(1000000) + tv.tv_usec);
+ return Time(tv.tv_sec * ICE_INT64(1000000) + tv.tv_usec);
#endif
}
Time
IceUtil::Time::seconds(Int64 t)
{
- return Time(t * static_cast<Int64>(1000000));
+ return Time(t * ICE_INT64(1000000));
}
Time
IceUtil::Time::milliSeconds(Int64 t)
{
- return Time(t * static_cast<Int64>(1000));
+ return Time(t * ICE_INT64(1000));
}
Time
diff --git a/cpp/src/IceUtil/Unicode.cpp b/cpp/src/IceUtil/Unicode.cpp
index 8fbe1267af5..724139f25bd 100644
--- a/cpp/src/IceUtil/Unicode.cpp
+++ b/cpp/src/IceUtil/Unicode.cpp
@@ -45,6 +45,7 @@ IceUtil::wstringToString(const wstring& str)
result += 0x80 | ((wc>>6) & 0x3f);
result += 0x80 | (wc & 0x3f);
}
+#if SIZEOF_WCHAR_T >= 4
else if(wc < 0x10FFFF)
{
result += 0xf0 | (wc>>18);
@@ -52,6 +53,7 @@ IceUtil::wstringToString(const wstring& str)
result += 0x80 | ((wc>>6) & 0x3f);
result += 0x80 | (wc & 0x3f);
}
+#endif
else
{
return result; // Error, not encodable.
@@ -159,11 +161,13 @@ IceUtil::stringToWstring(const string& str)
//
// See comments in IceUtil/Unicode.h
//
+
+# if _MSC_VER < 1400
string
IceUtil::wstringToString(const basic_string<__wchar_t>& str)
{
assert(sizeof(__wchar_t) == SIZEOF_WCHAR_T);
- return wstringToString(*reinterpret_cast<const wstring*>(&str));
+ return wstringToString(*reinterpret_cast<const wstring*>(&str));
}
basic_string<__wchar_t>
@@ -172,5 +176,20 @@ IceUtil::stringToNativeWstring(const string& str)
assert(sizeof(__wchar_t) == SIZEOF_WCHAR_T);
return reinterpret_cast<basic_string<__wchar_t>& >(stringToWstring(str));
}
+# else
+string
+IceUtil::wstringToString(const basic_string<unsigned short>& str)
+{
+ assert(sizeof(__wchar_t) == SIZEOF_WCHAR_T);
+ return wstringToString(*reinterpret_cast<const wstring*>(&str));
+}
+
+basic_string<unsigned short>
+IceUtil::stringToTypedefWstring(const string& str)
+{
+ assert(sizeof(__wchar_t) == SIZEOF_WCHAR_T);
+ return reinterpret_cast<basic_string<unsigned short>& >(stringToWstring(str));
+}
+# endif
#endif