Index: runtime/vm/cpuinfo_fuchsia.cc |
diff --git a/runtime/vm/cpuinfo_fuchsia.cc b/runtime/vm/cpuinfo_fuchsia.cc |
index 04fe196415eb393d4425163c157346e0c0acbe39..ad9e990dd9042fe3da57fbf2f48e603254945321 100644 |
--- a/runtime/vm/cpuinfo_fuchsia.cc |
+++ b/runtime/vm/cpuinfo_fuchsia.cc |
@@ -8,8 +8,7 @@ |
#include "vm/cpuinfo.h" |
#include "platform/assert.h" |
- |
-// TODO(zra): Use "vm/cpuid.h" |
+#include "vm/cpuid.h" |
namespace dart { |
@@ -17,30 +16,55 @@ CpuInfoMethod CpuInfo::method_ = kCpuInfoDefault; |
const char* CpuInfo::fields_[kCpuInfoMax] = {0}; |
void CpuInfo::InitOnce() { |
- UNIMPLEMENTED(); |
+ // TODO(zra): Add support for HOST_ARCH_ARM64 |
+#if defined(HOST_ARCH_IA32) || defined(HOST_ARCH_X64) |
+ method_ = kCpuInfoCpuId; |
+ |
+ // Initialize the CpuId information. |
+ CpuId::InitOnce(); |
+ |
+ fields_[kCpuInfoProcessor] = "Processor"; |
+ fields_[kCpuInfoModel] = "Hardware"; |
+ fields_[kCpuInfoHardware] = "Hardware"; |
+ fields_[kCpuInfoFeatures] = "Features"; |
+#endif |
} |
void CpuInfo::Cleanup() { |
- UNIMPLEMENTED(); |
+ if (method_ == kCpuInfoCpuId) { |
+ CpuId::Cleanup(); |
+ } |
} |
bool CpuInfo::FieldContains(CpuInfoIndices idx, const char* search_string) { |
- UNIMPLEMENTED(); |
- return false; |
+ if (method_ == kCpuInfoCpuId) { |
+ return strstr(CpuId::field(idx), search_string); |
+ } else { |
+ return false; |
+ } |
} |
const char* CpuInfo::ExtractField(CpuInfoIndices idx) { |
- UNIMPLEMENTED(); |
- return "<undefined>"; |
+ if (method_ == kCpuInfoCpuId) { |
+ return CpuId::field(idx); |
+ } else { |
+ return strdup(""); |
+ } |
} |
bool CpuInfo::HasField(const char* field) { |
- UNIMPLEMENTED(); |
- return false; |
+ if (method_ == kCpuInfoCpuId) { |
+ return (strcmp(field, fields_[kCpuInfoProcessor]) == 0) || |
+ (strcmp(field, fields_[kCpuInfoModel]) == 0) || |
+ (strcmp(field, fields_[kCpuInfoHardware]) == 0) || |
+ (strcmp(field, fields_[kCpuInfoFeatures]) == 0); |
+ } else { |
+ return false; |
+ } |
} |
} // namespace dart |