[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.19-706-ge5415e9
eric at webkit.org
eric at webkit.org
Thu Feb 4 21:29:26 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit e5759035b8d01cedb038d027c38918710998117e
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Jan 27 14:07:59 2010 +0000
2010-01-27 Kwang Yul Seo <skyul at company100.net>
Reviewed by Eric Seidel.
[BREWMP] Port WTF's randomNumber
https://bugs.webkit.org/show_bug.cgi?id=33566
Use GETRAND to generate 4 byte random byte sequence to implement
weakRandomNumber. Create a secure random number generator with
AEECLSID_RANDOM to implement randomNumber.
* wtf/RandomNumber.cpp:
(WTF::weakRandomNumber):
(WTF::randomNumber):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53928 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index e01040c..933fdc1 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -2,6 +2,21 @@
Reviewed by Eric Seidel.
+ [BREWMP] Port WTF's randomNumber
+ https://bugs.webkit.org/show_bug.cgi?id=33566
+
+ Use GETRAND to generate 4 byte random byte sequence to implement
+ weakRandomNumber. Create a secure random number generator with
+ AEECLSID_RANDOM to implement randomNumber.
+
+ * wtf/RandomNumber.cpp:
+ (WTF::weakRandomNumber):
+ (WTF::randomNumber):
+
+2010-01-27 Kwang Yul Seo <skyul at company100.net>
+
+ Reviewed by Eric Seidel.
+
[BREWMP] Port getCPUTime
https://bugs.webkit.org/show_bug.cgi?id=33572
diff --git a/JavaScriptCore/wtf/RandomNumber.cpp b/JavaScriptCore/wtf/RandomNumber.cpp
index 74bb45c..fc48263 100644
--- a/JavaScriptCore/wtf/RandomNumber.cpp
+++ b/JavaScriptCore/wtf/RandomNumber.cpp
@@ -40,6 +40,12 @@ extern "C" {
}
#endif
+#if PLATFORM(BREWMP)
+#include <AEEAppGen.h>
+#include <AEESource.h>
+#include <AEEStdLib.h>
+#endif
+
namespace WTF {
double weakRandomNumber()
@@ -47,6 +53,10 @@ 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
@@ -99,6 +109,16 @@ double randomNumber()
// Mask off the low 53bits
fullRandom &= (1LL << 53) - 1;
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);
+
+ return static_cast<double>(bits) / (static_cast<double>(std::numeric_limits<uint32_t>::max()) + 1.0);
#else
uint32_t part1 = rand() & (RAND_MAX - 1);
uint32_t part2 = rand() & (RAND_MAX - 1);
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list