Changeset 40968 in webkit for trunk/JavaScriptCore/wtf
- Timestamp:
- Feb 13, 2009, 1:18:43 AM (16 years ago)
- Location:
- trunk/JavaScriptCore/wtf
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/wtf/RandomNumber.cpp
r40967 r40968 36 36 37 37 namespace WTF { 38 39 double weakRandomNumber() 40 { 41 #if COMPILER(MSVC) && defined(_CRT_RAND_S) 42 // rand_s is incredibly slow on windows so we fall back on rand for Math.random 43 return (rand() + (rand() / (RAND_MAX + 1.0))) / (RAND_MAX + 1.0); 44 #else 45 return randomNumber(); 46 #endif 47 } 38 48 39 49 double randomNumber() -
trunk/JavaScriptCore/wtf/RandomNumber.h
r39432 r40968 29 29 namespace WTF { 30 30 31 // Returns a pseudo-random number in the range [0, 1) 31 // Returns a pseudo-random number in the range [0, 1), attempts to be 32 // cryptographically secure if possible on the target platform 32 33 double randomNumber(); 34 35 // Returns a pseudo-random number in the range [0, 1), attempts to 36 // produce a reasonable "random" number fast. 37 // We only need this because rand_s is so slow on windows. 38 double weakRandomNumber(); 33 39 34 40 } -
trunk/JavaScriptCore/wtf/RandomNumberSeed.h
r39558 r40968 58 58 } 59 59 60 inline void initializeWeakRandomNumberGenerator() 61 { 62 #if COMPILER(MSVC) && defined(_CRT_RAND_S) 63 // We need to initialise windows rand() explicitly for Math.random 64 unsigned seed = 0; 65 rand_s(&seed); 66 srand(seed); 67 #endif 68 } 60 69 } 61 70
Note:
See TracChangeset
for help on using the changeset viewer.