summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.mak24
-rw-r--r--cpp/include/IceUtil/Random.h2
-rw-r--r--cpp/src/IceGrid/ObjectCache.cpp2
-rw-r--r--cpp/src/IceGrid/ObjectCache.h2
-rw-r--r--cpp/src/IceUtil/Random.cpp36
5 files changed, 46 insertions, 20 deletions
diff --git a/Makefile.mak b/Makefile.mak
index 68579248c81..d5439df5e3a 100644
--- a/Makefile.mak
+++ b/Makefile.mak
@@ -10,19 +10,19 @@
top_srcdir = cpp
!include cpp/config/Make.rules.mak
-SUBDIRS = cpp java py
-CLEAN_SUBDIRS = java py cpp
-DEPEND_SUBDIRS = cpp py
-INSTALL_SUBDIRS = cpp java py
+SUBDIRS = cpp java py php
+CLEAN_SUBDIRS = java py php cpp
+DEPEND_SUBDIRS = cpp py php
+INSTALL_SUBDIRS = cpp java py php
!if "$(CPP_COMPILER)" == "VC60"
-SUBDIRS = $(SUBDIRS) php rb
-CLEAN_SUBDIRS = php rb $(CLEAN_SUBDIRS)
-DEPEND_SUBDIRS = $(DEPEND_SUBDIRS) php rb
-INSTALL_SUBDIRS = $(INSTALL_SUBDIRS) php rb
+SUBDIRS = $(SUBDIRS) rb
+CLEAN_SUBDIRS = rb $(CLEAN_SUBDIRS)
+DEPEND_SUBDIRS = $(DEPEND_SUBDIRS) rb
+INSTALL_SUBDIRS = $(INSTALL_SUBDIRS) rb
!else
-SUBDIRS = $(SUBDIRS) cs vb
-CLEAN_SUBDIRS = cs vb $(CLEAN_SUBDIRS)
+SUBDIRS = $(SUBDIRS) cs vb vsplugin
+CLEAN_SUBDIRS = cs vb vsplugin $(CLEAN_SUBDIRS)
DEPEND_SUBDIRS = $(DEPEND_SUBDIRS) cs vb
INSTALL_SUBDIRS = $(INSTALL_SUBDIRS) cs
!endif
@@ -74,3 +74,7 @@ rb::
php::
@echo "making all in php" && \
cmd /c "cd php && $(MAKE) -nologo -f Makefile.mak $(MAKEFLAGS) all" || exit 1
+
+vsplugin::
+ @echo "making all in vsplugin" && \
+ cmd /c "cd vsplugin && $(MAKE) -nologo -f Makefile.mak $(MAKEFLAGS) all" || exit 1
diff --git a/cpp/include/IceUtil/Random.h b/cpp/include/IceUtil/Random.h
index f2057ddcf75..7ee965c50ce 100644
--- a/cpp/include/IceUtil/Random.h
+++ b/cpp/include/IceUtil/Random.h
@@ -17,7 +17,7 @@ namespace IceUtilInternal
{
ICE_UTIL_API void generateRandom(char*, int);
-ICE_UTIL_API int random(int = 0);
+ICE_UTIL_API unsigned int random(int = 0);
}
diff --git a/cpp/src/IceGrid/ObjectCache.cpp b/cpp/src/IceGrid/ObjectCache.cpp
index 790c52af2ad..83a2a086695 100644
--- a/cpp/src/IceGrid/ObjectCache.cpp
+++ b/cpp/src/IceGrid/ObjectCache.cpp
@@ -19,7 +19,7 @@
using namespace std;
using namespace IceGrid;
-pointer_to_unary_function<int, int> ObjectCache::_rand(IceUtilInternal::random);
+pointer_to_unary_function<int, unsigned int> ObjectCache::_rand(IceUtilInternal::random);
namespace IceGrid
{
diff --git a/cpp/src/IceGrid/ObjectCache.h b/cpp/src/IceGrid/ObjectCache.h
index ce6b2ab279a..3e068dcc0ba 100644
--- a/cpp/src/IceGrid/ObjectCache.h
+++ b/cpp/src/IceGrid/ObjectCache.h
@@ -77,7 +77,7 @@ private:
const Ice::CommunicatorPtr _communicator;
std::map<std::string, TypeEntry> _types;
- static std::pointer_to_unary_function<int, int> _rand;
+ static std::pointer_to_unary_function<int, unsigned int> _rand;
};
};
diff --git a/cpp/src/IceUtil/Random.cpp b/cpp/src/IceUtil/Random.cpp
index c9772de3b9a..7afc171c1a2 100644
--- a/cpp/src/IceUtil/Random.cpp
+++ b/cpp/src/IceUtil/Random.cpp
@@ -7,6 +7,10 @@
//
// **********************************************************************
+#if defined(_MSC_VER) && (_MSC_VER > 1400)
+# define _CRT_RAND_S
+#endif
+
#include <IceUtil/Random.h>
#include <IceUtil/Mutex.h>
#include <IceUtil/MutexPtrLock.h>
@@ -21,6 +25,7 @@
using namespace std;
using namespace IceUtil;
+#if !defined(_WIN32) || !defined(_MSC_VER) || (_MSC_VER < 1400)
namespace
{
@@ -76,11 +81,19 @@ public:
Init init;
}
+#endif
void
IceUtilInternal::generateRandom(char* buffer, int size)
{
#ifdef _WIN32
+
+# if defined(_MSC_VER) && (_MSC_VER >= 1400)
+ for(int i = 0; i < size; ++i)
+ {
+ buffer[i] = random(256);
+ }
+# else
//
// It's not clear from the Microsoft documentation if CryptGenRandom
// can be called concurrently from several threads. To be on the safe
@@ -101,6 +114,8 @@ IceUtilInternal::generateRandom(char* buffer, int size)
{
throw SyscallException(__FILE__, __LINE__, GetLastError());
}
+# endif
+
#else
//
@@ -149,18 +164,25 @@ IceUtilInternal::generateRandom(char* buffer, int size)
#endif
}
-int
+unsigned int
IceUtilInternal::random(int limit)
{
- int r;
- generateRandom(reinterpret_cast<char*>(&r), static_cast<int>(sizeof(int)));
- if(limit > 0)
+ unsigned int r;
+#if defined(_MSC_VER) && (_MSC_VER > 1400)
+ errno_t err;
+ if(err = rand_s(&r) != 0)
{
- r = r % limit;
+ SyscallException ex(__FILE__, __LINE__, errno);
+ cerr << "rand_s failed:\n" << ex << endl;
+ assert(0);
+ throw ex;
}
- if(r < 0)
+#else
+ generateRandom(reinterpret_cast<char*>(&r), static_cast<unsigned int>(sizeof(unsigned int)));
+#endif
+ if(limit > 0)
{
- r = -r;
+ r = r % limit;
}
return r;
}