2008-05-18 simon.zheng <[email protected]> VERMILLION_91
authorxz159989
Sun, 18 May 2008 15:27:27 +0000
changeset 12320 a219dc6af25b
parent 12319 d00cf4d2ab02
child 12321 f7977074dff8
2008-05-18 simon.zheng <[email protected]> * base-specs/gnome-power-manager.spec: * patches/gnome-power-manager-10-kstat-cpu.diff: Add a patch because accuracy calculation needs cpu statistics.
ChangeLog
base-specs/gnome-power-manager.spec
patches/gnome-power-manager-10-kstat-cpu.diff
--- a/ChangeLog	Fri May 16 19:51:29 2008 +0000
+++ b/ChangeLog	Sun May 18 15:27:27 2008 +0000
@@ -1,3 +1,9 @@
+2008-05-18  simon.zheng  <[email protected]>
+
+	* base-specs/gnome-power-manager.spec:
+	* patches/gnome-power-manager-10-kstat-cpu.diff:
+	  Add a patch because accuracy calculation needs cpu statistics.
+
 2008-05-16  Brian Cameron <[email protected]>
 
 	* manpages/man4/gnome-vfs-mime-magic.4,
--- a/base-specs/gnome-power-manager.spec	Fri May 16 19:51:29 2008 +0000
+++ b/base-specs/gnome-power-manager.spec	Sun May 18 15:27:27 2008 +0000
@@ -20,24 +20,26 @@
 %if %build_l10n
 Source1:                 l10n-configure.sh
 %endif
-# date:2008-02-14 owner:xz159989 type:branding
+# date:2008-02-14 owner:xz159989 type:feature
 Patch1:         gnome-power-manager-01-build.diff
-# date:2008-02-14 owner:xz159989 type:branding
+# date:2008-02-14 owner:xz159989 type:feature
 Patch2:		gnome-power-manager-02-icon_plicy_and_cpufreq_show.diff
-# date:2008-02-14 owner:xz159989 type:branding
+# date:2008-02-14 owner:xz159989 type:feature
 Patch3:         gnome-power-manager-03-disable-sleep-configration.diff
-# date:2008-02-14 owner:xz159989 type:branding
+# date:2008-02-14 owner:xz159989 type:feature
 Patch4:		gnome-power-manager-04-scripts.diff
-# date:2008-02-14 owner:xz159989 type:branding
+# date:2008-02-14 owner:xz159989 type:feature
 Patch5:        gnome-power-manager-05-diable-suspend-button-configration.diff
-# date:2008-05-07 owner:xz159989 type:branding
+# date:2008-05-07 owner:xz159989 type:feature
 Patch6:        gnome-power-manager-06-interactive-dialog.diff
-# date:2008-02-14 owner:xz159989 type:branding
+# date:2008-02-14 owner:xz159989 type:feature
 Patch7:        gnome-power-manager-07-screensaver.diff
-# date:2008-03-14 owner:xz159989 type:branding
+# date:2008-03-14 owner:xz159989 type:feature
 Patch8:        gnome-power-manager-08-sync-cpufreq.diff
-# date:2008-04-06 owner:xz159989 type:branding
+# date:2008-04-06 owner:xz159989 type:feature
 Patch9:        gnome-power-manager-09-authorization.diff
+# date:2008-05-17 owner:xz159989 type:feature
+Patch10:       gnome-power-manager-10-kstat-cpu.diff
 URL:		http://www.gnome.org/projects/gnome-power-manager/
 BuildRequires:	autoconf >= 2.52
 BuildRequires:	automake
@@ -100,6 +102,7 @@
 %patch7 -p0
 %patch8 -p0
 %patch9 -p0
+%patch10 -p0
 
 %build
 %ifos linux
@@ -163,6 +166,9 @@
 
 
 %changelog
+* Sun May 18 2008 - [email protected]
+- Add patch 10-kstat-cpu.diff because accuracy calculation
+  needs cpu load.
 * Wed May 07 2008 - [email protected]
 - Rework patch 06-interactive-dialog.diff.
 * Fri Apr 04 2008 - [email protected]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/gnome-power-manager-10-kstat-cpu.diff	Sun May 18 15:27:27 2008 +0000
