Changeset 77260 in webkit


Ignore:
Timestamp:
Feb 1, 2011 10:50:17 AM (13 years ago)
Author:
dbates@webkit.org
Message:

2011-02-01 Daniel Bates <dbates@rim.com>

Reviewed by Antonio Gomes.

Modify RandomNumberSeed.h to use USE(MERSENNE_TWISTER_19937)
https://bugs.webkit.org/show_bug.cgi?id=53506

Currently, use of the Mersenne Twister pseudorandom number generator
is hardcoded to the Windows CE port. With the passing of bug #53253,
we can generalize support for this PRNG to all ports that use srand(3)
and rand(3), including Windows CE.

  • wtf/RandomNumberSeed.h: (WTF::initializeRandomNumberGenerator):
Location:
trunk/Source/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r77248 r77260  
     12011-02-01  Daniel Bates  <dbates@rim.com>
     2
     3        Reviewed by Antonio Gomes.
     4
     5        Modify RandomNumberSeed.h to use USE(MERSENNE_TWISTER_19937)
     6        https://bugs.webkit.org/show_bug.cgi?id=53506
     7
     8        Currently, use of the Mersenne Twister pseudorandom number generator
     9        is hardcoded to the Windows CE port. With the passing of bug #53253,
     10        we can generalize support for this PRNG to all ports that use srand(3)
     11        and rand(3), including Windows CE.
     12
     13        * wtf/RandomNumberSeed.h:
     14        (WTF::initializeRandomNumberGenerator):
     15
    1162011-02-01  Dave Tapuska  <dtapuska@rim.com>
    217
  • trunk/Source/JavaScriptCore/wtf/RandomNumberSeed.h

    r73177 r77260  
    3939#endif
    4040
    41 #if OS(WINCE)
     41#if USE(MERSENNE_TWISTER_19937)
    4242extern "C" {
    4343void init_by_array(unsigned long init_key[],int key_length);
     
    5555    // initialize rand()
    5656    srand(GetTickCount());
    57 
    58     // use rand() to initialize the real RNG
    59     unsigned long initializationBuffer[4];
    60     initializationBuffer[0] = (rand() << 16) | rand();
    61     initializationBuffer[1] = (rand() << 16) | rand();
    62     initializationBuffer[2] = (rand() << 16) | rand();
    63     initializationBuffer[3] = (rand() << 16) | rand();
    64     init_by_array(initializationBuffer, 4);
    6557#elif COMPILER(MSVC) && defined(_CRT_RAND_S)
    6658    // On Windows we use rand_s which initialises itself
     
    7567    srand(static_cast<unsigned>(time(0)));
    7668#endif
     69
     70#if USE(MERSENNE_TWISTER_19937)
     71    // use rand() to initialize the Mersenne Twister random number generator.
     72    unsigned long initializationBuffer[4];
     73    initializationBuffer[0] = (rand() << 16) | rand();
     74    initializationBuffer[1] = (rand() << 16) | rand();
     75    initializationBuffer[2] = (rand() << 16) | rand();
     76    initializationBuffer[3] = (rand() << 16) | rand();
     77    init_by_array(initializationBuffer, 4);
     78#endif
    7779}
    7880
Note: See TracChangeset for help on using the changeset viewer.