| OLD | NEW |
| 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 Loading... |
| 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 inclsion for cryptographically strong rand_s. |
| 58 #ifndef _CRT_RAND_S |
| 59 #define _CRT_RAND_S |
| 60 #endif // _CRT_RAND_S |
| 61 |
| 57 #include <windows.h> | 62 #include <windows.h> |
| 58 | 63 |
| 59 #include <time.h> // For LocalOffset() implementation. | 64 #include <time.h> // For LocalOffset() implementation. |
| 60 #include <mmsystem.h> // For timeGetTime(). | 65 #include <mmsystem.h> // For timeGetTime(). |
| 61 #ifdef __MINGW32__ | 66 #ifdef __MINGW32__ |
| 62 // Require Windows XP or higher when compiling with MinGW. This is for MinGW | 67 // Require Windows XP or higher when compiling with MinGW. This is for MinGW |
| 63 // header files to expose getaddrinfo. | 68 // header files to expose getaddrinfo. |
| 64 #undef _WIN32_WINNT | 69 #undef _WIN32_WINNT |
| 65 #define _WIN32_WINNT 0x501 | 70 #define _WIN32_WINNT 0x501 |
| 66 #endif // __MINGW32__ | 71 #endif // __MINGW32__ |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 // timestamp taking into account daylight saving. | 582 // timestamp taking into account daylight saving. |
| 578 char* Time::LocalTimezone() { | 583 char* Time::LocalTimezone() { |
| 579 // Return the standard or DST time zone name based on whether daylight | 584 // Return the standard or DST time zone name based on whether daylight |
| 580 // saving is in effect at the given time. | 585 // saving is in effect at the given time. |
| 581 return InDST() ? dst_tz_name_ : std_tz_name_; | 586 return InDST() ? dst_tz_name_ : std_tz_name_; |
| 582 } | 587 } |
| 583 | 588 |
| 584 | 589 |
| 585 void OS::Setup() { | 590 void OS::Setup() { |
| 586 // Seed the random number generator. | 591 // Seed the random number generator. |
| 587 // Convert the current time to a 64-bit integer first, before converting it | 592 unsigned int seed; |
| 588 // to an unsigned. Going directly can cause an overflow and the seed to be | 593 CHECK_EQ(rand_s(&seed), 0); |
| 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()); | |
| 592 srand(static_cast<unsigned int>(seed)); | 594 srand(static_cast<unsigned int>(seed)); |
| 593 } | 595 } |
| 594 | 596 |
| 595 | 597 |
| 596 // Returns the accumulated user time for thread. | 598 // Returns the accumulated user time for thread. |
| 597 int OS::GetUserTime(uint32_t* secs, uint32_t* usecs) { | 599 int OS::GetUserTime(uint32_t* secs, uint32_t* usecs) { |
| 598 FILETIME dummy; | 600 FILETIME dummy; |
| 599 uint64_t usertime; | 601 uint64_t usertime; |
| 600 | 602 |
| 601 // Get the amount of time that the thread has executed in user mode. | 603 // Get the amount of time that the thread has executed in user mode. |
| (...skipping 1351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1953 | 1955 |
| 1954 // Release the thread handles | 1956 // Release the thread handles |
| 1955 CloseHandle(data_->sampler_thread_); | 1957 CloseHandle(data_->sampler_thread_); |
| 1956 CloseHandle(data_->profiled_thread_); | 1958 CloseHandle(data_->profiled_thread_); |
| 1957 } | 1959 } |
| 1958 | 1960 |
| 1959 | 1961 |
| 1960 #endif // ENABLE_LOGGING_AND_PROFILING | 1962 #endif // ENABLE_LOGGING_AND_PROFILING |
| 1961 | 1963 |
| 1962 } } // namespace v8::internal | 1964 } } // namespace v8::internal |
| OLD | NEW |