diff options
author | marcus <marcus@df743ca5-7f9a-e211-a948-0013205c9059> | 2010-01-02 12:49:32 +0800 |
---|---|---|
committer | marcus <marcus@df743ca5-7f9a-e211-a948-0013205c9059> | 2010-01-02 12:49:32 +0800 |
commit | 8accbdf7fd8a1099e6992c8a42c2670c2103ed0e (patch) | |
tree | 1d8c3f6f2d3222aa0db522e182266da8c6d8a4c5 /sysutils/gnome-power-manager | |
parent | a88a7e4f7d83f8bcfad7fe2c2eb1a0c9a46110a3 (diff) | |
download | marcuscom-ports-8accbdf7fd8a1099e6992c8a42c2670c2103ed0e.tar marcuscom-ports-8accbdf7fd8a1099e6992c8a42c2670c2103ed0e.tar.gz marcuscom-ports-8accbdf7fd8a1099e6992c8a42c2670c2103ed0e.tar.bz2 marcuscom-ports-8accbdf7fd8a1099e6992c8a42c2670c2103ed0e.tar.lz marcuscom-ports-8accbdf7fd8a1099e6992c8a42c2670c2103ed0e.tar.xz marcuscom-ports-8accbdf7fd8a1099e6992c8a42c2670c2103ed0e.tar.zst marcuscom-ports-8accbdf7fd8a1099e6992c8a42c2670c2103ed0e.zip |
Add code to read CPU states from sysctl instead of /proc. While here, help
the Linux boys out some, and plug a file descriptor leak.
git-svn-id: svn://creme-brulee.marcuscom.com/ports/trunk@13339 df743ca5-7f9a-e211-a948-0013205c9059
Diffstat (limited to 'sysutils/gnome-power-manager')
-rw-r--r-- | sysutils/gnome-power-manager/Makefile | 3 | ||||
-rw-r--r-- | sysutils/gnome-power-manager/files/patch-src_gpm-load.c | 55 |
2 files changed, 57 insertions, 1 deletions
diff --git a/sysutils/gnome-power-manager/Makefile b/sysutils/gnome-power-manager/Makefile index f7f92ffc5..ad0bd1e9f 100644 --- a/sysutils/gnome-power-manager/Makefile +++ b/sysutils/gnome-power-manager/Makefile @@ -3,11 +3,12 @@ # Whom: Joe Marcus Clarke <marcus@FreeBSD.org> # # $FreeBSD$ -# $MCom: ports/sysutils/gnome-power-manager/Makefile,v 1.54 2009/10/25 00:02:31 marcus Exp $ +# $MCom: ports/sysutils/gnome-power-manager/Makefile,v 1.56 2010/01/01 16:56:03 avl Exp $ # PORTNAME= gnome-power-manager PORTVERSION= 2.29.1 +PORTREVISION= 1 CATEGORIES= sysutils gnome MASTER_SITES= GNOME DIST_SUBDIR= gnome2 diff --git a/sysutils/gnome-power-manager/files/patch-src_gpm-load.c b/sysutils/gnome-power-manager/files/patch-src_gpm-load.c new file mode 100644 index 000000000..eaa8df1b2 --- /dev/null +++ b/sysutils/gnome-power-manager/files/patch-src_gpm-load.c @@ -0,0 +1,55 @@ +--- src/gpm-load.c.orig 2010-01-01 23:29:11.000000000 -0500 ++++ src/gpm-load.c 2010-01-01 23:46:31.000000000 -0500 +@@ -33,6 +33,10 @@ + #include <kstat.h> + #include <sys/sysinfo.h> + #endif ++#if defined(__FreeBSD__) ++#include <sys/resource.h> ++#include <sys/sysctl.h> ++#endif + #ifdef HAVE_UNISTD_H + #include <unistd.h> + #endif /* HAVE_UNISTD_H */ +@@ -151,6 +155,32 @@ out: + return FALSE; + } + ++#elif defined(__FreeBSD__) ++ ++/** ++ * gpm_load_get_cpu_values: ++ * @cpu_idle: The idle time reported by the CPU ++ * @cpu_total: The total time reported by the CPU ++ * Return value: Success of reading of the kern.cp_time sysctl. ++ **/ ++static gboolean ++gpm_load_get_cpu_values (long unsigned *cpu_idle, long unsigned *cpu_total) ++{ ++ long cpts[CPUSTATES]; ++ size_t length; ++ ++ length = sizeof (cpts); ++ if (sysctlbyname ("kern.cp_time", cpts, &length, NULL, 0)) { ++ return FALSE; ++ } ++ ++ *cpu_idle = (unsigned long) cpts[CP_IDLE]; ++ *cpu_total = (unsigned long) (cpts[CP_USER] + cpts[CP_NICE] + \ ++ cpts[CP_SYS] + cpts[CP_IDLE] + cpts[CP_INTR]); ++ ++ return TRUE; ++} ++ + #else + + /** +@@ -192,7 +222,7 @@ gpm_load_get_cpu_values (long unsigned * + *cpu_total = cpu_user + cpu_nice + cpu_system + *cpu_idle; + ret = TRUE; + out: +- if (!fd) ++ if (fd) + fclose (fd); + return ret; + } |