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

Side by Side 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 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #endif 47 #endif
48 #ifndef NOMCX 48 #ifndef NOMCX
49 #define NOMCX 49 #define NOMCX
50 #endif 50 #endif
51 // Require Windows XP or higher (this is required for the RtlCaptureContext 51 // Require Windows XP or higher (this is required for the RtlCaptureContext
52 // function to be present). 52 // function to be present).
53 #ifndef _WIN32_WINNT 53 #ifndef _WIN32_WINNT
54 #define _WIN32_WINNT 0x501 54 #define _WIN32_WINNT 0x501
55 #endif 55 #endif
56 56
57 // Required before stdlib.h inclusion for cryptographically strong rand_s.
58 #ifndef _CRT_RAND_S
59 #define _CRT_RAND_S
60 #endif // _CRT_RAND_S
61
62 #include <windows.h> 57 #include <windows.h>
63 58
64 #include <time.h> // For LocalOffset() implementation. 59 #include <time.h> // For LocalOffset() implementation.
65 #include <mmsystem.h> // For timeGetTime(). 60 #include <mmsystem.h> // For timeGetTime().
66 #ifdef __MINGW32__ 61 #ifdef __MINGW32__
67 // Require Windows XP or higher when compiling with MinGW. This is for MinGW 62 // Require Windows XP or higher when compiling with MinGW. This is for MinGW
68 // header files to expose getaddrinfo. 63 // header files to expose getaddrinfo.
69 #undef _WIN32_WINNT 64 #undef _WIN32_WINNT
70 #define _WIN32_WINNT 0x501 65 #define _WIN32_WINNT 0x501
71 #endif // __MINGW32__ 66 #endif // __MINGW32__
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 // timestamp taking into account daylight saving. 577 // timestamp taking into account daylight saving.
583 char* Time::LocalTimezone() { 578 char* Time::LocalTimezone() {
584 // Return the standard or DST time zone name based on whether daylight 579 // Return the standard or DST time zone name based on whether daylight
585 // saving is in effect at the given time. 580 // saving is in effect at the given time.
586 return InDST() ? dst_tz_name_ : std_tz_name_; 581 return InDST() ? dst_tz_name_ : std_tz_name_;
587 } 582 }
588 583
589 584
590 void OS::Setup() { 585 void OS::Setup() {
591 // Seed the random number generator. 586 // Seed the random number generator.
592 unsigned int seed; 587 // Convert the current time to a 64-bit integer first, before converting it
593 CHECK_EQ(rand_s(&seed), 0); 588 // to an unsigned. Going directly can cause an overflow and the seed to be
589 // set to all ones. The seed will be identical for different instances that
590 // call this setup code within the same millisecond.
591 uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis());
594 srand(static_cast<unsigned int>(seed)); 592 srand(static_cast<unsigned int>(seed));
595 } 593 }
596 594
597 595
598 // Returns the accumulated user time for thread. 596 // Returns the accumulated user time for thread.
599 int OS::GetUserTime(uint32_t* secs, uint32_t* usecs) { 597 int OS::GetUserTime(uint32_t* secs, uint32_t* usecs) {
600 FILETIME dummy; 598 FILETIME dummy;
601 uint64_t usertime; 599 uint64_t usertime;
602 600
603 // Get the amount of time that the thread has executed in user mode. 601 // Get the amount of time that the thread has executed in user mode.
(...skipping 1352 matching lines...) Expand 10 before | Expand all | Expand 10 after
1956 1954
1957 // Release the thread handles 1955 // Release the thread handles
1958 CloseHandle(data_->sampler_thread_); 1956 CloseHandle(data_->sampler_thread_);
1959 CloseHandle(data_->profiled_thread_); 1957 CloseHandle(data_->profiled_thread_);
1960 } 1958 }
1961 1959
1962 1960
1963 #endif // ENABLE_LOGGING_AND_PROFILING 1961 #endif // ENABLE_LOGGING_AND_PROFILING
1964 1962
1965 } } // namespace v8::internal 1963 } } // namespace v8::internal
OLDNEW
« 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