Fix build on netbsd-5

This commit is contained in:
sborrill 2016-01-07 08:14:23 +00:00
parent 8d00999310
commit 8710616e5c
2 changed files with 61 additions and 41 deletions

View file

@ -1,4 +1,4 @@
$NetBSD: distinfo,v 1.11 2015/12/04 09:42:18 ryoon Exp $
$NetBSD: distinfo,v 1.12 2016/01/07 08:14:23 sborrill Exp $
SHA1 (psutil-release-3.3.0.tar.gz) = e1a1ff558a90ad48302ad4aaf485a1841d67ee89
RMD160 (psutil-release-3.3.0.tar.gz) = 59ddfcdd2bdaa4274ff22e40da021c0ff69191a1
@ -6,7 +6,7 @@ SHA512 (psutil-release-3.3.0.tar.gz) = c0865631a3cb3a347c5e24328108f05a84f9468f6
Size (psutil-release-3.3.0.tar.gz) = 256632 bytes
SHA1 (patch-psutil_____init____.py) = 40b3108ab934ed8529a3989eda331d9d2cf2b7af
SHA1 (patch-psutil___psbsd.py) = e80fd4dcfad88468963d67c90b79c09625c43d1c
SHA1 (patch-psutil___psutil__bsd.c) = 4efa4ae9fcd16961e3bca987726732260214b635
SHA1 (patch-psutil___psutil__bsd.c) = 78db0683c961a03462e47c1db6ac448f26ed1014
SHA1 (patch-psutil___psutil__posix.c) = 6a01a7d45481ab1f512ef90164548a8a8b5cb831
SHA1 (patch-psutil_arch_bsd_netbsd.c) = a1183af4f7745c9774e01e3b3addf5f817a084ef
SHA1 (patch-psutil_arch_bsd_netbsd.h) = 4d58a458b10e34e4fac862cc70e53b9faf65dcb0

View file

