Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 #ifndef VM_CPUINFO_H_ | |
| 6 #define VM_CPUINFO_H_ | |
| 7 | |
| 8 #include "vm/allocation.h" | |
| 9 | |
| 10 namespace dart { | |
| 11 | |
| 12 class CpuInfo : public AllStatic { | |
| 13 public: | |
| 14 // If necessary, allocates a buffer [data_] and reads cpuinfo into | |
| 15 // that buffer. | |
| 16 static void Read(); | |
|
Cutch
2014/01/02 19:39:19
Rename to InitOnce ?
| |
| 17 | |
| 18 // Returns true if the cpuinfo field [field] contains the | |
| 19 // string [search_string]. | |
| 20 static bool FieldContains(const char* field, const char* search_string); | |
| 21 | |
| 22 // Returns true if the cpuinfo field [field] exists and is non-empty. | |
| 23 static bool HasField(const char* field); | |
| 24 | |
| 25 // Reads the cpuinfo field [field] into the buffer [dest] and returns the | |
| 26 // length of the field. | |
| 27 // If [dest] is NULL, ExtractField just returns the length. | |
| 28 static intptr_t ExtractField( | |
| 29 const char* field, char* dest, const intptr_t dest_len); | |
| 30 | |
| 31 // Returns the length of the cpuinfo field [field]. | |
| 32 static intptr_t FieldLength(const char* field) { | |
| 33 return ExtractField(field, NULL, 0); | |
| 34 } | |
| 35 | |
| 36 // Reads the cpuinfo field describing the CPU model into the buffer [dest]. | |
| 37 static intptr_t GetCpuModel(char* dest, const intptr_t dest_len); | |
| 38 | |
| 39 private: | |
| 40 // On Linux and Android data_ holds /proc/cpuinfo after Read(). | |
| 41 static char* data_; | |
| 42 // On Linux and Android, the length of /proc/cpuinfo. | |
| 43 static intptr_t datalen_; | |
| 44 }; | |
| 45 | |
| 46 } // namespace dart | |
| 47 | |
| 48 #endif // VM_CPUINFO_H_ | |
| OLD | NEW |