Skip to content

Commit

Permalink
Fix parsing of cpuinfo for s390 platform. (#712)
Browse files Browse the repository at this point in the history
s390 has another line structure for processor-field.
It should be differently parsed.
  • Loading branch information
gladk authored and LebedevRI committed Oct 21, 2018
1 parent 507c06e commit c6193af
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/sysinfo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,13 @@ int GetNumCPUs() {
if (ln.empty()) continue;
size_t SplitIdx = ln.find(':');
std::string value;
#if defined(__s390__)
// s390 has another format in /proc/cpuinfo
// it needs to be parsed differently
if (SplitIdx != std::string::npos) value = ln.substr(Key.size()+1,SplitIdx-Key.size()-1);
#else
if (SplitIdx != std::string::npos) value = ln.substr(SplitIdx + 1);
#endif
if (ln.size() >= Key.size() && ln.compare(0, Key.size(), Key) == 0) {
NumCPUs++;
if (!value.empty()) {
Expand Down

0 comments on commit c6193af

Please sign in to comment.