pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/sysutils/libgtop Add processor affinity support, from ...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/a80504924129
branches:  trunk
changeset: 550181:a80504924129
user:      wiz <wiz%pkgsrc.org@localhost>
date:      Sun Nov 16 20:31:09 2008 +0000

description:
Add processor affinity support, from Juan Romero Pardines -- thank you!
Bump PKGREVISION.

diffstat:

 sysutils/libgtop/Makefile             |   6 +-
 sysutils/libgtop/distinfo             |   3 +-
 sysutils/libgtop/files/procaffinity.c |  87 +++++++++++++++++++++++++++++++++++
 sysutils/libgtop/patches/patch-ad     |  23 ---------
 4 files changed, 91 insertions(+), 28 deletions(-)

diffs (157 lines):

diff -r 756d3995e164 -r a80504924129 sysutils/libgtop/Makefile
--- a/sysutils/libgtop/Makefile Sun Nov 16 20:11:31 2008 +0000
+++ b/sysutils/libgtop/Makefile Sun Nov 16 20:31:09 2008 +0000
@@ -1,6 +1,7 @@
-# $NetBSD: Makefile,v 1.19 2008/11/15 19:34:11 wiz Exp $
+# $NetBSD: Makefile,v 1.20 2008/11/16 20:31:09 wiz Exp $
 
 DISTNAME=              libgtop-2.24.0
+PKGREVISION=           1
 CATEGORIES=            sysutils gnome
 MASTER_SITES=          ${MASTER_SITE_GNOME:=sources/libgtop/2.24/}
 EXTRACT_SUFX=          .tar.bz2
@@ -26,8 +27,7 @@
 CONFLICTS+=            libgtop2-[0-9]*
 
 post-patch:
-       cd ${WRKSRC}/sysdeps && \
-               ${CP} freebsd/procaffinity.c bsd/procaffinity.c
+       ${CP} ${FILESDIR}/procaffinity.c ${WRKSRC}/sysdeps/bsd/
 
 # The following flags are for debugging purposes.  They don't need to
 # be used unless you are actively developing/debugging libgtop.
diff -r 756d3995e164 -r a80504924129 sysutils/libgtop/distinfo
--- a/sysutils/libgtop/distinfo Sun Nov 16 20:11:31 2008 +0000
+++ b/sysutils/libgtop/distinfo Sun Nov 16 20:31:09 2008 +0000
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.8 2008/11/15 19:34:11 wiz Exp $
+$NetBSD: distinfo,v 1.9 2008/11/16 20:31:09 wiz Exp $
 
 SHA1 (libgtop-2.24.0.tar.bz2) = 934b9a83f8042dbbacdfb02cf85f4078d8b6fd14
 RMD160 (libgtop-2.24.0.tar.bz2) = f007316559118c02acd7f0eafba79b7c8dfd28f3
@@ -6,7 +6,6 @@
 SHA1 (patch-aa) = 031a8128a89bd1d0adcd04d46fb6822ba16bb1b1
 SHA1 (patch-ab) = cd11ad54870ab54fb940f922c1cc55d1c7ec2161
 SHA1 (patch-ac) = 3dd59355e36657df4c8575c35ef11c28d4192d77
-SHA1 (patch-ad) = 737186e6245f66a8650b0c4bf91702a5ffa1c186
 SHA1 (patch-ag) = 8ed7b66b4250dbc6f6321cef24941f58106fcbaf
 SHA1 (patch-ai) = 856c457b14e384b2c991bf51274f97a3a9c853f1
 SHA1 (patch-aj) = 94e41923f13732118e8e809a09ec4162bf2ca422
