Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Side by Side Diff: runtime/vm/cpuinfo_openbsd.cc

Issue 1559053002: Refs #10260 OpenBSD support #25327 Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address code review issues Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/atomic_openbsd.h ('k') | runtime/vm/debuginfo_openbsd.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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_OPENBSD)
7 7
8 #include "vm/cpuinfo.h" 8 #include "vm/cpuinfo.h"
9 #include "vm/cpuid.h" 9 #include "vm/cpuid.h"
10 10
11 // __cpuid()
12 #include <intrin.h> // NOLINT
13 #include <string.h> // NOLINT
14
15 #include "platform/assert.h" 11 #include "platform/assert.h"
16 12
17 namespace dart { 13 namespace dart {
18 14
19 CpuInfoMethod CpuInfo::method_ = kCpuInfoDefault; 15 CpuInfoMethod CpuInfo::method_ = kCpuInfoDefault;
20 const char* CpuInfo::fields_[kCpuInfoMax] = {0}; 16 const char* CpuInfo::fields_[kCpuInfoMax] = {0};
21 17
22 void CpuInfo::InitOnce() { 18 void CpuInfo::InitOnce() {
19 fields_[kCpuInfoProcessor] = "vendor_id";
20 fields_[kCpuInfoModel] = "model name";
21 fields_[kCpuInfoHardware] = "model name";
22 fields_[kCpuInfoFeatures] = "flags";
23 method_ = kCpuInfoCpuId; 23 method_ = kCpuInfoCpuId;
24
25 // Initialize the CpuId information.
26 CpuId::InitOnce(); 24 CpuId::InitOnce();
27
28 fields_[kCpuInfoProcessor] = "Processor";
29 fields_[kCpuInfoModel] = "Hardware";
30 fields_[kCpuInfoHardware] = "Hardware";
31 fields_[kCpuInfoFeatures] = "Features";
32 } 25 }
33 26
34 27
35 void CpuInfo::Cleanup() { 28 void CpuInfo::Cleanup() {
36 CpuId::Cleanup(); 29 CpuId::Cleanup();
37 } 30 }
38 31
39 32
40 bool CpuInfo::FieldContains(CpuInfoIndices idx, const char* search_string) { 33 bool CpuInfo::FieldContains(CpuInfoIndices idx, const char* search_string) {
41 ASSERT(method_ != kCpuInfoDefault);
42 return strstr(CpuId::field(idx), search_string); 34 return strstr(CpuId::field(idx), search_string);
43 } 35 }
44 36
45 37
46 bool CpuInfo::FieldContainsByString(const char* field, 38 bool CpuInfo::FieldContainsByString(const char* field,
47 const char* search_string) { 39 const char* search_string) {
48 ASSERT(method_ != kCpuInfoDefault);
49 for (int i = 0; i < kCpuInfoMax; i++) { 40 for (int i = 0; i < kCpuInfoMax; i++) {
50 if (strcmp(field, fields_[i]) == 0) { 41 if (strcmp(field, fields_[i]) == 0) {
51 return FieldContains(static_cast<CpuInfoIndices>(i), search_string); 42 return FieldContains(static_cast<CpuInfoIndices>(i), search_string);
52 } 43 }
53 } 44 }
54 UNIMPLEMENTED(); 45 UNIMPLEMENTED();
55 return false; 46 return false;
56 } 47 }
57 48
58 49
59 const char* CpuInfo::ExtractField(CpuInfoIndices idx) { 50 const char* CpuInfo::ExtractField(CpuInfoIndices idx) {
60 ASSERT(method_ != kCpuInfoDefault);
61 return CpuId::field(idx); 51 return CpuId::field(idx);
62 } 52 }
63 53
64 54
65 const char* CpuInfo::ExtractFieldByString(const char* field) { 55 const char* CpuInfo::ExtractFieldByString(const char* field) {
66 ASSERT(method_ != kCpuInfoDefault);
67 for (int i = 0; i < kCpuInfoMax; i++) { 56 for (int i = 0; i < kCpuInfoMax; i++) {
68 if (strcmp(field, fields_[i]) == 0) { 57 if (strcmp(field, fields_[i]) == 0) {
69 return ExtractField(static_cast<CpuInfoIndices>(i)); 58 return ExtractField(static_cast<CpuInfoIndices>(i));
70 } 59 }
71 } 60 }
72 UNIMPLEMENTED(); 61 UNIMPLEMENTED();
73 return NULL; 62 return NULL;
74 } 63 }
75 64
76 65
77 bool CpuInfo::HasField(const char* field) { 66 bool CpuInfo::HasField(const char* field) {
78 ASSERT(method_ != kCpuInfoDefault);
79 return (strcmp(field, fields_[kCpuInfoProcessor]) == 0) || 67 return (strcmp(field, fields_[kCpuInfoProcessor]) == 0) ||
80 (strcmp(field, fields_[kCpuInfoModel]) == 0) || 68 (strcmp(field, fields_[kCpuInfoModel]) == 0) ||
81 (strcmp(field, fields_[kCpuInfoHardware]) == 0) || 69 (strcmp(field, fields_[kCpuInfoHardware]) == 0) ||
82 (strcmp(field, fields_[kCpuInfoFeatures]) == 0); 70 (strcmp(field, fields_[kCpuInfoFeatures]) == 0);
83 } 71 }
84 72
85 } // namespace dart 73 } // namespace dart
86 74
87 #endif // defined(TARGET_OS_WINDOWS) 75 #endif // defined(TARGET_OS_OPENBSD)
OLDNEW
« no previous file with comments | « runtime/vm/atomic_openbsd.h ('k') | runtime/vm/debuginfo_openbsd.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698