From a898c2d3c130a04a00f69e54583ceade02f5bbcd Mon Sep 17 00:00:00 2001 From: Thomas Klausner Date: Fri, 15 Jul 2016 09:20:31 +0200 Subject: [PATCH] Add NetBSD support to CPU detection. --- numexpr/cpuinfo.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/numexpr/cpuinfo.py b/numexpr/cpuinfo.py index f11cf5fd..5be8b7c8 100755 --- a/numexpr/cpuinfo.py +++ b/numexpr/cpuinfo.py @@ -498,6 +498,32 @@ def _is_ppc823(self): return self.__machine(823) def _is_ppc860(self): return self.__machine(860) +class NetBSDCPUInfo(CPUInfoBase): + info = None + + def __init__(self): + if self.info is not None: + return + info = {} + info['sysctl_hw'] = key_value_from_command(['sysctl', 'hw'], sep='=') + info['arch'] = info['sysctl_hw'].get('hw.machine_arch', 1) + info['machine'] = info['sysctl_hw'].get('hw.machine', 1) + self.__class__.info = info + + def _not_impl(self): pass + + def _getNCPUs(self): + return int(self.info['sysctl_hw'].get('hw.ncpu', 1)) + + def _is_Intel(self): + if self.info['sysctl_hw'].get('hw.model', "")[0:5] == 'Intel': + return True + return False + + def _is_AMD(self): + if self.info['sysctl_hw'].get('hw.model', "")[0:3] == 'AMD': + return True + return False class SunOSCPUInfo(CPUInfoBase): info = None @@ -781,6 +807,8 @@ def _has_3dnowext(self): cpuinfo = IRIXCPUInfo elif sys.platform == 'darwin': cpuinfo = DarwinCPUInfo +elif sys.platform[0:6] == 'netbsd': + cpuinfo = NetBSDCPUInfo elif sys.platform.startswith('sunos'): cpuinfo = SunOSCPUInfo elif sys.platform.startswith('win32'):