OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/globals.h" | 5 #include "vm/globals.h" |
6 #if defined(TARGET_OS_WINDOWS) | 6 #if defined(TARGET_OS_WINDOWS) |
7 | 7 |
8 #include "vm/cpuinfo.h" | 8 #include "vm/cpuinfo.h" |
9 #include "vm/cpuid.h" | 9 #include "vm/cpuid.h" |
10 | 10 |
(...skipping 25 matching lines...) Expand all Loading... |
36 CpuId::Cleanup(); | 36 CpuId::Cleanup(); |
37 } | 37 } |
38 | 38 |
39 | 39 |
40 bool CpuInfo::FieldContains(CpuInfoIndices idx, const char* search_string) { | 40 bool CpuInfo::FieldContains(CpuInfoIndices idx, const char* search_string) { |
41 ASSERT(method_ != kCpuInfoDefault); | 41 ASSERT(method_ != kCpuInfoDefault); |
42 return strstr(CpuId::field(idx), search_string); | 42 return strstr(CpuId::field(idx), search_string); |
43 } | 43 } |
44 | 44 |
45 | 45 |
46 bool CpuInfo::FieldContainsByString(const char* field, | |
47 const char* search_string) { | |
48 ASSERT(method_ != kCpuInfoDefault); | |
49 for (int i = 0; i < kCpuInfoMax; i++) { | |
50 if (strcmp(field, fields_[i]) == 0) { | |
51 return FieldContains(static_cast<CpuInfoIndices>(i), search_string); | |
52 } | |
53 } | |
54 UNIMPLEMENTED(); | |
55 return false; | |
56 } | |
57 | |
58 | |
59 const char* CpuInfo::ExtractField(CpuInfoIndices idx) { | 46 const char* CpuInfo::ExtractField(CpuInfoIndices idx) { |
60 ASSERT(method_ != kCpuInfoDefault); | 47 ASSERT(method_ != kCpuInfoDefault); |
61 return CpuId::field(idx); | 48 return CpuId::field(idx); |
62 } | 49 } |
63 | 50 |
64 | 51 |
65 const char* CpuInfo::ExtractFieldByString(const char* field) { | |
66 ASSERT(method_ != kCpuInfoDefault); | |
67 for (int i = 0; i < kCpuInfoMax; i++) { | |
68 if (strcmp(field, fields_[i]) == 0) { | |
69 return ExtractField(static_cast<CpuInfoIndices>(i)); | |
70 } | |
71 } | |
72 UNIMPLEMENTED(); | |
73 return NULL; | |
74 } | |
75 | |
76 | |
77 bool CpuInfo::HasField(const char* field) { | 52 bool CpuInfo::HasField(const char* field) { |
78 ASSERT(method_ != kCpuInfoDefault); | 53 ASSERT(method_ != kCpuInfoDefault); |
79 return (strcmp(field, fields_[kCpuInfoProcessor]) == 0) || | 54 return (strcmp(field, fields_[kCpuInfoProcessor]) == 0) || |
80 (strcmp(field, fields_[kCpuInfoModel]) == 0) || | 55 (strcmp(field, fields_[kCpuInfoModel]) == 0) || |
81 (strcmp(field, fields_[kCpuInfoHardware]) == 0) || | 56 (strcmp(field, fields_[kCpuInfoHardware]) == 0) || |
82 (strcmp(field, fields_[kCpuInfoFeatures]) == 0); | 57 (strcmp(field, fields_[kCpuInfoFeatures]) == 0); |
83 } | 58 } |
84 | 59 |
85 } // namespace dart | 60 } // namespace dart |
86 | 61 |
87 #endif // defined(TARGET_OS_WINDOWS) | 62 #endif // defined(TARGET_OS_WINDOWS) |
OLD | NEW |