diff -r 756d3995e164 -r a80504924129 sysutils/libgtop/files/procaffinity.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sysutils/libgtop/files/procaffinity.c     Sun Nov 16 20:31:09 2008 +0000
@@ -0,0 +1,87 @@
+/* Copyright (C) 2008 Juan Romero Pardines <xtraeme%gmail.com@localhost>
+
+   This file is part of LibGTop 2.
+
+   LibGTop is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License,
+   or (at your option) any later version.
+
+   LibGTop is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+   for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with LibGTop; see the file COPYING. If not, write to the
+   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.
+*/
+
+#include <config.h>
+#include <glibtop/procaffinity.h>
+#include <glibtop/error.h>
+
+#include <sys/param.h>
+#if __NetBSD_Version__ >= 499007200    /* 4.99.72 to play safe */
+#include <sched.h>
+#endif
+
+void
+_glibtop_init_proc_affinity_s(glibtop *server)
+{
+  server->sysdeps.proc_affinity =
+    (1 << GLIBTOP_PROC_AFFINITY_NUMBER) |
+    (1 << GLIBTOP_PROC_AFFINITY_ALL);
+
+}
+
+
+guint16 *
+glibtop_get_proc_affinity_s(glibtop *server, glibtop_proc_affinity *buf, pid_t pid)
+{
+#if __NetBSD_Version__ >= 499007200
+  cpuset_t *cpuset;
+  size_t i;
+  GArray* cpus;
+
+  memset(buf, 0, sizeof *buf);
+
+  /* create the cpuset(3) */
+  cpuset = cpuset_create();
+  if (cpuset == NULL) {
+    glibtop_error_r(server, "cpuset_getaffinity (cpuset_create) failed");
+    return NULL;
+  }
+
+  /* get the affinity for _this_ pid, I assume that we always want lid 0 */
+  if ((_sched_getaffinity(pid, 0, cpuset_size(cpuset), cpuset)) != 0) {
+    cpuset_destroy(cpuset);
+    glibtop_error_r(server, "cpuset_getaffinity (_sched_getaffinity) failed");
+    return NULL;
+  }
+
+  cpus = g_array_new(FALSE, FALSE, sizeof(guint16));
+
+  for (i = 0; i < MIN(cpuset_size(cpuset), (size_t)(server->ncpu + 1)); i++) {
+    if (cpuset_isset(i, cpuset)) {
+      guint16 n = i;
+      g_array_append_val(cpus, n);
+    }
+  }
+
+  buf->number = cpus->len;
+  buf->all = (cpus->len == (size_t)(server->ncpu + 1));
+  buf->flags = (1 << GLIBTOP_PROC_AFFINITY_NUMBER)
+    | (1 << GLIBTOP_PROC_AFFINITY_ALL);
+
+  /* we are done */
+  cpuset_destroy(cpuset);
+
+  return (guint16*) g_array_free(cpus, FALSE);
+#else
+  memset(buf, 0, sizeof *buf);
+
+  return NULL;
+#endif
+}
diff -r 756d3995e164 -r a80504924129 sysutils/libgtop/patches/patch-ad
--- a/sysutils/libgtop/patches/patch-ad Sun Nov 16 20:11:31 2008 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-$NetBSD: patch-ad,v 1.7 2008/11/15 19:34:11 wiz Exp $
-
---- sysdeps/freebsd/procaffinity.c.orig        2008-08-18 15:23:36.000000000 +0000
-+++ sysdeps/freebsd/procaffinity.c
-@@ -21,7 +21,9 @@
- #include <glibtop/procaffinity.h>
- #include <glibtop/error.h>
- 
-+#if defined(__FreeBSD__)
- #include <glibtop_private.h>
-+#endif
- 
- #include <sys/param.h>
- #if __FreeBSD_version > 800024
-@@ -41,7 +43,7 @@ _glibtop_init_proc_affinity_s(glibtop *s
- guint16 *
- glibtop_get_proc_affinity_s(glibtop *server, glibtop_proc_affinity *buf, pid_t pid)
- {
--#if __FreeBSD_version > 800024
-+#if defined(__FreeBSD__) && __FreeBSD_version > 800024
-   id_t id;
-   cpulevel_t level;
-   cpuwhich_t which;



Home | Main Index | Thread Index | Old Index