Get page size from sysconf.

This commit is contained in:
steve 2007-02-16 23:29:17 +00:00
parent e99f0a8f51
commit d72eadb885
1 changed files with 9 additions and 4 deletions

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: main.cc,v 1.39 2004/10/04 01:10:59 steve Exp $" #ident "$Id: main.cc,v 1.39.2.1 2007/02/16 23:29:17 steve Exp $"
#endif #endif
# include "config.h" # include "config.h"
@ -66,15 +66,17 @@ static void my_getrusage(struct rusage *a)
{ {
FILE *statm; FILE *statm;
unsigned siz, rss, shd; unsigned siz, rss, shd;
long page_size = sysconf(_SC_PAGESIZE);
if (page_size==-1) page_size=0;
statm = fopen("/proc/self/statm", "r"); statm = fopen("/proc/self/statm", "r");
if (!statm) { if (!statm) {
perror("/proc/self/statm"); perror("/proc/self/statm");
return; return;
} }
if (3<=fscanf(statm, "%u%u%u", &siz, &rss, &shd)) { if (3<=fscanf(statm, "%u%u%u", &siz, &rss, &shd)) {
a->ru_maxrss = PAGE_SIZE * siz; a->ru_maxrss = page_size * siz;
a->ru_idrss = PAGE_SIZE * rss; a->ru_idrss = page_size * rss;
a->ru_ixrss = PAGE_SIZE * shd; a->ru_ixrss = page_size * shd;
} }
fclose(statm); fclose(statm);
} }
@ -277,6 +279,9 @@ int main(int argc, char*argv[])
/* /*
* $Log: main.cc,v $ * $Log: main.cc,v $
* Revision 1.39.2.1 2007/02/16 23:29:17 steve
* Get page size from sysconf.
*
* Revision 1.39 2004/10/04 01:10:59 steve * Revision 1.39 2004/10/04 01:10:59 steve
* Clean up spurious trailing white space. * Clean up spurious trailing white space.
* *