Changeset 53928 in webkit for trunk/JavaScriptCore/wtf/RandomNumber.cpp
- Timestamp:
- Jan 27, 2010, 6:07:59 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/wtf/RandomNumber.cpp
r52791 r53928 41 41 #endif 42 42 43 #if PLATFORM(BREWMP) 44 #include <AEEAppGen.h> 45 #include <AEESource.h> 46 #include <AEEStdLib.h> 47 #endif 48 43 49 namespace WTF { 44 50 … … 48 54 // rand_s is incredibly slow on windows so we fall back on rand for Math.random 49 55 return (rand() + (rand() / (RAND_MAX + 1.0))) / (RAND_MAX + 1.0); 56 #elif PLATFORM(BREWMP) 57 uint32_t bits; 58 GETRAND(reinterpret_cast<byte*>(&bits), sizeof(uint32_t)); 59 return static_cast<double>(bits) / (static_cast<double>(std::numeric_limits<uint32_t>::max()) + 1.0); 50 60 #else 51 61 return randomNumber(); … … 100 110 fullRandom &= (1LL << 53) - 1; 101 111 return static_cast<double>(fullRandom)/static_cast<double>(1LL << 53); 112 #elif PLATFORM(BREWMP) 113 uint32_t bits; 114 ISource* randomSource; 115 116 IShell* shell = reinterpret_cast<AEEApplet*>(GETAPPINSTANCE())->m_pIShell; 117 ISHELL_CreateInstance(shell, AEECLSID_RANDOM, reinterpret_cast<void**>(&randomSource)); 118 ISOURCE_Read(randomSource, reinterpret_cast<char*>(&bits), 4); 119 ISOURCE_Release(randomSource); 120 121 return static_cast<double>(bits) / (static_cast<double>(std::numeric_limits<uint32_t>::max()) + 1.0); 102 122 #else 103 123 uint32_t part1 = rand() & (RAND_MAX - 1);
Note:
See TracChangeset
for help on using the changeset viewer.