Ignore:
Timestamp:
Dec 16, 2008, 1:15:22 PM (16 years ago)
Author:
Nikolas Zimmermann
Message:

Reviewed by Darin Adler.

Fixes: https://bugs.webkit.org/show_bug.cgi?id=22876

Unify random number generation in JavaScriptCore & WebCore, by introducing
wtf/RandomNumber.h and moving wtf_random/wtf_random_init out of MathExtras.h.

wtf_random_init() has been renamed to initializeRandomNumberGenerator() and
lives in it's own private header: wtf/RandomNumberSeed.h, only intended to
be used from within JavaScriptCore.

wtf_random() has been renamed to randomNumber() and lives in a public header
wtf/RandomNumber.h, usable from within JavaScriptCore & WebCore. It encapsulates
the code taking care of initializing the random number generator (only when
building without ENABLE(JSC_MULTIPLE_THREADS), otherwhise initializeThreading()
already took care of that).

Functional change on darwin: Use random() instead of rand(), as it got a larger
period (more randomness). HTMLFormElement already contains this implementation
and I just moved it in randomNumber(), as special case for PLATFORM(DARWIN).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/ThreadingPthreads.cpp

    r38411 r39337  
    3636#include "HashMap.h"
    3737#include "MainThread.h"
    38 #include "MathExtras.h"
     38#include "RandomNumberSeed.h"
    3939
    4040#include <errno.h>
     
    6262        atomicallyInitializedStaticMutex = new Mutex;
    6363        threadMapMutex();
    64         wtf_random_init();
     64        initializeRandomNumberGenerator();
    6565#if !PLATFORM(DARWIN)
    6666        mainThreadIdentifier = currentThread();
Note: See TracChangeset for help on using the changeset viewer.