OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/sys_info.h" | 5 #include "base/sys_info.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 | 88 |
89 // static | 89 // static |
90 size_t SysInfo::VMAllocationGranularity() { | 90 size_t SysInfo::VMAllocationGranularity() { |
91 SYSTEM_INFO sysinfo; | 91 SYSTEM_INFO sysinfo; |
92 GetSystemInfo(&sysinfo); | 92 GetSystemInfo(&sysinfo); |
93 | 93 |
94 return sysinfo.dwAllocationGranularity; | 94 return sysinfo.dwAllocationGranularity; |
95 } | 95 } |
96 | 96 |
97 // static | 97 // static |
98 void SysInfo::OperatingSystemVersionNumbers(int32 *major_version, | 98 void SysInfo::OperatingSystemVersionNumbers(int32* major_version, |
99 int32 *minor_version, | 99 int32* minor_version, |
100 int32 *bugfix_version) { | 100 int32* bugfix_version) { |
101 OSVERSIONINFO info = {0}; | 101 static bool checked_version = false; |
102 info.dwOSVersionInfoSize = sizeof(info); | 102 static int32 major = 0, minor = 0; |
103 GetVersionEx(&info); | 103 if (!checked_version) { |
brettw
2011/03/24 20:19:03
This makes this function no longer thread safe. I
Peter Kasting
2011/03/24 20:59:02
Good point. The reason I did this is because rvar
brettw
2011/03/24 23:47:37
You're more expert on the compilers here than I am
Peter Kasting
2011/03/25 00:39:19
volatile isn't what you want, that means "can be c
| |
104 *major_version = info.dwMajorVersion; | 104 checked_version = true; |
105 *minor_version = info.dwMinorVersion; | 105 OSVERSIONINFO info = {0}; |
106 info.dwOSVersionInfoSize = sizeof(info); | |
107 GetVersionEx(&info); | |
108 major = info.dwMajorVersion; | |
109 minor = info.dwMinorVersion; | |
110 } | |
111 *major_version = major; | |
112 *minor_version = minor; | |
106 *bugfix_version = 0; | 113 *bugfix_version = 0; |
107 } | 114 } |
108 | 115 |
109 } // namespace base | 116 } // namespace base |
OLD | NEW |