Skip to content

Commit

Permalink
first step towards successful compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Mar 3, 2019
1 parent 7a9e796 commit 9e00829
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 6 deletions.
8 changes: 8 additions & 0 deletions INSTALL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,19 @@ NetBSD
======

::

export PKG_PATH="ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/`uname -m`/`uname -r`/All"
pkg_add -v pkgin
pkgin install python gcc
python -m pip install psutil

DragonflyBSD
============

::

pkg install python3


Solaris
=======
Expand Down
5 changes: 3 additions & 2 deletions psutil/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
__all__ = [
# constants
'FREEBSD', 'BSD', 'LINUX', 'NETBSD', 'OPENBSD', 'MACOS', 'OSX', 'POSIX',
'SUNOS', 'WINDOWS',
'SUNOS', 'WINDOWS', 'DRAGONFLYBSD',
'ENCODING', 'ENCODING_ERRS', 'AF_INET6',
# connection constants
'CONN_CLOSE', 'CONN_CLOSE_WAIT', 'CONN_CLOSING', 'CONN_ESTABLISHED',
Expand Down Expand Up @@ -80,7 +80,8 @@
FREEBSD = sys.platform.startswith("freebsd")
OPENBSD = sys.platform.startswith("openbsd")
NETBSD = sys.platform.startswith("netbsd")
BSD = FREEBSD or OPENBSD or NETBSD
DRAGONFLYBSD = sys.platform.startswith("dragonfly")
BSD = FREEBSD or OPENBSD or NETBSD or DRAGONFLYBSD
SUNOS = sys.platform.startswith(("sunos", "solaris"))
AIX = sys.platform.startswith("aix")

Expand Down
16 changes: 12 additions & 4 deletions psutil/_psutil_bsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,21 @@
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/in_pcb.h>
#include <netinet/tcp.h>
#include <netinet/tcp_timer.h>
#include <netinet/ip_var.h>

#ifndef PSUTIL_DRAGONFLYBSD
#include <netinet/in_pcb.h>
#include <netinet/tcp_var.h> // for struct xtcpcb
#endif

#include <netinet/tcp_fsm.h> // for TCP connection states
#include <arpa/inet.h> // for inet_ntop()

#include <sys/mount.h>

#include <net/if.h> // net io counters
#include <net/if_dl.h>
#include <net/route.h>

#include <netinet/in.h> // process open files/connections
#include <sys/un.h>

Expand Down Expand Up @@ -94,9 +95,16 @@
#ifndef DTYPE_VNODE
#define DTYPE_VNODE 1
#endif
// #elif PSUTIL_DRAGONFLYBSD
// #include <kcore.h>
#endif


#include <kcore.h>
#include <sys/kinfo.h>
#include <kvm.h>



// convert a timeval struct to a double
#define PSUTIL_TV2DOUBLE(t) ((t).tv_sec + (t).tv_usec / 1000000.0)
Expand Down
11 changes: 11 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

from _common import AIX # NOQA
from _common import BSD # NOQA
from _common import DRAGONFLYBSD # NOQA
from _common import FREEBSD # NOQA
from _common import LINUX # NOQA
from _common import MACOS # NOQA
Expand Down Expand Up @@ -195,6 +196,16 @@ def get_winver():
define_macros=macros,
libraries=["kvm"])

elif DRAGONFLYBSD:
macros.append(("PSUTIL_DRAGONFLYBSD", 1))
ext = Extension(
'psutil._psutil_bsd',
sources=sources + [
'psutil/_psutil_bsd.c',
],
define_macros=macros,
libraries=["kvm"])

elif LINUX:
def get_ethtool_macro():
# see: https://github.com/giampaolo/psutil/issues/659
Expand Down

0 comments on commit 9e00829

Please sign in to comment.