diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-26 02:49:42 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-26 02:49:42 +0000 |
commit | 56d0cefa32d24d3222bee3615c6f7e0e772b6977 (patch) | |
tree | 91257b88907b8122316a61100205d08401fa4992 | |
parent | 853493a340e81c4220844ec192b4d70572c4e90f (diff) | |
download | chromium_src-56d0cefa32d24d3222bee3615c6f7e0e772b6977.zip chromium_src-56d0cefa32d24d3222bee3615c6f7e0e772b6977.tar.gz chromium_src-56d0cefa32d24d3222bee3615c6f7e0e772b6977.tar.bz2 |
Implement SysInfo::CPUArchitecture() on Windows. Try to make Windows and POSIX versions return consistent architecture names.
Review URL: https://chromiumcodereview.appspot.com/10910247
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@158726 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/sys_info.h | 22 | ||||
-rw-r--r-- | base/sys_info_posix.cc | 8 | ||||
-rw-r--r-- | base/sys_info_win.cc | 14 |
3 files changed, 32 insertions, 12 deletions
diff --git a/base/sys_info.h b/base/sys_info.h index e5917f1..e155285 100644 --- a/base/sys_info.h +++ b/base/sys_info.h @@ -5,14 +5,13 @@ #ifndef BASE_SYS_INFO_H_ #define BASE_SYS_INFO_H_ +#include <string> + #include "base/base_export.h" #include "base/basictypes.h" #include "base/file_path.h" #include "base/time.h" - -#include <string> - -class FilePath; +#include "build/build_config.h" namespace base { @@ -51,10 +50,15 @@ class BASE_EXPORT SysInfo { int32* minor_version, int32* bugfix_version); - // Returns the CPU architecture of the system. Exact return value may differ - // across platforms. + // Returns the architecture of the running operating system. + // Exact return value may differ across platforms. + // e.g. a 32-bit x86 kernel on a 64-bit capable CPU will return "x86", + // whereas a x86-64 kernel on the same CPU will return "x86_64" + // TODO(thestig) Rename this to OperatingSystemArchitecture(). static std::string CPUArchitecture(); + // Avoid using this. Use base/cpu.h to get information about the CPU instead. + // http://crbug.com/148884 // Returns the CPU model name of the system. If it can not be figured out, // an empty string is returned. static std::string CPUModelName(); @@ -66,7 +70,7 @@ class BASE_EXPORT SysInfo { #if defined(OS_POSIX) && !defined(OS_MACOSX) // Returns the maximum SysV shared memory segment size. static size_t MaxSharedMemorySize(); -#endif // defined(OS_POSIX) && !defined(OS_MACOSX) +#endif // defined(OS_POSIX) && !defined(OS_MACOSX) #if defined(OS_CHROMEOS) // Returns the name of the version entry we wish to look up in the @@ -82,7 +86,7 @@ class BASE_EXPORT SysInfo { // Returns the path to the lsb-release file. static FilePath GetLsbReleaseFilePath(); -#endif // defined(OS_CHROMEOS) +#endif // defined(OS_CHROMEOS) #if defined(OS_ANDROID) // Returns the Android build's codename. @@ -95,7 +99,7 @@ class BASE_EXPORT SysInfo { static std::string GetDeviceName(); static int DalvikHeapSizeMB(); -#endif // defined(OS_ANDROID) +#endif // defined(OS_ANDROID) }; } // namespace base diff --git a/base/sys_info_posix.cc b/base/sys_info_posix.cc index 3a6bd62..73a7108 100644 --- a/base/sys_info_posix.cc +++ b/base/sys_info_posix.cc @@ -79,7 +79,13 @@ std::string SysInfo::CPUArchitecture() { NOTREACHED(); return ""; } - return std::string(info.machine); + std::string arch(info.machine); + if (arch == "i386" || arch == "i486" || arch == "i586" || arch == "i686") { + arch = "x86"; + } else if (arch == "amd64") { + arch = "x86_64"; + } + return arch; } // static diff --git a/base/sys_info_win.cc b/base/sys_info_win.cc index d8de736..f5fa7d7 100644 --- a/base/sys_info_win.cc +++ b/base/sys_info_win.cc @@ -75,8 +75,18 @@ std::string SysInfo::OperatingSystemVersion() { // static std::string SysInfo::CPUArchitecture() { - // TODO: Make this vary when we support any other architectures. - return "x86"; + win::OSInfo::WindowsArchitecture arch = + win::OSInfo::GetInstance()->architecture(); + switch (arch) { + case win::OSInfo::X86_ARCHITECTURE: + return "x86"; + case win::OSInfo::X64_ARCHITECTURE: + return "x86_64"; + case win::OSInfo::IA64_ARCHITECTURE: + return "ia64"; + default: + return ""; + } } // static |