From 67a86f31d7a74857b857894f8470fbc4e1a893b5 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Sat, 21 Apr 2007 15:30:14 +0000 Subject: [PATCH] use getpagesize() instead of PAGE_SHIFT --- src/os/linux/linux_sigar.c | 11 ++++++++--- src/os/linux/sigar_os.h | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/os/linux/linux_sigar.c b/src/os/linux/linux_sigar.c index 3949b6d4..61b174c8 100644 --- a/src/os/linux/linux_sigar.c +++ b/src/os/linux/linux_sigar.c @@ -29,9 +29,7 @@ #include "sigar_util.h" #include "sigar_os.h" -#include /* for PAGE_SHIFT */ - -#define pageshift(x) ((x) << PAGE_SHIFT) +#define pageshift(x) ((x) << sigar->pagesize) #define PROC_MEMINFO PROC_FS_ROOT "meminfo" #define PROC_MTRR PROC_FS_ROOT "mtrr" @@ -125,6 +123,7 @@ sigar_pid_t sigar_pid_get(sigar_t *sigar) int sigar_os_open(sigar_t **sigar) { char buffer[BUFSIZ], *ptr; + int i; int status = sigar_file2str(PROC_STAT, buffer, sizeof(buffer)); struct stat sb; @@ -134,6 +133,12 @@ int sigar_os_open(sigar_t **sigar) return status; } + (*sigar)->pagesize = 0; + i = sysconf(_SC_PAGESIZE); + while ((i >>= 1) > 0) { + (*sigar)->pagesize++; + } + ptr = strstr(buffer, "\nbtime"); ptr = sigar_skip_token(ptr); (*sigar)->boot_time = sigar_strtoul(ptr); diff --git a/src/os/linux/sigar_os.h b/src/os/linux/sigar_os.h index cf500982..031f78e4 100644 --- a/src/os/linux/sigar_os.h +++ b/src/os/linux/sigar_os.h @@ -60,6 +60,7 @@ typedef enum { struct sigar_t { SIGAR_T_BASE; + int pagesize; int ram; int proc_signal_offset; linux_proc_stat_t last_proc_stat;