Skip to content

Commit c6193af

Browse files
gladkLebedevRI
authored andcommitted
Fix parsing of cpuinfo for s390 platform. (#712)
s390 has another line structure for processor-field. It should be differently parsed.
1 parent 507c06e commit c6193af

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/sysinfo.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,13 @@ int GetNumCPUs() {
404404
if (ln.empty()) continue;
405405
size_t SplitIdx = ln.find(':');
406406
std::string value;
407+
#if defined(__s390__)
408+
// s390 has another format in /proc/cpuinfo
409+
// it needs to be parsed differently
410+
if (SplitIdx != std::string::npos) value = ln.substr(Key.size()+1,SplitIdx-Key.size()-1);
411+
#else
407412
if (SplitIdx != std::string::npos) value = ln.substr(SplitIdx + 1);
413+
#endif
408414
if (ln.size() >= Key.size() && ln.compare(0, Key.size(), Key) == 0) {
409415
NumCPUs++;
410416
if (!value.empty()) {

0 commit comments

Comments
 (0)