@ -1,7 +1,7 @@
$NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
$NetBSD: patch-psutil___psutil__bsd.c,v 1.2 2016/01/07 08:14:23 sborrill Exp $
--- psutil/_psutil_bsd.c.orig 2015-11-25 01:20:34.000000000 +0000
+++ psutil/_psutil_bsd.c
+++ psutil/_psutil_bsd.c 2016-01-06 12:12:07.000000000 +0000
@@ -15,6 +15,9 @@
* - psutil.Process.memory_maps()
*/
@ -12,7 +12,21 @@ $NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
#include <Python.h>
#include <assert.h>
@@ -42,6 +45,7 @@
@@ -29,7 +32,13 @@
#include <sys/sysctl.h>
#include <sys/user.h>
#include <sys/proc.h>
+#if defined(__NetBSD__)
+#define _KERNEL
+#include <sys/file.h>
+#undef _KERNEL
+#else
#include <sys/file.h>
+#endif
#include <sys/socket.h>
#include <net/route.h>
#include <sys/socketvar.h> // for struct xsocket
@@ -42,6 +51,7 @@
#include <netinet/in_pcb.h>
#include <netinet/tcp.h>
#include <netinet/tcp_timer.h>
@ -20,7 +34,7 @@ $NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
#include <netinet/tcp_var.h> // for struct xtcpcb
#include <netinet/tcp_fsm.h> // for TCP connection states
#include <arpa/inet.h> // for inet_ntop()
@@ -63,6 +67,9 @@
@@ -63,6 +73,9 @@
#include "arch/bsd/freebsd_socks.h"
#elif __OpenBSD__
#include "arch/bsd/openbsd.h"
@ -30,7 +44,7 @@ $NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
#endif
#ifdef __FreeBSD__
@@ -85,6 +92,15 @@
@@ -85,6 +98,15 @@
#include <sys/sched.h> // for CPUSTATES & CP_*
#endif
@ -46,7 +60,7 @@ $NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
// convert a timeval struct to a double
#define PSUTIL_TV2DOUBLE(t) ((t).tv_sec + (t).tv_usec / 1000000.0)
@@ -95,7 +111,7 @@
@@ -95,7 +117,7 @@
(uint32_t) (bt.frac >> 32) ) >> 32 ) / 1000000)
#endif
@ -55,7 +69,7 @@ $NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
#define PSUTIL_KPT2DOUBLE(t) (t ## _sec + t ## _usec / 1000000.0)
#endif
@@ -125,7 +141,7 @@ psutil_pids(PyObject *self, PyObject *ar
@@ -125,7 +147,7 @@
for (idx = 0; idx < num_processes; idx++) {
#ifdef __FreeBSD__
py_pid = Py_BuildValue("i", proclist->ki_pid);
@ -64,7 +78,7 @@ $NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
py_pid = Py_BuildValue("i", proclist->p_pid);
#endif
if (!py_pid)
@@ -174,14 +190,14 @@ psutil_boot_time(PyObject *self, PyObjec
@@ -174,14 +196,14 @@
static PyObject *
psutil_proc_name(PyObject *self, PyObject *args) {
long pid;
@ -81,7 +95,7 @@ $NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
return Py_BuildValue("s", kp.p_comm);
#endif
}
@@ -213,14 +229,14 @@ psutil_proc_cmdline(PyObject *self, PyOb
@@ -213,14 +235,14 @@
static PyObject *
psutil_proc_ppid(PyObject *self, PyObject *args) {
long pid;
@ -98,7 +112,7 @@ $NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
return Py_BuildValue("l", (long)kp.p_ppid);
#endif
}
@@ -232,14 +248,14 @@ psutil_proc_ppid(PyObject *self, PyObjec
@@ -232,14 +254,14 @@
static PyObject *
psutil_proc_status(PyObject *self, PyObject *args) {
long pid;
@ -115,7 +129,7 @@ $NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
return Py_BuildValue("i", (int)kp.p_stat);
#endif
}
@@ -252,7 +268,7 @@ psutil_proc_status(PyObject *self, PyObj
@@ -252,7 +274,7 @@
static PyObject *
psutil_proc_uids(PyObject *self, PyObject *args) {
long pid;
@ -124,7 +138,7 @@ $NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
if (! PyArg_ParseTuple(args, "l", &pid))
return NULL;
if (psutil_kinfo_proc(pid, &kp) == -1)
@@ -262,7 +278,7 @@ psutil_proc_uids(PyObject *self, PyObjec
@@ -262,7 +284,7 @@
(long)kp.ki_ruid,
(long)kp.ki_uid,
(long)kp.ki_svuid);
@ -133,7 +147,7 @@ $NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
(long)kp.p_ruid,
(long)kp.p_uid,
(long)kp.p_svuid);
@@ -277,7 +293,7 @@ psutil_proc_uids(PyObject *self, PyObjec
@@ -277,7 +299,7 @@
static PyObject *
psutil_proc_gids(PyObject *self, PyObject *args) {
long pid;
@ -142,7 +156,7 @@ $NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
if (! PyArg_ParseTuple(args, "l", &pid))
return NULL;
if (psutil_kinfo_proc(pid, &kp) == -1)
@@ -287,7 +303,7 @@ psutil_proc_gids(PyObject *self, PyObjec
@@ -287,7 +309,7 @@
(long)kp.ki_rgid,
(long)kp.ki_groups[0],
(long)kp.ki_svuid);
@ -151,7 +165,7 @@ $NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
(long)kp.p_rgid,
(long)kp.p_groups[0],
(long)kp.p_svuid);
@@ -302,14 +318,14 @@ psutil_proc_gids(PyObject *self, PyObjec
@@ -302,14 +324,14 @@
static PyObject *
psutil_proc_tty_nr(PyObject *self, PyObject *args) {
long pid;
@ -168,7 +182,7 @@ $NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
return Py_BuildValue("i", kp.p_tdev);
#endif
}
@@ -321,7 +337,7 @@ psutil_proc_tty_nr(PyObject *self, PyObj
@@ -321,7 +343,7 @@
static PyObject *
psutil_proc_num_ctx_switches(PyObject *self, PyObject *args) {
long pid;
@ -177,7 +191,7 @@ $NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
if (! PyArg_ParseTuple(args, "l", &pid))
return NULL;
if (psutil_kinfo_proc(pid, &kp) == -1)
@@ -330,7 +346,7 @@ psutil_proc_num_ctx_switches(PyObject *s
@@ -330,7 +352,7 @@
#ifdef __FreeBSD__
kp.ki_rusage.ru_nvcsw,
kp.ki_rusage.ru_nivcsw);
@ -186,7 +200,7 @@ $NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
kp.p_uru_nvcsw,
kp.p_uru_nivcsw);
#endif
@@ -344,7 +360,7 @@ static PyObject *
@@ -344,7 +366,7 @@
psutil_proc_cpu_times(PyObject *self, PyObject *args) {
long pid;
double user_t, sys_t;
@ -195,7 +209,7 @@ $NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
if (! PyArg_ParseTuple(args, "l", &pid))
return NULL;
if (psutil_kinfo_proc(pid, &kp) == -1)
@@ -353,7 +369,7 @@ psutil_proc_cpu_times(PyObject *self, Py
@@ -353,7 +375,7 @@
#ifdef __FreeBSD__
user_t = PSUTIL_TV2DOUBLE(kp.ki_rusage.ru_utime);
sys_t = PSUTIL_TV2DOUBLE(kp.ki_rusage.ru_stime);
@ -204,7 +218,7 @@ $NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
user_t = PSUTIL_KPT2DOUBLE(kp.p_uutime);
sys_t = PSUTIL_KPT2DOUBLE(kp.p_ustime);
#endif
@@ -389,14 +405,14 @@ psutil_cpu_count_logical(PyObject *self,
@@ -389,14 +411,14 @@
static PyObject *
psutil_proc_create_time(PyObject *self, PyObject *args) {
long pid;
@ -221,7 +235,7 @@ $NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
return Py_BuildValue("d", PSUTIL_KPT2DOUBLE(kp.p_ustart));
#endif
}
@@ -409,7 +425,7 @@ psutil_proc_create_time(PyObject *self,
@@ -409,7 +431,7 @@
static PyObject *
psutil_proc_io_counters(PyObject *self, PyObject *args) {
long pid;
@ -230,7 +244,7 @@ $NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
if (! PyArg_ParseTuple(args, "l", &pid))
return NULL;
if (psutil_kinfo_proc(pid, &kp) == -1)
@@ -419,7 +435,7 @@ psutil_proc_io_counters(PyObject *self,
@@ -419,7 +441,7 @@
#ifdef __FreeBSD__
kp.ki_rusage.ru_inblock,
kp.ki_rusage.ru_oublock,
@ -239,7 +253,7 @@ $NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
kp.p_uru_inblock,
kp.p_uru_oublock,
#endif
@@ -438,7 +454,7 @@ psutil_proc_io_counters(PyObject *self,
@@ -438,7 +460,7 @@
static PyObject *
psutil_proc_memory_info(PyObject *self, PyObject *args) {
long pid;
@ -248,7 +262,7 @@ $NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
if (! PyArg_ParseTuple(args, "l", &pid))
return NULL;
if (psutil_kinfo_proc(pid, &kp) == -1)
@@ -451,7 +467,7 @@ psutil_proc_memory_info(PyObject *self,
@@ -451,7 +473,7 @@
ptoa(kp.ki_tsize), // text
ptoa(kp.ki_dsize), // data
ptoa(kp.ki_ssize)); // stack
@ -257,7 +271,7 @@ $NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
ptoa(kp.p_vm_rssize), // rss
// vms, this is how ps does it, see:
// http://anoncvs.spacehopper.org/openbsd-src/tree/bin/ps/print.c#n461
@@ -459,6 +475,9 @@ psutil_proc_memory_info(PyObject *self,
@@ -459,6 +481,9 @@
ptoa(kp.p_vm_tsize), // text
ptoa(kp.p_vm_dsize), // data
ptoa(kp.p_vm_ssize)); // stack
@ -267,7 +281,7 @@ $NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
#endif
}
@@ -472,7 +491,7 @@ psutil_cpu_times(PyObject *self, PyObjec
@@ -472,7 +497,7 @@
size_t size = sizeof(cpu_time);
int ret;
@ -276,7 +290,7 @@ $NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
ret = sysctlbyname("kern.cp_time", &cpu_time, &size, NULL, 0);
#elif __OpenBSD__
int mib[] = {CTL_KERN, KERN_CPTIME};
@@ -499,14 +518,14 @@ psutil_cpu_times(PyObject *self, PyObjec
@@ -499,14 +524,14 @@
* utility has the same problem see:
* https://github.com/giampaolo/psutil/issues/595
*/
@ -293,7 +307,7 @@ $NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
PyObject *py_retlist = PyList_New(0);
PyObject *py_tuple = NULL;
@@ -530,11 +549,16 @@ psutil_proc_open_files(PyObject *self, P
@@ -530,11 +555,16 @@
(kif->kf_vnode_type == KF_VTYPE_VREG))
{
py_tuple = Py_BuildValue("(si)", kif->kf_path, kif->kf_fd);
@ -311,7 +325,7 @@ $NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
#endif
if (py_tuple == NULL)
goto error;
@@ -567,7 +591,11 @@ psutil_disk_partitions(PyObject *self, P
@@ -567,7 +597,11 @@
long len;
uint64_t flags;
char opts[200];
@ -323,7 +337,7 @@ $NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
PyObject *py_retlist = PyList_New(0);
PyObject *py_tuple = NULL;
@@ -576,7 +604,11 @@ psutil_disk_partitions(PyObject *self, P
@@ -576,7 +610,11 @@
// get the number of mount points
Py_BEGIN_ALLOW_THREADS
@ -335,7 +349,7 @@ $NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
Py_END_ALLOW_THREADS
if (num == -1) {
PyErr_SetFromErrno(PyExc_OSError);
@@ -591,7 +623,11 @@ psutil_disk_partitions(PyObject *self, P
@@ -591,7 +629,11 @@
}
Py_BEGIN_ALLOW_THREADS
@ -347,7 +361,7 @@ $NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
Py_END_ALLOW_THREADS
if (num == -1) {
PyErr_SetFromErrno(PyExc_OSError);
@@ -601,24 +637,32 @@ psutil_disk_partitions(PyObject *self, P
@@ -601,24 +643,32 @@
for (i = 0; i < num; i++) {
py_tuple = NULL;
opts[0] = 0;
@ -383,7 +397,7 @@ $NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
if (flags & MNT_SUIDDIR)
strlcat(opts, ",suiddir", sizeof(opts));
if (flags & MNT_SOFTDEP)
@@ -631,27 +675,33 @@ psutil_disk_partitions(PyObject *self, P
@@ -631,27 +681,39 @@
strlcat(opts, ",multilabel", sizeof(opts));
if (flags & MNT_ACLS)
strlcat(opts, ",acls", sizeof(opts));
@ -415,14 +429,20 @@ $NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
+ strlcat(opts, ",union", sizeof(opts));
+ if (flags & MNT_NOCOREDUMP)
+ strlcat(opts, ",nocoredump", sizeof(opts));
+#ifdef MNT_RELATIME
+ if (flags & MNT_RELATIME)
+ strlcat(opts, ",relatime", sizeof(opts));
+#endif
+ if (flags & MNT_IGNORE)
+ strlcat(opts, ",ignore", sizeof(opts));
+#ifdef MNT_DISCARD
+ if (flags & MNT_DISCARD)
+ strlcat(opts, ",discard", sizeof(opts));
+#endif
+#ifdef MNT_EXTATTR
+ if (flags & MNT_EXTATTR)
+ strlcat(opts, ",extattr", sizeof(opts));
+#endif
+ if (flags & MNT_LOG)
+ strlcat(opts, ",log", sizeof(opts));
+ if (flags & MNT_SYMPERM)
@ -432,7 +452,7 @@ $NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
#endif
py_tuple = Py_BuildValue("(ssss)",
fs[i].f_mntfromname, // device
@@ -778,7 +828,7 @@ psutil_users(PyObject *self, PyObject *a
@@ -778,7 +840,7 @@
if (py_retlist == NULL)
return NULL;
@ -441,7 +461,7 @@ $NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
struct utmp ut;
FILE *fp;
@@ -812,6 +862,7 @@ psutil_users(PyObject *self, PyObject *a
@@ -812,6 +874,7 @@
#else
struct utmpx *utx;
@ -449,7 +469,7 @@ $NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
while ((utx = getutxent()) != NULL) {
if (utx->ut_type != USER_PROCESS)
continue;
@@ -883,20 +934,21 @@ PsutilMethods[] = {
@@ -883,20 +946,21 @@
"Return process tty (terminal) number"},
{"proc_cwd", psutil_proc_cwd, METH_VARARGS,
"Return process current working directory."},
@ -474,7 +494,7 @@ $NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
{"proc_memory_maps", psutil_proc_memory_maps, METH_VARARGS,
"Return a list of tuples for every process's memory map"},
{"proc_cpu_affinity_get", psutil_proc_cpu_affinity_get, METH_VARARGS,
@@ -906,6 +958,7 @@ PsutilMethods[] = {
@@ -906,6 +970,7 @@
{"cpu_count_phys", psutil_cpu_count_phys, METH_VARARGS,
"Return an XML string to determine the number physical CPUs."},
#endif
@ -482,7 +502,7 @@ $NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
// --- system-related functions
@@ -932,7 +985,7 @@ PsutilMethods[] = {
@@ -932,7 +997,7 @@
"Return a Python dict of tuples for disk I/O information"},
{"users", psutil_users, METH_VARARGS,
"Return currently connected users as a list of tuples"},
@ -491,7 +511,7 @@ $NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
{"net_connections", psutil_net_connections, METH_VARARGS,
"Return system-wide open connections."},
#endif
@@ -1010,6 +1063,13 @@ void init_psutil_bsd(void)
@@ -1010,6 +1075,13 @@
PyModule_AddIntConstant(module, "SZOMB", SZOMB); // unused
PyModule_AddIntConstant(module, "SDEAD", SDEAD);
PyModule_AddIntConstant(module, "SONPROC", SONPROC);