Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(696)

Unified Diff: src/platform-win32.cc

Issue 5284006: Revert seeding the random number generator with rand_s on Windows. It... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/platform-win32.cc
===================================================================
--- src/platform-win32.cc (revision 5894)
+++ src/platform-win32.cc (working copy)
@@ -54,11 +54,6 @@
#define _WIN32_WINNT 0x501
#endif
-// Required before stdlib.h inclusion for cryptographically strong rand_s.
-#ifndef _CRT_RAND_S
-#define _CRT_RAND_S
-#endif // _CRT_RAND_S
-
#include <windows.h>
#include <time.h> // For LocalOffset() implementation.
@@ -589,8 +584,11 @@
void OS::Setup() {
// Seed the random number generator.
- unsigned int seed;
- CHECK_EQ(rand_s(&seed), 0);
+ // Convert the current time to a 64-bit integer first, before converting it
+ // to an unsigned. Going directly can cause an overflow and the seed to be
+ // set to all ones. The seed will be identical for different instances that
+ // call this setup code within the same millisecond.
+ uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis());
srand(static_cast<unsigned int>(seed));
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698