diff options
author | chappedm@gmail.com <chappedm@gmail.com@6b5cf1ce-ec42-a296-1ba9-69fdba395a50> | 2012-09-18 02:33:00 +0000 |
---|---|---|
committer | chappedm@gmail.com <chappedm@gmail.com@6b5cf1ce-ec42-a296-1ba9-69fdba395a50> | 2012-09-18 02:33:00 +0000 |
commit | 1f59bb34d3ce03df51c8356dd44fcb0b15de4769 (patch) | |
tree | 51c96a810f6bd247c9cd103488ca300e1fde6445 | |
parent | a2fec7c694ce992a3b7d3fe4205bb8710b017bab (diff) | |
download | gperftools-1f59bb34d3ce03df51c8356dd44fcb0b15de4769.tar.gz |
Adding support for CPU frequencies for Linux on PowerPC
git-svn-id: http://gperftools.googlecode.com/svn/trunk@159 6b5cf1ce-ec42-a296-1ba9-69fdba395a50
-rw-r--r-- | src/base/sysinfo.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/base/sysinfo.cc b/src/base/sysinfo.cc index 2559158..c83ad58 100644 --- a/src/base/sysinfo.cc +++ b/src/base/sysinfo.cc @@ -350,6 +350,22 @@ static void InitializeSystemInfo() { if (newline != NULL) *newline = '\0'; +#if defined(__powerpc__) || defined(__ppc__) + // PowerPC cpus report the frequency in "clock" line + if (strncasecmp(line, "clock", sizeof("clock")-1) == 0) { + const char* freqstr = strchr(line, ':'); + if (freqstr) { + // PowerPC frequencies are only reported as MHz (check 'show_cpuinfo' + // function at arch/powerpc/kernel/setup-common.c) + char *endp = strstr(line, "MHz"); + if (endp) { + *endp = 0; + cpuinfo_cycles_per_second = strtod(freqstr+1, &err) * 1000000.0; + if (freqstr[1] != '\0' && *err == '\0' && cpuinfo_cycles_per_second > 0) + saw_mhz = true; + } + } +#else // When parsing the "cpu MHz" and "bogomips" (fallback) entries, we only // accept postive values. Some environments (virtual machines) report zero, // which would cause infinite looping in WallTime_Init. @@ -367,6 +383,7 @@ static void InitializeSystemInfo() { if (freqstr[1] != '\0' && *err == '\0' && bogo_clock > 0) saw_bogo = true; } +#endif } else if (strncasecmp(line, "processor", sizeof("processor")-1) == 0) { num_cpus++; // count up every time we see an "processor :" entry } |