Changeset 53928 in webkit
- Timestamp:
- Jan 27, 2010 6:07:59 AM (14 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r53926 r53928 1 2010-01-27 Kwang Yul Seo <skyul@company100.net> 2 3 Reviewed by Eric Seidel. 4 5 [BREWMP] Port WTF's randomNumber 6 https://bugs.webkit.org/show_bug.cgi?id=33566 7 8 Use GETRAND to generate 4 byte random byte sequence to implement 9 weakRandomNumber. Create a secure random number generator with 10 AEECLSID_RANDOM to implement randomNumber. 11 12 * wtf/RandomNumber.cpp: 13 (WTF::weakRandomNumber): 14 (WTF::randomNumber): 15 1 16 2010-01-27 Kwang Yul Seo <skyul@company100.net> 2 17 -
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.