Index: runtime/vm/cpuinfo.h |
=================================================================== |
--- runtime/vm/cpuinfo.h (revision 0) |
+++ runtime/vm/cpuinfo.h (revision 0) |
@@ -0,0 +1,48 @@ |
+// Copyright (c) 2012, 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. |
+ |
+#ifndef VM_CPUINFO_H_ |
+#define VM_CPUINFO_H_ |
+ |
+#include "vm/allocation.h" |
+ |
+namespace dart { |
+ |
+class CpuInfo : public AllStatic { |
+ public: |
+ // If necessary, allocates a buffer [data_] and reads cpuinfo into |
+ // that buffer. |
+ static void Read(); |
Cutch
2014/01/02 19:39:19
Rename to InitOnce ?
|
+ |
+ // Returns true if the cpuinfo field [field] contains the |
+ // string [search_string]. |
+ static bool FieldContains(const char* field, const char* search_string); |
+ |
+ // Returns true if the cpuinfo field [field] exists and is non-empty. |
+ static bool HasField(const char* field); |
+ |
+ // Reads the cpuinfo field [field] into the buffer [dest] and returns the |
+ // length of the field. |
+ // If [dest] is NULL, ExtractField just returns the length. |
+ static intptr_t ExtractField( |
+ const char* field, char* dest, const intptr_t dest_len); |
+ |
+ // Returns the length of the cpuinfo field [field]. |
+ static intptr_t FieldLength(const char* field) { |
+ return ExtractField(field, NULL, 0); |
+ } |
+ |
+ // Reads the cpuinfo field describing the CPU model into the buffer [dest]. |
+ static intptr_t GetCpuModel(char* dest, const intptr_t dest_len); |
+ |
+ private: |
+ // On Linux and Android data_ holds /proc/cpuinfo after Read(). |
+ static char* data_; |
+ // On Linux and Android, the length of /proc/cpuinfo. |
+ static intptr_t datalen_; |
+}; |
+ |
+} // namespace dart |
+ |
+#endif // VM_CPUINFO_H_ |