From b5bbd617b219f1c94d3e21b2fc8284014cb61a40 Mon Sep 17 00:00:00 2001 From: marcus Date: Mon, 29 Sep 2008 17:52:59 +0000 Subject: Fix CPU detection so that we can properly report stats for multiple CPUs. git-svn-id: svn://creme-brulee.marcuscom.com/ports/trunk@11653 df743ca5-7f9a-e211-a948-0013205c9059 --- devel/libgtop/files/patch-sysdeps_freebsd_open.c | 36 ++++++++++++++++++++++ .../libgtop/files/patch-sysdeps_freebsd_sysinfo.c | 13 ++++++++ 2 files changed, 49 insertions(+) create mode 100644 devel/libgtop/files/patch-sysdeps_freebsd_open.c create mode 100644 devel/libgtop/files/patch-sysdeps_freebsd_sysinfo.c (limited to 'devel/libgtop/files') diff --git a/devel/libgtop/files/patch-sysdeps_freebsd_open.c b/devel/libgtop/files/patch-sysdeps_freebsd_open.c new file mode 100644 index 000000000..eee11421d --- /dev/null +++ b/devel/libgtop/files/patch-sysdeps_freebsd_open.c @@ -0,0 +1,36 @@ +--- sysdeps/freebsd/open.c.orig 2008-09-29 13:44:47.000000000 -0400 ++++ sysdeps/freebsd/open.c 2008-09-29 13:49:37.000000000 -0400 +@@ -20,11 +20,14 @@ + */ + + #include ++#include ++#include + #include + #include + #include + #include + ++ + /* !!! THIS FUNCTION RUNS SUID ROOT - CHANGE WITH CAUTION !!! */ + + void +@@ -53,11 +56,18 @@ glibtop_open_p (glibtop *server, const c + const unsigned long features, + const unsigned flags) + { ++ guint64 ncpus; ++ size_t len; + #ifdef DEBUG + fprintf (stderr, "DEBUG (%d): glibtop_open_p ()\n", getpid ()); + #endif + + /* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */ ++ len = sizeof (ncpus); ++ sysctlbyname ("hw.ncpu", &ncpus, &len, NULL, 0); ++ server->ncpu = ncpus; ++ /* XXX We should detect HTT CPUs here. */ ++ server->real_ncpu = ncpus; + + server->machine.uid = getuid (); + server->machine.euid = geteuid (); diff --git a/devel/libgtop/files/patch-sysdeps_freebsd_sysinfo.c b/devel/libgtop/files/patch-sysdeps_freebsd_sysinfo.c new file mode 100644 index 000000000..3d6026e4c --- /dev/null +++ b/devel/libgtop/files/patch-sysdeps_freebsd_sysinfo.c @@ -0,0 +1,13 @@ +--- sysdeps/freebsd/sysinfo.c.orig 2008-09-29 13:44:45.000000000 -0400 ++++ sysdeps/freebsd/sysinfo.c 2008-09-29 13:50:06.000000000 -0400 +@@ -45,8 +45,8 @@ init_sysinfo (glibtop *server) + + glibtop_init_s (&server, GLIBTOP_SYSDEPS_CPU, 0); + +- len = sizeof (ncpus); +- sysctlbyname ("hw.ncpu", &ncpus, &len, NULL, 0); ++ ncpus = server->ncpu; ++ + len = 0; + sysctlbyname ("hw.model", NULL, &len, NULL, 0); + model = g_malloc (len); -- cgit v1.2.3