summaryrefslogtreecommitdiff
path: root/simpleperf/environment.cpp
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@google.com>2019-12-17 17:15:02 +0900
committerNamhyung Kim <namhyung@google.com>2019-12-20 17:28:43 +0900
commita5f1d42f8a0a4853425d021c273e8d0ee94d8d7d (patch)
treea04cbe1bb1d117d1f96d43d5b722eafcc2f84570 /simpleperf/environment.cpp
parent52ff4263e57843b44657815973950c980aad81e1 (diff)
downloadextras-a5f1d42f8a0a4853425d021c273e8d0ee94d8d7d.tar.gz
simpleperf: move GetCpusFromString() to utils.cpp
Move the GetCpusFromString() to utils.cpp so that it can be used by event parsing code in event_type.cpp. No functional change intended. Test: build test only Change-Id: I626b8146f90bf8bb161ce8574bcf70f6600c8ad3
Diffstat (limited to 'simpleperf/environment.cpp')
-rw-r--r--simpleperf/environment.cpp28
1 files changed, 0 insertions, 28 deletions
diff --git a/simpleperf/environment.cpp b/simpleperf/environment.cpp
index 86766921..38ba2eb9 100644
--- a/simpleperf/environment.cpp
+++ b/simpleperf/environment.cpp
@@ -92,34 +92,6 @@ std::vector<int> GetOnlineCpus() {
return result;
}
-std::vector<int> GetCpusFromString(const std::string& s) {
- std::set<int> cpu_set;
- bool have_dash = false;
- const char* p = s.c_str();
- char* endp;
- int last_cpu;
- int cpu;
- // Parse line like: 0,1-3, 5, 7-8
- while ((cpu = static_cast<int>(strtol(p, &endp, 10))) != 0 || endp != p) {
- if (have_dash && !cpu_set.empty()) {
- for (int t = last_cpu + 1; t < cpu; ++t) {
- cpu_set.insert(t);
- }
- }
- have_dash = false;
- cpu_set.insert(cpu);
- last_cpu = cpu;
- p = endp;
- while (!isdigit(*p) && *p != '\0') {
- if (*p == '-') {
- have_dash = true;
- }
- ++p;
- }
- }
- return std::vector<int>(cpu_set.begin(), cpu_set.end());
-}
-
static std::vector<KernelMmap> GetLoadedModules() {
std::vector<KernelMmap> result;
FILE* fp = fopen("/proc/modules", "re");