From dc8c4a5de536a270a709a63b9d217627cc925a29 Mon Sep 17 00:00:00 2001 From: Bernard Cafarelli Date: Wed, 18 Apr 2012 09:32:31 +0000 Subject: Fix memory usage monitor, report and patch by wbk in bug #410093 Package-Manager: portage-2.2.0_alpha100/cvs/Linux x86_64 --- x11-plugins/wmtop/ChangeLog | 10 +- x11-plugins/wmtop/Manifest | 14 +- x11-plugins/wmtop/files/wmtop-0.9.0-meminfo.patch | 189 ++++++++++++++++++++++ x11-plugins/wmtop/wmtop-0.9.0-r1.ebuild | 39 +++++ 4 files changed, 249 insertions(+), 3 deletions(-) create mode 100644 x11-plugins/wmtop/files/wmtop-0.9.0-meminfo.patch create mode 100644 x11-plugins/wmtop/wmtop-0.9.0-r1.ebuild (limited to 'x11-plugins/wmtop') diff --git a/x11-plugins/wmtop/ChangeLog b/x11-plugins/wmtop/ChangeLog index cb8ee7199df0..60e47a54da4c 100644 --- a/x11-plugins/wmtop/ChangeLog +++ b/x11-plugins/wmtop/ChangeLog @@ -1,6 +1,12 @@ # ChangeLog for x11-plugins/wmtop -# Copyright 2002-2010 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/x11-plugins/wmtop/ChangeLog,v 1.14 2010/09/06 07:59:28 s4t4n Exp $ +# Copyright 1999-2012 Gentoo Foundation; Distributed under the GPL v2 +# $Header: /var/cvsroot/gentoo-x86/x11-plugins/wmtop/ChangeLog,v 1.15 2012/04/18 09:32:30 voyageur Exp $ + +*wmtop-0.9.0-r1 (18 Apr 2012) + + 18 Apr 2012; Bernard Cafarelli +wmtop-0.9.0-r1.ebuild, + +files/wmtop-0.9.0-meminfo.patch: + Fix memory usage monitor, report and patch by wbk in bug #410093 06 Sep 2010; Michele Noberasco wmtop-0.9.0.ebuild: Honour Gentoo LDFLAGS. Closes bug #335953. diff --git a/x11-plugins/wmtop/Manifest b/x11-plugins/wmtop/Manifest index bec378cb2488..d23e95a7d4c9 100644 --- a/x11-plugins/wmtop/Manifest +++ b/x11-plugins/wmtop/Manifest @@ -1,4 +1,16 @@ +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA256 + +AUX wmtop-0.9.0-meminfo.patch 5780 RMD160 b2195718a67085affb94fb29e8501450777c15f9 SHA1 fa2616ffeca41f660a4f6a7a9c9c771f413e5bf9 SHA256 c80d2c15d8d5572b56789e670f4572d5293d7b60f21e567e51ef9c5668a0ff59 DIST wmtop-0.9.0.tar.gz 25833 RMD160 af7470bd34870ca487e9cf6984c4947672631472 SHA1 fe83d660572093d9a23b5791d8190dd34e2ed6a2 SHA256 b141e608b32c1d58c03c31c18b420d25a490bfe49a63a56cef5b8f86935752de +EBUILD wmtop-0.9.0-r1.ebuild 1020 RMD160 95959be27e82966cc00d0d9763e5402f73b19fdc SHA1 4253bbf23defc4eab1c63e366949aaa044cd4802 SHA256 2d7753a6ed5a8765c601436bacede757dad7944f19d64f13376d9987fb634773 EBUILD wmtop-0.9.0.ebuild 965 RMD160 6cca43e47df20cb336028db6455127f015502b13 SHA1 59114982b6802087f4a41faf74d886e74ef92eb8 SHA256 e5e03ef074f1bd6b08edce388e7e8bb70db26f7f27c0a95eb522481f3749f153 -MISC ChangeLog 1650 RMD160 fcf34bfe7150d79186fcb56d343d51bf856c6fcc SHA1 3214d5601fd525ff0b20ebdfbb3e68647a508f29 SHA256 b9cac748e4561c670247c16f67dd00c3f9af48269d285585a84ce9063c24cbbf +MISC ChangeLog 1867 RMD160 bbfa7debc6e70f33987456113978afa7b0f45ce9 SHA1 10d799b3ec12d512eff203ce3471650baaf4c596 SHA256 15ac60d540bf7c022b96d0e5fc895e91d89fff66a1c17d14c0c5a951364f996e MISC metadata.xml 555 RMD160 ef338820040dcb4f2fbec61ef4d3bb203570631e SHA1 eec568a7e2327f7008ca7bce859d4099088e0356 SHA256 0291ea9b9e27bf3192522e7a8587654c66c113a52784b44c1f085f226ea63d33 +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v2.0.19 (GNU/Linux) + +iF4EAREIAAYFAk+OijsACgkQFYEBGcdFJfIsyAD+PCx8RPtJ+roIvo70KrbA31Cm +RwTbRYguDCW/N5nNLYIBAIu9dN0lAmj7Yan52bwuJYRnGCY6wME8SeHCJOUgMmVa +=X6JP +-----END PGP SIGNATURE----- diff --git a/x11-plugins/wmtop/files/wmtop-0.9.0-meminfo.patch b/x11-plugins/wmtop/files/wmtop-0.9.0-meminfo.patch new file mode 100644 index 000000000000..541ab6a1d697 --- /dev/null +++ b/x11-plugins/wmtop/files/wmtop-0.9.0-meminfo.patch @@ -0,0 +1,189 @@ +--- wmtop.c.orig 2001-01-19 15:41:20.000000000 -0600 ++++ wmtop.c 2012-03-29 22:36:49.906684353 -0500 +@@ -182,12 +182,12 @@ + pid_t pid; + char *name; + float amount; +- int user_time; +- int kernel_time; +- int previous_user_time; +- int previous_kernel_time; +- int vsize; +- int rss; ++ unsigned long user_time; ++ unsigned long kernel_time; ++ unsigned long previous_user_time; ++ unsigned long previous_kernel_time; ++ unsigned long vsize; ++ long rss; + int time_stamp; + int counted; + }; +@@ -236,8 +236,8 @@ + + process->pid = p; + process->time_stamp = 0; +- process->previous_user_time = INT_MAX; +- process->previous_kernel_time = INT_MAX; ++ process->previous_user_time = ULONG_MAX; ++ process->previous_kernel_time = ULONG_MAX; + process->counted = 1; + + /* process_find_name(process);*/ +@@ -256,11 +256,11 @@ + void process_cleanup(void); + void delete_process(struct process *); + inline void draw_processes(void); +-int calc_cpu_total(void); +-void calc_cpu_each(int); ++unsigned long calc_cpu_total(void); ++void calc_cpu_each(unsigned long total); + #if defined(LINUX) +-int calc_mem_total(void); +-void calc_mem_each(int); ++unsigned long calc_mem_total(void); ++void calc_mem_each(unsigned long total); + #endif + int process_find_top_three(struct process **); + void draw_bar(int, int, int, int, float, int, int); +@@ -457,13 +457,15 @@ + char line[WMTOP_BUFLENGTH],filename[WMTOP_BUFLENGTH],procname[WMTOP_BUFLENGTH]; + int ps; + struct stat sbuf; +- int user_time,kernel_time; ++ unsigned long user_time,kernel_time; + int rc; + #if defined(LINUX) + char *r,*q; + char deparenthesised_name[WMTOP_BUFLENGTH]; + #endif /* defined(LINUX) */ + #if defined(FREEBSD) ++ /* TODO: needs analysis. Probably needs same data type fix as LINUX (use ++ * long types). Need to check FreeBSD docs and test. -wbk */ + int us,um,ks,km; + #endif /* defined(FREEBSD) */ + +@@ -501,9 +503,10 @@ + + #if defined(LINUX) + /* +- * Extract cpu times from data in /proc filesystem ++ * Extract cpu times from data in /proc filesystem. ++ * For conversion types see man proc(5). + */ +- rc = sscanf(line,"%*s %s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %d %d %*s %*s %*s %*s %*s %*s %*s %d %d", ++ rc = sscanf(line,"%*s %s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %lu %lu %*s %*s %*s %*s %*s %*s %*s %lu %ld", + procname, + &process->user_time,&process->kernel_time, + &process->vsize,&process->rss); +@@ -527,6 +530,9 @@ + /* + * Extract cpu times from data in /proc//stat + * XXX: Process name extractor for FreeBSD is untested right now. ++ * ++ * [TODO: FREEBSD code probably needs similar data type changes to ++ * those made for LINUX above. Need to check docs. -wbk] + */ + rc = sscanf(line,"%s %*s %*s %*s %*s %*s %*s %*s %d,%d %d,%d", + procname, +@@ -540,11 +546,14 @@ + process->kernel_time = ks*1000+km/1000; + #endif /* defined(FREEBSD) */ + ++ /* not portable (especially unsuitable for redistributable executables. ++ * On some systems, getpagesize() is a preprocessor macro). ++ */ + process->rss *= getpagesize(); + +- if (process->previous_user_time==INT_MAX) ++ if (process->previous_user_time==ULONG_MAX) + process->previous_user_time = process->user_time; +- if (process->previous_kernel_time==INT_MAX) ++ if (process->previous_kernel_time==ULONG_MAX) + process->previous_kernel_time = process->kernel_time; + + user_time = process->user_time-process->previous_user_time; +@@ -686,7 +695,7 @@ + void draw_processes() { + int i,n; + struct process *best[3] = { 0, 0, 0 }; +- int total; ++ unsigned long total; + + /* + * Invalidate time stamps +@@ -743,21 +752,21 @@ + /* Calculate cpu total */ + /******************************************/ + +-int calc_cpu_total() { +- int total,t; +- static int previous_total = INT_MAX; ++unsigned long calc_cpu_total() { ++ unsigned long total,t; ++ static unsigned long previous_total = ULONG_MAX; + #if defined(LINUX) + int rc; + int ps; + char line[WMTOP_BUFLENGTH]; +- int cpu,nice,system,idle; ++ unsigned long cpu,nice,system,idle; + + ps = open("/proc/stat",O_RDONLY); + rc = read(ps,line,sizeof(line)); + close(ps); + if (rc<0) + return 0; +- sscanf(line,"%*s %d %d %d %d",&cpu,&nice,&system,&idle); ++ sscanf(line,"%*s %lu %lu %lu %lu",&cpu,&nice,&system,&idle); + total = cpu+nice+system+idle; + #endif /* defined(LINUX) */ + +@@ -780,7 +789,7 @@ + /* Calculate each processes cpu */ + /******************************************/ + +-void calc_cpu_each(int total) { ++void calc_cpu_each(unsigned long total) { + struct process *p = first_process; + while (p) { + +@@ -798,7 +807,8 @@ + /******************************************/ + + #if defined(LINUX) +-int calc_mem_total() { ++/* INT_MAX won't always hold total system RAM, especially on a 64 bit system. */ ++unsigned long calc_mem_total() { + int ps; + char line[512]; + char *ptr; +@@ -810,11 +820,12 @@ + if (rc<0) + return 0; + +- if ((ptr = strstr(line, "Mem:")) == NULL) { ++ if ((ptr = strstr(line, "MemTotal:")) == NULL) { + return 0; + } else { +- ptr += 4; +- return atoi(ptr); ++ ptr += 9; /* move into whitespace */ ++ /* wbk - old Mem: Total was bytes. MemTotal: is KB */ ++ return (unsigned long)atoi(ptr) * 1024; + } + + } +@@ -825,10 +836,10 @@ + /******************************************/ + + #if defined(LINUX) +-void calc_mem_each(int total) { ++void calc_mem_each(unsigned long total) { + struct process *p = first_process; + while (p) { +- p->amount = 100*(float)p->rss/total; ++ p->amount = 100*(double)p->rss/total; + p = p->next; + } + } diff --git a/x11-plugins/wmtop/wmtop-0.9.0-r1.ebuild b/x11-plugins/wmtop/wmtop-0.9.0-r1.ebuild new file mode 100644 index 000000000000..662df9cd6d52 --- /dev/null +++ b/x11-plugins/wmtop/wmtop-0.9.0-r1.ebuild @@ -0,0 +1,39 @@ +# Copyright 1999-2012 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/x11-plugins/wmtop/wmtop-0.9.0-r1.ebuild,v 1.1 2012/04/18 09:32:30 voyageur Exp $ + +EAPI=4 +inherit eutils multilib toolchain-funcs + +DESCRIPTION="dockapp for monitoring the top three processes using cpu or memory." +HOMEPAGE="http://www.swanson.ukfsn.org/#wmtop" +SRC_URI="http://www.swanson.ukfsn.org/wmdock/${P}.tar.gz" + +LICENSE="GPL-2" +SLOT="0" +KEYWORDS="~amd64 ~ppc ~sparc ~x86" +IUSE="" + +RDEPEND="x11-libs/libX11 + x11-libs/libXpm + x11-libs/libXext" +DEPEND="${RDEPEND} + x11-proto/xproto + x11-proto/xextproto" + +src_prepare() { + sed -ie "s/\$(FLAGS) -o wmtop/\$(DEBUG) \$(LDFLAGS) -D\$(OS) -o wmtop/" Makefile || die "sed failed" + epatch "${FILESDIR}"/${P}-meminfo.patch +} + +src_compile() { + emake CC="$(tc-getCC)" OPTS="${CFLAGS}" \ + LIBDIR="-L/usr/$(get_libdir)" \ + INCS="-I/usr/include/X11" linux +} + +src_install() { + dobin ${PN} + doman ${PN}.1 + dodoc BUGS CHANGES README TODO +} -- cgit v1.2.3-65-gdbad