summaryrefslogtreecommitdiff
path: root/base/cpu.cc
diff options
context:
space:
mode:
authorLuis Hector Chavez <lhchavez@google.com>2016-05-25 15:29:35 -0700
committerLuis Hector Chavez <lhchavez@google.com>2016-05-27 09:06:26 -0700
commit94ffa55491333f3dcc701befd0d2652922916d99 (patch)
tree40533589f9b338f32c7f30d7d0169118eef52959 /base/cpu.cc
parent520be045f15462281c61e53944100d7e303679be (diff)
downloadlibchrome-94ffa55491333f3dcc701befd0d2652922916d99.tar.gz
libchrome: Uprev the library to r395517 from Chromium
Pulled the latest and greatest version of libchrome from Chromium. The merge was done against r395517 which corresponds to git commit ebdcb576bb346af95b8ad219f6250daf63122f98 of May 23, 2016 Notable changes are: - scoped_ptr was removed in favor of std::unique_ptr - base/thread_task_runner_handle.h was moved to base/threading. BUG: 28985443 TEST: All tests in libchrome_test pass on dragonboard-eng build Change-Id: Ic9f9ed1cafe754c96cd2f007984514e091aaba39
Diffstat (limited to 'base/cpu.cc')
-rw-r--r--base/cpu.cc60
1 files changed, 1 insertions, 59 deletions
diff --git a/base/cpu.cc b/base/cpu.cc
index 7135445664..de4a001f7f 100644
--- a/base/cpu.cc
+++ b/base/cpu.cc
@@ -7,13 +7,11 @@
#include <limits.h>
#include <stddef.h>
#include <stdint.h>
-#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include "base/macros.h"
-#include "base/strings/string_piece.h"
#include "build/build_config.h"
#if defined(ARCH_CPU_ARM_FAMILY) && (defined(OS_ANDROID) || defined(OS_LINUX))
@@ -49,7 +47,6 @@ CPU::CPU()
has_avx2_(false),
has_aesni_(false),
has_non_stop_time_stamp_counter_(false),
- has_broken_neon_(false),
cpu_vendor_("unknown") {
Initialize();
}
@@ -99,7 +96,7 @@ uint64_t _xgetbv(uint32_t xcr) {
#if defined(ARCH_CPU_ARM_FAMILY) && (defined(OS_ANDROID) || defined(OS_LINUX))
class LazyCpuInfoValue {
public:
- LazyCpuInfoValue() : has_broken_neon_(false) {
+ LazyCpuInfoValue() {
// This function finds the value from /proc/cpuinfo under the key "model
// name" or "Processor". "model name" is used in Linux 3.8 and later (3.7
// and later for arm64) and is shown once per CPU. "Processor" is used in
@@ -108,21 +105,6 @@ class LazyCpuInfoValue {
const char kModelNamePrefix[] = "model name\t: ";
const char kProcessorPrefix[] = "Processor\t: ";
- // This function also calculates whether we believe that this CPU has a
- // broken NEON unit based on these fields from cpuinfo:
- unsigned implementer = 0, architecture = 0, variant = 0, part = 0,
- revision = 0;
- const struct {
- const char key[17];
- unsigned int* result;
- } kUnsignedValues[] = {
- {"CPU implementer", &implementer},
- {"CPU architecture", &architecture},
- {"CPU variant", &variant},
- {"CPU part", &part},
- {"CPU revision", &revision},
- };
-
std::string contents;
ReadFileToString(FilePath("/proc/cpuinfo"), &contents);
DCHECK(!contents.empty());
@@ -138,52 +120,13 @@ class LazyCpuInfoValue {
line.compare(0, strlen(kProcessorPrefix), kProcessorPrefix) == 0)) {
brand_.assign(line.substr(strlen(kModelNamePrefix)));
}
-
- for (size_t i = 0; i < arraysize(kUnsignedValues); i++) {
- const char *key = kUnsignedValues[i].key;
- const size_t len = strlen(key);
-
- if (line.compare(0, len, key) == 0 &&
- line.size() >= len + 1 &&
- (line[len] == '\t' || line[len] == ' ' || line[len] == ':')) {
- size_t colon_pos = line.find(':', len);
- if (colon_pos == std::string::npos) {
- continue;
- }
-
- const StringPiece line_sp(line);
- StringPiece value_sp = line_sp.substr(colon_pos + 1);
- while (!value_sp.empty() &&
- (value_sp[0] == ' ' || value_sp[0] == '\t')) {
- value_sp = value_sp.substr(1);
- }
-
- // The string may have leading "0x" or not, so we use strtoul to
- // handle that.
- char* endptr;
- std::string value(value_sp.as_string());
- unsigned long int result = strtoul(value.c_str(), &endptr, 0);
- if (*endptr == 0 && result <= UINT_MAX) {
- *kUnsignedValues[i].result = result;
- }
- }
- }
}
-
- has_broken_neon_ =
- implementer == 0x51 &&
- architecture == 7 &&
- variant == 1 &&
- part == 0x4d &&
- revision == 0;
}
const std::string& brand() const { return brand_; }
- bool has_broken_neon() const { return has_broken_neon_; }
private:
std::string brand_;
- bool has_broken_neon_;
DISALLOW_COPY_AND_ASSIGN(LazyCpuInfoValue);
};
@@ -277,7 +220,6 @@ void CPU::Initialize() {
}
#elif defined(ARCH_CPU_ARM_FAMILY) && (defined(OS_ANDROID) || defined(OS_LINUX))
cpu_brand_.assign(g_lazy_cpuinfo.Get().brand());
- has_broken_neon_ = g_lazy_cpuinfo.Get().has_broken_neon();
#endif
}