summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2023-04-14 00:19:55 +0200
committerGitHub <noreply@github.com>2023-04-14 00:19:55 +0200
commiteb8e318628eeddc3b237449c08226785e9e2d589 (patch)
tree93f336c852b0f1b8c0d88d414e6fbccb59e1888b
parent59d8550c147795c6ab89535f719fbf6c8c40d2d5 (diff)
downloadpsutil-eb8e318628eeddc3b237449c08226785e9e2d589.tar.gz
[NetBSD] move files / refactoring of C files (#2232)
-rw-r--r--MANIFEST.in10
-rw-r--r--psutil/_psutil_bsd.c5
-rw-r--r--psutil/arch/netbsd/cpu.c102
-rw-r--r--psutil/arch/netbsd/cpu.h11
-rw-r--r--psutil/arch/netbsd/disk.c75
-rw-r--r--psutil/arch/netbsd/disk.h10
-rw-r--r--psutil/arch/netbsd/mem.c111
-rw-r--r--psutil/arch/netbsd/mem.h11
-rw-r--r--psutil/arch/netbsd/proc.c (renamed from psutil/arch/netbsd/specific.c)263
-rw-r--r--psutil/arch/netbsd/proc.h (renamed from psutil/arch/netbsd/specific.h)5
-rwxr-xr-xsetup.py5
11 files changed, 337 insertions, 271 deletions
diff --git a/MANIFEST.in b/MANIFEST.in
index 2653b691..a594328d 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -61,10 +61,16 @@ include psutil/arch/freebsd/sensors.c
include psutil/arch/freebsd/sensors.h
include psutil/arch/freebsd/sys_socks.c
include psutil/arch/freebsd/sys_socks.h
+include psutil/arch/netbsd/cpu.c
+include psutil/arch/netbsd/cpu.h
+include psutil/arch/netbsd/disk.c
+include psutil/arch/netbsd/disk.h
+include psutil/arch/netbsd/mem.c
+include psutil/arch/netbsd/mem.h
+include psutil/arch/netbsd/proc.c
+include psutil/arch/netbsd/proc.h
include psutil/arch/netbsd/socks.c
include psutil/arch/netbsd/socks.h
-include psutil/arch/netbsd/specific.c
-include psutil/arch/netbsd/specific.h
include psutil/arch/openbsd/cpu.c
include psutil/arch/openbsd/cpu.h
include psutil/arch/openbsd/disk.c
diff --git a/psutil/_psutil_bsd.c b/psutil/_psutil_bsd.c
index b2afbb28..ff5fd72d 100644
--- a/psutil/_psutil_bsd.c
+++ b/psutil/_psutil_bsd.c
@@ -93,7 +93,10 @@
#undef _KERNEL
#include <sys/sched.h> // for CPUSTATES & CP_*
#elif PSUTIL_NETBSD
- #include "arch/netbsd/specific.h"
+ #include "arch/netbsd/cpu.h"
+ #include "arch/netbsd/disk.h"
+ #include "arch/netbsd/mem.h"
+ #include "arch/netbsd/proc.h"
#include "arch/netbsd/socks.h"
#include <utmpx.h>
diff --git a/psutil/arch/netbsd/cpu.c b/psutil/arch/netbsd/cpu.c
new file mode 100644
index 00000000..33eb906f
--- /dev/null
+++ b/psutil/arch/netbsd/cpu.c
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2009, Giampaolo Rodola', Landry Breuil.
+ * All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <Python.h>
+#include <sys/sysctl.h>
+#include <uvm/uvm_extern.h>
+
+
+/*
+CPU related functions. Original code was refactored and moved from
+psutil/arch/netbsd/specific.c in 2023 (and was moved in there previously
+already) from cset 84219ad. For reference, here's the git history with
+original(ish) implementations:
+- per CPU times: 312442ad2a5b5d0c608476c5ab3e267735c3bc59 (Jan 2016)
+- CPU stats: a991494e4502e1235ebc62b5ba450287d0dedec0 (Jan 2016)
+*/
+
+
+PyObject *
+psutil_cpu_stats(PyObject *self, PyObject *args) {
+ size_t size;
+ struct uvmexp_sysctl uv;
+ int uvmexp_mib[] = {CTL_VM, VM_UVMEXP2};
+
+ size = sizeof(uv);
+ if (sysctl(uvmexp_mib, 2, &uv, &size, NULL, 0) < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+
+ return Py_BuildValue(
+ "IIIIIII",
+ uv.swtch, // ctx switches
+ uv.intrs, // interrupts - XXX always 0, will be determined via /proc
+ uv.softs, // soft interrupts
+ uv.syscalls, // syscalls - XXX always 0
+ uv.traps, // traps
+ uv.faults, // faults
+ uv.forks // forks
+ );
+}
+
+
+PyObject *
+psutil_per_cpu_times(PyObject *self, PyObject *args) {
+ int mib[3];
+ int ncpu;
+ size_t len;
+ size_t size;
+ int i;
+ PyObject *py_cputime = NULL;
+ PyObject *py_retlist = PyList_New(0);
+
+ if (py_retlist == NULL)
+ return NULL;
+ // retrieve the number of cpus
+ mib[0] = CTL_HW;
+ mib[1] = HW_NCPU;
+ len = sizeof(ncpu);
+ if (sysctl(mib, 2, &ncpu, &len, NULL, 0) == -1) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ goto error;
+ }
+ uint64_t cpu_time[CPUSTATES];
+
+ for (i = 0; i < ncpu; i++) {
+ // per-cpu info
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_CP_TIME;
+ mib[2] = i;
+ size = sizeof(cpu_time);
+ if (sysctl(mib, 3, &cpu_time, &size, NULL, 0) == -1) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+
+ py_cputime = Py_BuildValue(
+ "(ddddd)",
+ (double)cpu_time[CP_USER] / CLOCKS_PER_SEC,
+ (double)cpu_time[CP_NICE] / CLOCKS_PER_SEC,
+ (double)cpu_time[CP_SYS] / CLOCKS_PER_SEC,
+ (double)cpu_time[CP_IDLE] / CLOCKS_PER_SEC,
+ (double)cpu_time[CP_INTR] / CLOCKS_PER_SEC
+ );
+ if (!py_cputime)
+ goto error;
+ if (PyList_Append(py_retlist, py_cputime))
+ goto error;
+ Py_DECREF(py_cputime);
+ }
+
+ return py_retlist;
+
+error:
+ Py_XDECREF(py_cputime);
+ Py_DECREF(py_retlist);
+ return NULL;
+}
diff --git a/psutil/arch/netbsd/cpu.h b/psutil/arch/netbsd/cpu.h
new file mode 100644
index 00000000..6c861032
--- /dev/null
+++ b/psutil/arch/netbsd/cpu.h
@@ -0,0 +1,11 @@
+/*
+ * Copyright (c) 2009, Giampaolo Rodola', Landry Breuil.
+ * All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <Python.h>
+
+PyObject *psutil_cpu_stats(PyObject *self, PyObject *args);
+PyObject *psutil_per_cpu_times(PyObject *self, PyObject *args);
diff --git a/psutil/arch/netbsd/disk.c b/psutil/arch/netbsd/disk.c
new file mode 100644
index 00000000..5481f65d
--- /dev/null
+++ b/psutil/arch/netbsd/disk.c
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2009, Giampaolo Rodola', Landry Breuil.
+ * All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/*
+Disk related functions. Original code was refactored and moved from
+psutil/arch/netbsd/specific.c in 2023 (and was moved in there previously
+already) from cset 84219ad. For reference, here's the git history with
+original(ish) implementations:
+- disk IO counters: 312442ad2a5b5d0c608476c5ab3e267735c3bc59 (Jan 2016)
+*/
+
+#include <Python.h>
+#include <sys/sysctl.h>
+#include <sys/disk.h>
+
+
+PyObject *
+psutil_disk_io_counters(PyObject *self, PyObject *args) {
+ int i, dk_ndrive, mib[3];
+ size_t len;
+ struct io_sysctl *stats = NULL;
+ PyObject *py_disk_info = NULL;
+ PyObject *py_retdict = PyDict_New();
+
+ if (py_retdict == NULL)
+ return NULL;
+ mib[0] = CTL_HW;
+ mib[1] = HW_IOSTATS;
+ mib[2] = sizeof(struct io_sysctl);
+ len = 0;
+ if (sysctl(mib, 3, NULL, &len, NULL, 0) < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ goto error;
+ }
+ dk_ndrive = (int)(len / sizeof(struct io_sysctl));
+
+ stats = malloc(len);
+ if (stats == NULL) {
+ PyErr_NoMemory();
+ goto error;
+ }
+ if (sysctl(mib, 3, stats, &len, NULL, 0) < 0 ) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ goto error;
+ }
+
+ for (i = 0; i < dk_ndrive; i++) {
+ py_disk_info = Py_BuildValue(
+ "(KKKK)",
+ stats[i].rxfer,
+ stats[i].wxfer,
+ stats[i].rbytes,
+ stats[i].wbytes
+ );
+ if (!py_disk_info)
+ goto error;
+ if (PyDict_SetItemString(py_retdict, stats[i].name, py_disk_info))
+ goto error;
+ Py_DECREF(py_disk_info);
+ }
+
+ free(stats);
+ return py_retdict;
+
+error:
+ Py_XDECREF(py_disk_info);
+ Py_DECREF(py_retdict);
+ if (stats != NULL)
+ free(stats);
+ return NULL;
+}
diff --git a/psutil/arch/netbsd/disk.h b/psutil/arch/netbsd/disk.h
new file mode 100644
index 00000000..77691c0d
--- /dev/null
+++ b/psutil/arch/netbsd/disk.h
@@ -0,0 +1,10 @@
+/*
+ * Copyright (c) 2009, Giampaolo Rodola', Landry Breuil.
+ * All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <Python.h>
+
+PyObject *psutil_disk_io_counters(PyObject *self, PyObject *args);
diff --git a/psutil/arch/netbsd/mem.c b/psutil/arch/netbsd/mem.c
new file mode 100644
index 00000000..b7f5ba23
--- /dev/null
+++ b/psutil/arch/netbsd/mem.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2009, Giampaolo Rodola', Landry Breuil.
+ * All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/*
+Memory related functions. Original code was refactored and moved from
+psutil/arch/netbsd/specific.c in 2023 (and was moved in there previously
+already) from cset 84219ad. For reference, here's the git history with
+original(ish) implementations:
+- virtual memory: 0749a69c01b374ca3e2180aaafc3c95e3b2d91b9 (Oct 2016)
+- swap memory: 312442ad2a5b5d0c608476c5ab3e267735c3bc59 (Jan 2016)
+*/
+
+#include <Python.h>
+#include <sys/swap.h>
+#include <sys/sysctl.h>
+#include <uvm/uvm_extern.h>
+
+#include "../../_psutil_common.h"
+#include "../../_psutil_posix.h"
+
+
+// Virtual memory stats, taken from:
+// https://github.com/satterly/zabbix-stats/blob/master/src/libs/zbxsysinfo/
+// netbsd/memory.c
+PyObject *
+psutil_virtual_mem(PyObject *self, PyObject *args) {
+ size_t size;
+ struct uvmexp_sysctl uv;
+ int mib[] = {CTL_VM, VM_UVMEXP2};
+ long pagesize = psutil_getpagesize();
+
+ size = sizeof(uv);
+ if (sysctl(mib, 2, &uv, &size, NULL, 0) < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+
+ return Py_BuildValue("KKKKKKKK",
+ (unsigned long long) uv.npages << uv.pageshift, // total
+ (unsigned long long) uv.free << uv.pageshift, // free
+ (unsigned long long) uv.active << uv.pageshift, // active
+ (unsigned long long) uv.inactive << uv.pageshift, // inactive
+ (unsigned long long) uv.wired << uv.pageshift, // wired
+ (unsigned long long) (uv.filepages + uv.execpages) * pagesize, // cached
+ // These are determined from /proc/meminfo in Python.
+ (unsigned long long) 0, // buffers
+ (unsigned long long) 0 // shared
+ );
+}
+
+
+PyObject *
+psutil_swap_mem(PyObject *self, PyObject *args) {
+ uint64_t swap_total, swap_free;
+ struct swapent *swdev;
+ int nswap, i;
+ long pagesize = psutil_getpagesize();
+
+ nswap = swapctl(SWAP_NSWAP, 0, 0);
+ if (nswap == 0) {
+ // This means there's no swap partition.
+ return Py_BuildValue("(iiiii)", 0, 0, 0, 0, 0);
+ }
+
+ swdev = calloc(nswap, sizeof(*swdev));
+ if (swdev == NULL) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+
+ if (swapctl(SWAP_STATS, swdev, nswap) == -1) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ goto error;
+ }
+
+ // Total things up.
+ swap_total = swap_free = 0;
+ for (i = 0; i < nswap; i++) {
+ if (swdev[i].se_flags & SWF_ENABLE) {
+ swap_total += (uint64_t)swdev[i].se_nblks * DEV_BSIZE;
+ swap_free += (uint64_t)(swdev[i].se_nblks - swdev[i].se_inuse) * DEV_BSIZE;
+ }
+ }
+ free(swdev);
+
+ // Get swap in/out
+ unsigned int total;
+ size_t size = sizeof(total);
+ struct uvmexp_sysctl uv;
+ int mib[] = {CTL_VM, VM_UVMEXP2};
+ size = sizeof(uv);
+ if (sysctl(mib, 2, &uv, &size, NULL, 0) < 0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ goto error;
+ }
+
+ return Py_BuildValue("(LLLll)",
+ swap_total,
+ (swap_total - swap_free),
+ swap_free,
+ (long) uv.pgswapin * pagesize, // swap in
+ (long) uv.pgswapout * pagesize); // swap out
+
+error:
+ free(swdev);
+ return NULL;
+}
diff --git a/psutil/arch/netbsd/mem.h b/psutil/arch/netbsd/mem.h
new file mode 100644
index 00000000..1de3f3c4
--- /dev/null
+++ b/psutil/arch/netbsd/mem.h
@@ -0,0 +1,11 @@
+/*
+ * Copyright (c) 2009, Giampaolo Rodola', Landry Breuil.
+ * All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <Python.h>
+
+PyObject *psutil_virtual_mem(PyObject *self, PyObject *args);
+PyObject *psutil_swap_mem(PyObject *self, PyObject *args);
diff --git a/psutil/arch/netbsd/specific.c b/psutil/arch/netbsd/proc.c
index 11b8c1dd..b87473a6 100644
--- a/psutil/arch/netbsd/specific.c
+++ b/psutil/arch/netbsd/proc.c
@@ -7,39 +7,13 @@
* Platform-specific module methods for NetBSD.
*/
-#if defined(PSUTIL_NETBSD)
- #define _KMEMUSER
-#endif
-
#include <Python.h>
-#include <assert.h>
-#include <err.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/param.h>
#include <sys/sysctl.h>
-#include <sys/proc.h>
-#include <sys/swap.h> // for swap_mem
-#include <signal.h>
#include <kvm.h>
-// connection stuff
-#include <netdb.h> // for NI_MAXHOST
-#include <sys/socket.h>
-#include <sys/sched.h> // for CPUSTATES & CP_*
-#define _KERNEL // for DTYPE_*
- #include <sys/file.h>
-#undef _KERNEL
-#include <sys/disk.h> // struct diskstats
-#include <netinet/in.h>
-#include <arpa/inet.h>
#include "../../_psutil_common.h"
#include "../../_psutil_posix.h"
-#include "specific.h"
+#include "proc.h"
#define PSUTIL_KPT2DOUBLE(t) (t ## _sec + t ## _usec / 1000000.0)
@@ -295,10 +269,6 @@ error:
}
-// ============================================================================
-// APIS
-// ============================================================================
-
int
psutil_get_proc_list(kinfo_proc **procList, size_t *procCount) {
// Returns a list of all BSD processes on the system. This routine
@@ -435,96 +405,6 @@ error:
}
-/*
- * Virtual memory stats, taken from:
- * https://github.com/satterly/zabbix-stats/blob/master/src/libs/zbxsysinfo/
- * netbsd/memory.c
- */
-PyObject *
-psutil_virtual_mem(PyObject *self, PyObject *args) {
- size_t size;
- struct uvmexp_sysctl uv;
- int mib[] = {CTL_VM, VM_UVMEXP2};
- long pagesize = psutil_getpagesize();
-
- size = sizeof(uv);
- if (sysctl(mib, 2, &uv, &size, NULL, 0) < 0) {
- PyErr_SetFromErrno(PyExc_OSError);
- return NULL;
- }
-
- return Py_BuildValue("KKKKKKKK",
- (unsigned long long) uv.npages << uv.pageshift, // total
- (unsigned long long) uv.free << uv.pageshift, // free
- (unsigned long long) uv.active << uv.pageshift, // active
- (unsigned long long) uv.inactive << uv.pageshift, // inactive
- (unsigned long long) uv.wired << uv.pageshift, // wired
- (unsigned long long) (uv.filepages + uv.execpages) * pagesize, // cached
- // These are determined from /proc/meminfo in Python.
- (unsigned long long) 0, // buffers
- (unsigned long long) 0 // shared
- );
-}
-
-
-PyObject *
-psutil_swap_mem(PyObject *self, PyObject *args) {
- uint64_t swap_total, swap_free;
- struct swapent *swdev;
- int nswap, i;
- long pagesize = psutil_getpagesize();
-
- nswap = swapctl(SWAP_NSWAP, 0, 0);
- if (nswap == 0) {
- // This means there's no swap partition.
- return Py_BuildValue("(iiiii)", 0, 0, 0, 0, 0);
- }
-
- swdev = calloc(nswap, sizeof(*swdev));
- if (swdev == NULL) {
- PyErr_SetFromErrno(PyExc_OSError);
- return NULL;
- }
-
- if (swapctl(SWAP_STATS, swdev, nswap) == -1) {
- PyErr_SetFromErrno(PyExc_OSError);
- goto error;
- }
-
- // Total things up.
- swap_total = swap_free = 0;
- for (i = 0; i < nswap; i++) {
- if (swdev[i].se_flags & SWF_ENABLE) {
- swap_total += (uint64_t)swdev[i].se_nblks * DEV_BSIZE;
- swap_free += (uint64_t)(swdev[i].se_nblks - swdev[i].se_inuse) * DEV_BSIZE;
- }
- }
- free(swdev);
-
- // Get swap in/out
- unsigned int total;
- size_t size = sizeof(total);
- struct uvmexp_sysctl uv;
- int mib[] = {CTL_VM, VM_UVMEXP2};
- size = sizeof(uv);
- if (sysctl(mib, 2, &uv, &size, NULL, 0) < 0) {
- PyErr_SetFromErrno(PyExc_OSError);
- goto error;
- }
-
- return Py_BuildValue("(LLLll)",
- swap_total,
- (swap_total - swap_free),
- swap_free,
- (long) uv.pgswapin * pagesize, // swap in
- (long) uv.pgswapout * pagesize); // swap out
-
-error:
- free(swdev);
- return NULL;
-}
-
-
PyObject *
psutil_proc_num_fds(PyObject *self, PyObject *args) {
long pid;
@@ -545,144 +425,3 @@ psutil_proc_num_fds(PyObject *self, PyObject *args) {
return Py_BuildValue("i", cnt);
}
-
-
-PyObject *
-psutil_per_cpu_times(PyObject *self, PyObject *args) {
- // XXX: why static?
- int mib[3];
- int ncpu;
- size_t len;
- size_t size;
- int i;
- PyObject *py_cputime = NULL;
- PyObject *py_retlist = PyList_New(0);
-
- if (py_retlist == NULL)
- return NULL;
- // retrieve the number of cpus
- mib[0] = CTL_HW;
- mib[1] = HW_NCPU;
- len = sizeof(ncpu);
- if (sysctl(mib, 2, &ncpu, &len, NULL, 0) == -1) {
- PyErr_SetFromErrno(PyExc_OSError);
- goto error;
- }
- uint64_t cpu_time[CPUSTATES];
-
- for (i = 0; i < ncpu; i++) {
- // per-cpu info
- mib[0] = CTL_KERN;
- mib[1] = KERN_CP_TIME;
- mib[2] = i;
- size = sizeof(cpu_time);
- if (sysctl(mib, 3, &cpu_time, &size, NULL, 0) == -1) {
- warn("failed to get kern.cptime2");
- PyErr_SetFromErrno(PyExc_OSError);
- return NULL;
- }
-
- py_cputime = Py_BuildValue(
- "(ddddd)",
- (double)cpu_time[CP_USER] / CLOCKS_PER_SEC,
- (double)cpu_time[CP_NICE] / CLOCKS_PER_SEC,
- (double)cpu_time[CP_SYS] / CLOCKS_PER_SEC,
- (double)cpu_time[CP_IDLE] / CLOCKS_PER_SEC,
- (double)cpu_time[CP_INTR] / CLOCKS_PER_SEC);
- if (!py_cputime)
- goto error;
- if (PyList_Append(py_retlist, py_cputime))
- goto error;
- Py_DECREF(py_cputime);
- }
-
- return py_retlist;
-
-error:
- Py_XDECREF(py_cputime);
- Py_DECREF(py_retlist);
- return NULL;
-}
-
-
-PyObject *
-psutil_disk_io_counters(PyObject *self, PyObject *args) {
- int i, dk_ndrive, mib[3];
- size_t len;
- struct io_sysctl *stats = NULL;
- PyObject *py_disk_info = NULL;
- PyObject *py_retdict = PyDict_New();
-
- if (py_retdict == NULL)
- return NULL;
- mib[0] = CTL_HW;
- mib[1] = HW_IOSTATS;
- mib[2] = sizeof(struct io_sysctl);
- len = 0;
- if (sysctl(mib, 3, NULL, &len, NULL, 0) < 0) {
- warn("can't get HW_IOSTATS");
- PyErr_SetFromErrno(PyExc_OSError);
- goto error;
- }
- dk_ndrive = (int)(len / sizeof(struct io_sysctl));
-
- stats = malloc(len);
- if (stats == NULL) {
- PyErr_NoMemory();
- goto error;
- }
- if (sysctl(mib, 3, stats, &len, NULL, 0) < 0 ) {
- PyErr_SetFromErrno(PyExc_OSError);
- goto error;
- }
-
- for (i = 0; i < dk_ndrive; i++) {
- py_disk_info = Py_BuildValue(
- "(KKKK)",
- stats[i].rxfer,
- stats[i].wxfer,
- stats[i].rbytes,
- stats[i].wbytes
- );
- if (!py_disk_info)
- goto error;
- if (PyDict_SetItemString(py_retdict, stats[i].name, py_disk_info))
- goto error;
- Py_DECREF(py_disk_info);
- }
-
- free(stats);
- return py_retdict;
-
-error:
- Py_XDECREF(py_disk_info);
- Py_DECREF(py_retdict);
- if (stats != NULL)
- free(stats);
- return NULL;
-}
-
-
-PyObject *
-psutil_cpu_stats(PyObject *self, PyObject *args) {
- size_t size;
- struct uvmexp_sysctl uv;
- int uvmexp_mib[] = {CTL_VM, VM_UVMEXP2};
-
- size = sizeof(uv);
- if (sysctl(uvmexp_mib, 2, &uv, &size, NULL, 0) < 0) {
- PyErr_SetFromErrno(PyExc_OSError);
- return NULL;
- }
-
- return Py_BuildValue(
- "IIIIIII",
- uv.swtch, // ctx switches
- uv.intrs, // interrupts - XXX always 0, will be determined via /proc
- uv.softs, // soft interrupts
- uv.syscalls, // syscalls - XXX always 0
- uv.traps, // traps
- uv.faults, // faults
- uv.forks // forks
- );
-}
diff --git a/psutil/arch/netbsd/specific.h b/psutil/arch/netbsd/proc.h
index 391ed164..b4c88851 100644
--- a/psutil/arch/netbsd/specific.h
+++ b/psutil/arch/netbsd/proc.h
@@ -17,13 +17,8 @@ char *psutil_get_cmd_args(pid_t pid, size_t *argsize);
//
PyObject *psutil_get_cmdline(pid_t pid);
PyObject *psutil_proc_threads(PyObject *self, PyObject *args);
-PyObject *psutil_virtual_mem(PyObject *self, PyObject *args);
-PyObject *psutil_swap_mem(PyObject *self, PyObject *args);
PyObject *psutil_proc_num_fds(PyObject *self, PyObject *args);
PyObject *psutil_proc_connections(PyObject *self, PyObject *args);
-PyObject *psutil_per_cpu_times(PyObject *self, PyObject *args);
-PyObject* psutil_disk_io_counters(PyObject* self, PyObject* args);
PyObject* psutil_proc_exe(PyObject* self, PyObject* args);
PyObject* psutil_proc_num_threads(PyObject* self, PyObject* args);
-PyObject* psutil_cpu_stats(PyObject* self, PyObject* args);
PyObject *psutil_proc_cwd(PyObject *self, PyObject *args);
diff --git a/setup.py b/setup.py
index c69f6e3d..9fda1b30 100755
--- a/setup.py
+++ b/setup.py
@@ -287,7 +287,10 @@ elif NETBSD:
'psutil._psutil_bsd',
sources=sources + [
'psutil/_psutil_bsd.c',
- 'psutil/arch/netbsd/specific.c',
+ 'psutil/arch/netbsd/cpu.c',
+ 'psutil/arch/netbsd/disk.c',
+ 'psutil/arch/netbsd/mem.c',
+ 'psutil/arch/netbsd/proc.c',
'psutil/arch/netbsd/socks.c',
],
define_macros=macros,