From a715b55029882ef32b5500de68867ad398c5b96a Mon Sep 17 00:00:00 2001 From: Soren Sandmann Date: Wed, 25 Oct 2006 02:02:44 +0000 Subject: [PATCH] replace PAGE_SIZE macro with this function. 2006-10-24 Soren Sandmann * process.c (page_size): replace PAGE_SIZE macro with this function. * binfile.c: Remove obsolete comment. --- ChangeLog | 6 ++++++ binfile.c | 1 - process.c | 19 ++++++++++++++++--- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2676df2c..44bcb5b3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-10-24 Soren Sandmann + + * process.c (page_size): replace PAGE_SIZE macro with this function. + + * binfile.c: Remove obsolete comment. + 2006-10-24 Soren Sandmann * process.c (struct Process): Use an array instead of list of diff --git a/binfile.c b/binfile.c index 94866d97..325e2ecf 100644 --- a/binfile.c +++ b/binfile.c @@ -90,7 +90,6 @@ separate_debug_file_exists (const char *name, guint32 crc) return parser; } -/* FIXME - not10: this should probably be detected by config.h -- find out what gdb does*/ static const char *const debug_file_directory = DEBUGDIR; static ElfParser * diff --git a/process.c b/process.c index 1478b9a5..a0cc081f 100644 --- a/process.c +++ b/process.c @@ -30,8 +30,6 @@ #include "process.h" #include "binfile.h" -#define PAGE_SIZE (getpagesize()) - static GHashTable *processes_by_cmdline; static GHashTable *processes_by_pid; @@ -281,12 +279,27 @@ process_has_page (Process *process, gulong addr) return FALSE; } +static int +page_size (void) +{ + static int page_size; + static gboolean has_page_size; + + if (!has_page_size) + { + page_size = getpagesize(); + has_page_size = TRUE; + } + + return page_size; +} + void process_ensure_map (Process *process, int pid, gulong addr) { /* Round down to closest page */ - addr = (addr - addr % PAGE_SIZE); + addr = (addr - addr % page_size()); if (process_has_page (process, addr)) return;