mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
![Ben Konyi](/assets/img/avatar_default.png)
Change-Id: I6dc02b3d9de16cc176eb97613bc0c7f0bb9b16eb Reviewed-on: https://dart-review.googlesource.com/77013 Commit-Queue: Ben Konyi <bkonyi@google.com> Commit-Queue: Ryan Macnak <rmacnak@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com> Auto-Submit: Ben Konyi <bkonyi@google.com>
60 lines
1.5 KiB
C++
60 lines
1.5 KiB
C++
// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
#include "vm/globals.h"
|
|
#if defined(HOST_OS_WINDOWS)
|
|
|
|
#include "vm/cpuid.h"
|
|
#include "vm/cpuinfo.h"
|
|
|
|
// __cpuid()
|
|
#include <intrin.h> // NOLINT
|
|
#include <string.h> // NOLINT
|
|
|
|
#include "platform/assert.h"
|
|
|
|
namespace dart {
|
|
|
|
CpuInfoMethod CpuInfo::method_ = kCpuInfoDefault;
|
|
const char* CpuInfo::fields_[kCpuInfoMax] = {0};
|
|
|
|
void CpuInfo::Init() {
|
|
method_ = kCpuInfoCpuId;
|
|
|
|
// Initialize the CpuId information.
|
|
CpuId::Init();
|
|
|
|
fields_[kCpuInfoProcessor] = "Processor";
|
|
fields_[kCpuInfoModel] = "Hardware";
|
|
fields_[kCpuInfoHardware] = "Hardware";
|
|
fields_[kCpuInfoFeatures] = "Features";
|
|
fields_[kCpuInfoArchitecture] = NULL;
|
|
}
|
|
|
|
void CpuInfo::Cleanup() {
|
|
CpuId::Cleanup();
|
|
}
|
|
|
|
bool CpuInfo::FieldContains(CpuInfoIndices idx, const char* search_string) {
|
|
ASSERT(method_ != kCpuInfoDefault);
|
|
return strstr(CpuId::field(idx), search_string);
|
|
}
|
|
|
|
const char* CpuInfo::ExtractField(CpuInfoIndices idx) {
|
|
ASSERT(method_ != kCpuInfoDefault);
|
|
return CpuId::field(idx);
|
|
}
|
|
|
|
bool CpuInfo::HasField(const char* field) {
|
|
ASSERT(method_ != kCpuInfoDefault);
|
|
return (strcmp(field, fields_[kCpuInfoProcessor]) == 0) ||
|
|
(strcmp(field, fields_[kCpuInfoModel]) == 0) ||
|
|
(strcmp(field, fields_[kCpuInfoHardware]) == 0) ||
|
|
(strcmp(field, fields_[kCpuInfoFeatures]) == 0);
|
|
}
|
|
|
|
} // namespace dart
|
|
|
|
#endif // defined(HOST_OS_WINDOWS)
|