summaryrefslogtreecommitdiff
path: root/math/py-numexpr/patches/patch-ab
blob: 4331c8e2e617db3c89e49dcb87c4ce0ff1a33d6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
$NetBSD: patch-ab,v 1.2 2016/07/15 07:18:45 wiz Exp $

Add NetBSD support in CPU detection.

--- numexpr/cpuinfo.py.orig	2016-06-01 11:55:58.000000000 +0000
+++ numexpr/cpuinfo.py
@@ -498,6 +498,32 @@ class DarwinCPUInfo(CPUInfoBase):
 
     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 @@ elif sys.platform.startswith('irix'):
     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'):