#include <sys/time.h>
#endif
-#if PLATFORM(UNIX)
+#if OS(UNIX)
#include <sys/types.h>
#include <unistd.h>
#endif
+#if OS(WINCE)
+extern "C" {
+void init_by_array(unsigned long init_key[],int key_length);
+}
+#endif
+
// Internal JavaScriptCore usage only
namespace WTF {
inline void initializeRandomNumberGenerator()
{
-#if PLATFORM(DARWIN)
+#if OS(DARWIN)
// On Darwin we use arc4random which initialises itself.
+#elif OS(WINCE)
+ // initialize rand()
+ srand(static_cast<unsigned>(time(0)));
+
+ // use rand() to initialize the real RNG
+ unsigned long initializationBuffer[4];
+ initializationBuffer[0] = (rand() << 16) | rand();
+ initializationBuffer[1] = (rand() << 16) | rand();
+ initializationBuffer[2] = (rand() << 16) | rand();
+ initializationBuffer[3] = (rand() << 16) | rand();
+ init_by_array(initializationBuffer, 4);
#elif COMPILER(MSVC) && defined(_CRT_RAND_S)
- // On Windows we use rand_s which intialises itself
-#elif PLATFORM(UNIX)
+ // On Windows we use rand_s which initialises itself
+#elif OS(UNIX)
// srandomdev is not guaranteed to exist on linux so we use this poor seed, this should be improved
timeval time;
gettimeofday(&time, 0);