summaryrefslogtreecommitdiffstats
path: root/base/cpu.cc
diff options
context:
space:
mode:
authormbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-26 23:26:34 +0000
committermbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-26 23:26:34 +0000
commit7f081364c5fb7ff6e35eef3242e26097225fd10e (patch)
tree9f333870f90718e310cb2c11cf6575733b684aae /base/cpu.cc
parent49a14c715d3f404e1b54f3ca23c806e8ae22ab8a (diff)
downloadchromium_src-7f081364c5fb7ff6e35eef3242e26097225fd10e.zip
chromium_src-7f081364c5fb7ff6e35eef3242e26097225fd10e.tar.gz
chromium_src-7f081364c5fb7ff6e35eef3242e26097225fd10e.tar.bz2
Check for cpu items before assuming it will work.
Review URL: http://codereview.chromium.org/3804 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2653 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/cpu.cc')
-rw-r--r--base/cpu.cc18
1 files changed, 10 insertions, 8 deletions
diff --git a/base/cpu.cc b/base/cpu.cc
index 41ebc083..ff02fb4 100644
--- a/base/cpu.cc
+++ b/base/cpu.cc
@@ -39,14 +39,16 @@ void CPU::Initialize() {
*(reinterpret_cast<int*>(cpu_string+8)) = cpu_info[2];
// Interpret CPU feature information.
- __cpuid(cpu_info, 1);
- stepping_ = cpu_info[0] & 0xf;
- model_ = (cpu_info[0] >> 4) & 0xf;
- family_ = (cpu_info[0] >> 8) & 0xf;
- type_ = (cpu_info[0] >> 12) & 0x3;
- ext_model_ = (cpu_info[0] >> 16) & 0xf;
- ext_family_ = (cpu_info[0] >> 20) & 0xff;
- cpu_vendor_ = cpu_string;
+ if (num_ids > 0) {
+ __cpuid(cpu_info, 1);
+ stepping_ = cpu_info[0] & 0xf;
+ model_ = (cpu_info[0] >> 4) & 0xf;
+ family_ = (cpu_info[0] >> 8) & 0xf;
+ type_ = (cpu_info[0] >> 12) & 0x3;
+ ext_model_ = (cpu_info[0] >> 16) & 0xf;
+ ext_family_ = (cpu_info[0] >> 20) & 0xff;
+ cpu_vendor_ = cpu_string;
+ }
}
} // namespace base