diff options
author | wiz <wiz@pkgsrc.org> | 2008-11-16 20:31:09 +0000 |
---|---|---|
committer | wiz <wiz@pkgsrc.org> | 2008-11-16 20:31:09 +0000 |
commit | 07985d295a8156287390f8e19f2d7e4b3fbfb9ba (patch) | |
tree | 5ed3cb915b2afdc62ef9ed8b548d83c6ae7187dd /sysutils/libgtop | |
parent | e1de0185046e5ab3641ccc2c7723979da5456e67 (diff) | |
download | pkgsrc-07985d295a8156287390f8e19f2d7e4b3fbfb9ba.tar.gz |
Add processor affinity support, from Juan Romero Pardines -- thank you!
Bump PKGREVISION.
Diffstat (limited to 'sysutils/libgtop')
-rw-r--r-- | sysutils/libgtop/Makefile | 6 | ||||
-rw-r--r-- | sysutils/libgtop/distinfo | 3 | ||||
-rw-r--r-- | sysutils/libgtop/files/procaffinity.c | 87 | ||||
-rw-r--r-- | sysutils/libgtop/patches/patch-ad | 23 |
4 files changed, 91 insertions, 28 deletions
diff --git a/sysutils/libgtop/Makefile b/sysutils/libgtop/Makefile index c57c3de3d01..8fe08c3d555 100644 --- a/sysutils/libgtop/Makefile +++ b/sysutils/libgtop/Makefile @@ -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 @@ CONFIGURE_ENV+= LN_S="${LN} -s" 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 --git a/sysutils/libgtop/distinfo b/sysutils/libgtop/distinfo index 6cee1c125d6..33dbe021fdd 100644 --- a/sysutils/libgtop/distinfo +++ b/sysutils/libgtop/distinfo @@ -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 @@ Size (libgtop-2.24.0.tar.bz2) = 775351 bytes 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 --git a/sysutils/libgtop/files/procaffinity.c b/sysutils/libgtop/files/procaffinity.c new file mode 100644 index 00000000000..141341d9e7b --- /dev/null +++ b/sysutils/libgtop/files/procaffinity.c @@ -0,0 +1,87 @@ +/* Copyright (C) 2008 Juan Romero Pardines <xtraeme@gmail.com> + + 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 --git a/sysutils/libgtop/patches/patch-ad b/sysutils/libgtop/patches/patch-ad deleted file mode 100644 index c08a9198aa6..00000000000 --- a/sysutils/libgtop/patches/patch-ad +++ /dev/null @@ -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; |