X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/9dae56ea45a0f5f8136a5c93d6f3a7f99399ca73..4e4e5a6f2694187498445a6ac6f1634ce8141119:/wtf/RandomNumberSeed.h diff --git a/wtf/RandomNumberSeed.h b/wtf/RandomNumberSeed.h index f994fd9..ae414c0 100644 --- a/wtf/RandomNumberSeed.h +++ b/wtf/RandomNumberSeed.h @@ -33,21 +33,38 @@ #include #endif -#if PLATFORM(UNIX) +#if OS(UNIX) #include #include #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(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);