Chromium Code Reviews| Index: base/sys_info_win.cc |
| =================================================================== |
| --- base/sys_info_win.cc (revision 79219) |
| +++ base/sys_info_win.cc (working copy) |
| @@ -95,14 +95,21 @@ |
| } |
| // static |
| -void SysInfo::OperatingSystemVersionNumbers(int32 *major_version, |
| - int32 *minor_version, |
| - int32 *bugfix_version) { |
| - OSVERSIONINFO info = {0}; |
| - info.dwOSVersionInfoSize = sizeof(info); |
| - GetVersionEx(&info); |
| - *major_version = info.dwMajorVersion; |
| - *minor_version = info.dwMinorVersion; |
| +void SysInfo::OperatingSystemVersionNumbers(int32* major_version, |
| + int32* minor_version, |
| + int32* bugfix_version) { |
| + static bool checked_version = false; |
| + static int32 major = 0, minor = 0; |
| + 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
|
| + checked_version = true; |
| + OSVERSIONINFO info = {0}; |
| + info.dwOSVersionInfoSize = sizeof(info); |
| + GetVersionEx(&info); |
| + major = info.dwMajorVersion; |
| + minor = info.dwMinorVersion; |
| + } |
| + *major_version = major; |
| + *minor_version = minor; |
| *bugfix_version = 0; |
| } |