@@ -0,0 +1,136 @@
+--- src/Makefile.am.orig	2008-05-18 03:15:44.506112000 +0800
++++ src/Makefile.am	2008-05-18 03:15:50.639100000 +0800
+@@ -118,6 +118,7 @@
+ 	$(GPM_EXTRA_LIBS)				\
+ 	$(LOCAL_LIBHAL_LIBS)				\
+ 	$(LOCAL_LIBDBUS_LIBS)				\
++	-lkstat						\
+ 	$(NULL)
+ 
+ if HAVE_GTKUNIQUE
+@@ -218,6 +219,7 @@
+ 	$(GPM_EXTRA_LIBS)				\
+ 	$(LOCAL_LIBHAL_LIBS)				\
+ 	$(LOCAL_LIBDBUS_LIBS)				\
++	-lkstat						\
+ 	$(NULL)
+ 
+ if HAVE_LIBNOTIFY
+@@ -297,6 +299,7 @@
+ 	$(LIBNOTIFY_LIBS)				\
+ 	$(LOCAL_LIBDBUS_LIBS)				\
+ 	$(LOCAL_LIBHAL_LIBS)				\
++	-lkstat						\
+ 	$(NULL)
+ 
+ gnome_power_self_test_CPPFLAGS=	\
+--- src/gpm-load.c.org	2007-05-12 17:43:41.846780000 +0800
++++ src/gpm-load.c	2007-05-12 17:43:46.035683000 +0800
+@@ -29,6 +29,10 @@
+ #include <string.h>
+ #include <sys/time.h>
+ #include <sys/types.h>
++#ifdef SOLARIS
++#include <kstat.h>
++#include <sys/sysinfo.h>
++#endif
+ #ifdef HAVE_UNISTD_H
+ #include <unistd.h>
+ #endif /* HAVE_UNISTD_H */
+@@ -75,6 +79,88 @@
+ 	g_type_class_add_private (klass, sizeof (GpmLoadPrivate));
+ }
+ 
++#ifdef SOLARIS
++
++/**
++ * 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 /proc/stat.
++ **/
++static gboolean
++gpm_load_get_cpu_values (long unsigned *cpu_idle, long unsigned *cpu_total)
++{	
++	long unsigned cpu_user = 0;
++	long unsigned cpu_kernel = 0;
++	long unsigned cpu_wait = 0;
++	kstat_ctl_t *kc = NULL;
++	kstat_named_t *kn = NULL;
++	kstat_t     *ks = NULL;
++	cpu_stat_t  data;
++	int ncpus;
++	int count;
++	   	
++	kc = kstat_open();
++	if (!kc){
++		gpm_warning ("Cannot open kstat!\n");
++		return FALSE;
++	}
++
++	ks = kstat_lookup(kc, "unix", 0, "system_misc");
++  	if (kstat_read(kc, ks, NULL) == -1) {
++		gpm_warning ("Cannot read kstat on module unix!\n");
++		goto out;
++	}
++	kn = kstat_data_lookup (ks, "ncpus");
++	if (!kn) {
++		gpm_warning ("Cannot get number of cpus in current system!\n");
++		goto out;
++	}
++	ncpus = kn->value.ui32;
++
++	/* 
++ 	 * To aggresive ticks used of all cpus,
++	 * traverse kstat chain to access very cpu_stat instane.
++	 */
++	for(count = 0, *cpu_idle =0, *cpu_total = 0; count < ncpus; count++){
++		
++		ks = kstat_lookup(kc, "cpu_stat", count, NULL);
++		if (ks == NULL) {
++			gpm_warning ("Null output for kstat on cpu%d\n", count);
++			goto out;
++		}
++     
++		if (kstat_read(kc, ks, &data) == -1) {
++			gpm_warning ("Cannot read kstat entry on cpu%d\n", count);
++			goto out;
++		}
++
++		gpm_debug ("cpu%d:\t%lu\t%lu\t%lu\t%lu\n", count,
++					data.cpu_sysinfo.cpu[CPU_IDLE],
++					data.cpu_sysinfo.cpu[CPU_USER],
++					data.cpu_sysinfo.cpu[CPU_KERNEL],
++					data.cpu_sysinfo.cpu[CPU_WAIT]);
++
++		*cpu_idle += data.cpu_sysinfo.cpu[CPU_IDLE];
++		cpu_user += data.cpu_sysinfo.cpu[CPU_USER];
++		cpu_kernel += data.cpu_sysinfo.cpu[CPU_KERNEL];
++		cpu_wait += data.cpu_sysinfo.cpu[CPU_WAIT];
++	}
++	kstat_close(kc);
++	/*
++         * Summing up all these times gives you the system uptime.
++         * This is what the uptime command does.
++         */
++        *cpu_total = cpu_user + cpu_kernel + cpu_wait + *cpu_idle;
++        return TRUE;
++
++out:
++	kstat_close(kc);
++	return FALSE;
++}
++
++#else
++
+ /**
+  * gpm_load_get_cpu_values:
+  * @cpu_idle: The idle time reported by the CPU
+@@ -108,6 +194,7 @@
+ 	*cpu_total = cpu_user + cpu_nice + cpu_system + *cpu_idle;
+ 	return TRUE;
+ }
++#endif
+ 
+ /**
+  * gpm_load_get_current: