summaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/linux/ChangeLog9
-rw-r--r--sysdeps/linux/glibtop_private.c14
-rw-r--r--sysdeps/linux/glibtop_private.h4
-rw-r--r--sysdeps/linux/procmem.c2
-rw-r--r--sysdeps/linux/procsegment.c2
5 files changed, 29 insertions, 2 deletions
diff --git a/sysdeps/linux/ChangeLog b/sysdeps/linux/ChangeLog
index 3e1a5308..60f03ce3 100644
--- a/sysdeps/linux/ChangeLog
+++ b/sysdeps/linux/ChangeLog
@@ -1,3 +1,12 @@
+2005-07-22 Benoît Dejean <TazForEver@dlfp.org>
+
+ * glibtop_private.c: (get_page_size):
+ * glibtop_private.h:
+ * procmem.c: (glibtop_get_proc_mem_s):
+ * procsegment.c: (glibtop_get_proc_segment_s):
+
+ Cached getpagesize().
+
2005-07-09 Benoît Dejean <TazForEver@dlfp.org>
* netload.c: (read_value), (linux_2_6_stats), (linux_2_0_stats),
diff --git a/sysdeps/linux/glibtop_private.c b/sysdeps/linux/glibtop_private.c
index 645b14c3..2deea49c 100644
--- a/sysdeps/linux/glibtop_private.c
+++ b/sysdeps/linux/glibtop_private.c
@@ -10,6 +10,7 @@
#include <stdarg.h>
#include <fcntl.h>
+#include <unistd.h>
unsigned long long
@@ -129,3 +130,16 @@ get_boot_time(glibtop *server)
return boot_time;
}
+
+size_t
+get_page_size(void)
+{
+ static size_t pagesize = 0;
+
+ if(G_UNLIKELY(!pagesize))
+ {
+ pagesize = getpagesize();
+ }
+
+ return pagesize;
+}
diff --git a/sysdeps/linux/glibtop_private.h b/sysdeps/linux/glibtop_private.h
index a207d7d4..ac22af7b 100644
--- a/sysdeps/linux/glibtop_private.h
+++ b/sysdeps/linux/glibtop_private.h
@@ -117,6 +117,10 @@ unsigned long
get_boot_time(glibtop *server) G_GNUC_INTERNAL;
+size_t
+get_page_size(void) G_GNUC_INTERNAL;
+
+
G_END_DECLS
#endif /* __LINUX__GLIBTOP_PRIVATE_H__ */
diff --git a/sysdeps/linux/procmem.c b/sysdeps/linux/procmem.c
index 61e03c92..5b246d40 100644
--- a/sysdeps/linux/procmem.c
+++ b/sysdeps/linux/procmem.c
@@ -51,7 +51,7 @@ void
glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf, pid_t pid)
{
char buffer [BUFSIZ], *p;
- const size_t pagesize = getpagesize();
+ const size_t pagesize = get_page_size();
glibtop_init_s (&server, GLIBTOP_SYSDEPS_MEM, 0);
diff --git a/sysdeps/linux/procsegment.c b/sysdeps/linux/procsegment.c
index cc371d1b..5bf6178f 100644
--- a/sysdeps/linux/procsegment.c
+++ b/sysdeps/linux/procsegment.c
@@ -55,7 +55,7 @@ glibtop_get_proc_segment_s (glibtop *server, glibtop_proc_segment *buf,
pid_t pid)
{
char buffer [BUFSIZ], *p;
- const size_t pagesize = getpagesize();
+ const size_t pagesize = get_page_size();
glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_SEGMENT, 0);