diff options
Diffstat (limited to 'JavaScriptCore/wtf/RandomNumber.cpp')
| -rw-r--r-- | JavaScriptCore/wtf/RandomNumber.cpp | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/JavaScriptCore/wtf/RandomNumber.cpp b/JavaScriptCore/wtf/RandomNumber.cpp index fc48263..7a9b6a8 100644 --- a/JavaScriptCore/wtf/RandomNumber.cpp +++ b/JavaScriptCore/wtf/RandomNumber.cpp @@ -44,24 +44,12 @@ extern "C" { #include <AEEAppGen.h> #include <AEESource.h> #include <AEEStdLib.h> +#include <wtf/brew/RefPtrBrew.h> +#include <wtf/brew/ShellBrew.h> #endif namespace WTF { -double weakRandomNumber() -{ -#if COMPILER(MSVC) && defined(_CRT_RAND_S) - // rand_s is incredibly slow on windows so we fall back on rand for Math.random - return (rand() + (rand() / (RAND_MAX + 1.0))) / (RAND_MAX + 1.0); -#elif PLATFORM(BREWMP) - uint32_t bits; - GETRAND(reinterpret_cast<byte*>(&bits), sizeof(uint32_t)); - return static_cast<double>(bits) / (static_cast<double>(std::numeric_limits<uint32_t>::max()) + 1.0); -#else - return randomNumber(); -#endif -} - double randomNumber() { #if !ENABLE(JSC_MULTIPLE_THREADS) @@ -111,12 +99,8 @@ double randomNumber() return static_cast<double>(fullRandom)/static_cast<double>(1LL << 53); #elif PLATFORM(BREWMP) uint32_t bits; - ISource* randomSource; - - IShell* shell = reinterpret_cast<AEEApplet*>(GETAPPINSTANCE())->m_pIShell; - ISHELL_CreateInstance(shell, AEECLSID_RANDOM, reinterpret_cast<void**>(&randomSource)); - ISOURCE_Read(randomSource, reinterpret_cast<char*>(&bits), 4); - ISOURCE_Release(randomSource); + PlatformRefPtr<ISource> randomSource = createRefPtrInstance<ISource>(AEECLSID_RANDOM); + ISOURCE_Read(randomSource.get(), reinterpret_cast<char*>(&bits), 4); return static_cast<double>(bits) / (static_cast<double>(std::numeric_limits<uint32_t>::max()) + 1.0); #else |
