Merge pull request #1233 from ausil/master

ClockSpeed not defined in /proc/cpuinfo for 32 bit arm, so return 0.
This commit is contained in:
Tim St. Clair 2016-04-26 12:09:11 -07:00
commit ae814a5fff

View File

@ -49,8 +49,8 @@ const maxFreqFile = "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq"
// GetClockSpeed returns the CPU clock speed, given a []byte formatted as the /proc/cpuinfo file. // GetClockSpeed returns the CPU clock speed, given a []byte formatted as the /proc/cpuinfo file.
func GetClockSpeed(procInfo []byte) (uint64, error) { func GetClockSpeed(procInfo []byte) (uint64, error) {
// s390/s390x and aarch64 changes // s390/s390x, aarch64 and arm32 changes
if true == isSystemZ() || true == isAArch64() { if isSystemZ() || isAArch64() || isArm32() {
return 0, nil return 0, nil
} }
@ -280,13 +280,20 @@ func getMachineArch() (string, error) {
return arch, nil return arch, nil
} }
// arm32 chanes
func isArm32() bool {
arch, err := getMachineArch()
if err == nil {
return strings.Contains(arch, "arm")
}
return false
}
// aarch64 changes // aarch64 changes
func isAArch64() bool { func isAArch64() bool {
arch, err := getMachineArch() arch, err := getMachineArch()
if err == nil { if err == nil {
if true == strings.Contains(arch, "aarch64") { return strings.Contains(arch, "aarch64")
return true
}
} }
return false return false
} }
@ -295,9 +302,7 @@ func isAArch64() bool {
func isSystemZ() bool { func isSystemZ() bool {
arch, err := getMachineArch() arch, err := getMachineArch()
if err == nil { if err == nil {
if true == strings.Contains(arch, "390") { return strings.Contains(arch, "390")
return true
}
} }
return false return false
} }