--- libraries/source/spidermonkey/FixpsutilFreeBSD.diff.orig	2017-09-13 00:10:27 UTC
+++ libraries/source/spidermonkey/FixpsutilFreeBSD.diff
@@ -1,6 +1,6 @@
---- python/psutil/psutil/_psutil_bsd.c
-+++ python/psutil/psutil/_psutil_bsd.c
-@@ -957,11 +957,19 @@ psutil_sockaddr_matches(int family, int port, void *pc
+--- ./python/psutil/psutil/_psutil_bsd.c.orig	2015-09-17 22:12:23.000000000 +0200
++++ ./python/psutil/psutil/_psutil_bsd.c
+@@ -957,11 +957,19 @@
                     psutil_sockaddr_addrlen(family)) == 0);
  }
  
@@ -20,7 +20,7 @@
      struct xinpgen *xig, *oxig;
      struct xsocket *so;
  
-@@ -969,9 +977,15 @@ psutil_search_tcplist(char *buf, struct kinfo_file *ki
+@@ -969,9 +977,15 @@
      for (xig = (struct xinpgen *)((char *)xig + xig->xig_len);
              xig->xig_len > sizeof(struct xinpgen);
              xig = (struct xinpgen *)((char *)xig + xig->xig_len)) {
@@ -36,7 +36,44 @@
  
          if (so->so_type != kif->kf_sock_type ||
                  so->xso_family != kif->kf_sock_domain ||
-@@ -1019,7 +1033,11 @@ psutil_proc_connections(PyObject *self, PyObject *args
+@@ -981,20 +995,36 @@
+         if (kif->kf_sock_domain == AF_INET) {
+             if (!psutil_sockaddr_matches(
+                     AF_INET, inp->inp_lport, &inp->inp_laddr,
++#if __FreeBSD_version < 1200031
+                     &kif->kf_sa_local))
++#else
++                    &kif->kf_un.kf_sock.kf_sa_local))
++#endif
+                 continue;
+             if (!psutil_sockaddr_matches(
+                     AF_INET, inp->inp_fport, &inp->inp_faddr,
++#if __FreeBSD_version < 1200031
+                     &kif->kf_sa_peer))
++#else
++                    &kif->kf_un.kf_sock.kf_sa_peer))
++#endif
+                 continue;
+         } else {
+             if (!psutil_sockaddr_matches(
+                     AF_INET6, inp->inp_lport, &inp->in6p_laddr,
++#if __FreeBSD_version < 1200031
+                     &kif->kf_sa_local))
++#else
++                    &kif->kf_un.kf_sock.kf_sa_peer))
++#endif
+                 continue;
+             if (!psutil_sockaddr_matches(
+                     AF_INET6, inp->inp_fport, &inp->in6p_faddr,
++#if __FreeBSD_version < 1200031
+                     &kif->kf_sa_peer))
++#else
++                    &kif->kf_un.kf_sock.kf_sa_peer))
++#endif
+                 continue;
+         }
+ 
+@@ -1019,7 +1049,11 @@
      struct kinfo_file *freep = NULL;
      struct kinfo_file *kif;
      char *tcplist = NULL;
@@ -48,3 +85,100 @@
  
      PyObject *retList = PyList_New(0);
      PyObject *tuple = NULL;
+@@ -1094,19 +1128,35 @@
+                 inet_ntop(
+                     kif->kf_sock_domain,
+                     psutil_sockaddr_addr(kif->kf_sock_domain,
++#if __FreeBSD_version < 1200031
+                                          &kif->kf_sa_local),
++#else
++                                         &kif->kf_un.kf_sock.kf_sa_local),
++#endif
+                     lip,
+                     sizeof(lip));
+                 inet_ntop(
+                     kif->kf_sock_domain,
+                     psutil_sockaddr_addr(kif->kf_sock_domain,
++#if __FreeBSD_version < 1200031
+                                          &kif->kf_sa_peer),
++#else
++                                         &kif->kf_un.kf_sock.kf_sa_peer),
++#endif
+                     rip,
+                     sizeof(rip));
+                 lport = htons(psutil_sockaddr_port(kif->kf_sock_domain,
++#if __FreeBSD_version < 1200031
+                                                    &kif->kf_sa_local));
++#else
++                                                   &kif->kf_un.kf_sock.kf_sa_local));
++#endif
+                 rport = htons(psutil_sockaddr_port(kif->kf_sock_domain,
++#if __FreeBSD_version < 1200031
+                                                    &kif->kf_sa_peer));
++#else
++                                                   &kif->kf_un.kf_sock.kf_sa_peer));
++#endif
+ 
+                 // construct python tuple/list
+                 laddr = Py_BuildValue("(si)", lip, lport);
+@@ -1137,7 +1187,11 @@
+             else if (kif->kf_sock_domain == AF_UNIX) {
+                 struct sockaddr_un *sun;
+ 
++#if __FreeBSD_version < 1200031
+                 sun = (struct sockaddr_un *)&kif->kf_sa_local;
++#else
++                sun = (struct sockaddr_un *)&kif->kf_un.kf_sock.kf_sa_local;
++#endif
+                 snprintf(
+                     path, sizeof(path), "%.*s",
+                     (sun->sun_len - (sizeof(*sun) - sizeof(sun->sun_path))),
+@@ -1779,7 +1833,11 @@
+     struct xinpgen *xig, *exig;
+     struct xinpcb *xip;
+     struct xtcpcb *xtp;
++#if __FreeBSD_version >= 1200026
++    struct xinpcb *inp;
++#else
+     struct inpcb *inp;
++#endif
+     struct xsocket *so;
+     struct sock *sock;
+     const char *varname;
+@@ -1849,13 +1907,21 @@
+                 PyErr_Format(PyExc_RuntimeError, "struct xinpcb size mismatch");
+                 goto error;
+             }
++#if __FreeBSD_version >= 1200026
++            inp = xip;
++#else
+             inp = &xip->xi_inp;
++#endif
+             so = &xip->xi_socket;
+             break;
+         }
+ 
+         inp = &xtp->xt_inp;
++#if __FreeBSD_version >= 1200026
++        so = &xtp->xt_inp.xi_socket;
++#else
+         so = &xtp->xt_socket;
++#endif
+         char lip[200], rip[200];
+         int family, lport, rport, pid, status;
+ 
+@@ -1863,9 +1929,14 @@
+         pid = psutil_get_pid_from_sock(hash);
+         if (pid < 0)
+             continue;
++
+         lport = ntohs(inp->inp_lport);
+         rport = ntohs(inp->inp_fport);
++#if __FreeBSD_version >= 1200026
++        status = xtp->t_state;
++#else
+         status = xtp->xt_tp.t_state;
++#endif
+ 
+         if (inp->inp_vflag & INP_IPV4) {
+             family = AF_INET;
