summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sysdeps/linux/ChangeLog9
-rw-r--r--sysdeps/linux/glibtop_server.c20
-rw-r--r--sysdeps/linux/glibtop_server.h2
-rw-r--r--sysdeps/linux/procmem.c10
-rw-r--r--sysdeps/linux/procsegment.c10
5 files changed, 19 insertions, 32 deletions
diff --git a/sysdeps/linux/ChangeLog b/sysdeps/linux/ChangeLog
index 14251573..b8f5a373 100644
--- a/sysdeps/linux/ChangeLog
+++ b/sysdeps/linux/ChangeLog
@@ -1,3 +1,12 @@
+2004-09-23 Benoît Dejean <tazforever@dlfp.org>
+
+ * glibtop_server.c:
+ * glibtop_server.h:
+ * procmem.c: (glibtop_get_proc_mem_s):
+ * procsegment.c: (glibtop_get_proc_segment_s): Removed get_pageshift().
+ Every one can affort a * instead of a >>, no need for this kind of
+ non-reentrant optimization. Saved 144B (obviously perfect cleanup ;)
+
2004-09-22 Benoît Dejean <tazforever@dlfp.org>
* glibtop_server.c: Removed #warning, my gcc is not buggy anymore.
diff --git a/sysdeps/linux/glibtop_server.c b/sysdeps/linux/glibtop_server.c
index ac41f045..ed112f08 100644
--- a/sysdeps/linux/glibtop_server.c
+++ b/sysdeps/linux/glibtop_server.c
@@ -9,9 +9,6 @@
#include <fcntl.h>
-/* gcc warning bug */
-unsigned get_pageshift(void);
-
unsigned long long
get_scaled(const char *buffer, const char *key)
@@ -85,20 +82,3 @@ file_to_buffer(glibtop *server, char *buffer, const char *filename)
}
-unsigned get_pageshift(void)
-{
- static unsigned pageshift = 0;
-
- if(G_UNLIKELY(!pageshift))
- {
- register unsigned pagesize = getpagesize();
-
- while( pagesize > 1 )
- {
- pagesize >>= 1;
- pageshift++;
- }
- }
-
- return pageshift;
-}
diff --git a/sysdeps/linux/glibtop_server.h b/sysdeps/linux/glibtop_server.h
index b3451b10..bff9f775 100644
--- a/sysdeps/linux/glibtop_server.h
+++ b/sysdeps/linux/glibtop_server.h
@@ -39,8 +39,6 @@ G_BEGIN_DECLS
#define LINUX_VERSION_CODE(x,y,z) (0x10000*(x) + 0x100*(y) + z)
-unsigned get_pageshift(void);
-
static inline char*
next_token(const char *p)
{
diff --git a/sysdeps/linux/procmem.c b/sysdeps/linux/procmem.c
index e2973b94..fc9ec22a 100644
--- a/sysdeps/linux/procmem.c
+++ b/sysdeps/linux/procmem.c
@@ -49,7 +49,7 @@ void
glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf, pid_t pid)
{
char buffer [BUFSIZ], *p;
- const unsigned pageshift = get_pageshift();
+ const size_t pagesize = getpagesize();
glibtop_init_s (&server, GLIBTOP_SYSDEPS_MEM, 0);
@@ -76,10 +76,10 @@ glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf, pid_t pid)
buf->resident = strtoull (p, &p, 0);
buf->share = strtoull (p, &p, 0);
- buf->size <<= pageshift;
- buf->resident <<= pageshift;
- buf->share <<= pageshift;
- buf->rss <<= pageshift;
+ buf->size *= pagesize;
+ buf->resident *= pagesize;
+ buf->share *= pagesize;
+ buf->rss *= pagesize;
buf->flags |= _glibtop_sysdeps_proc_mem_statm;
}
diff --git a/sysdeps/linux/procsegment.c b/sysdeps/linux/procsegment.c
index 99d084bd..8276df1d 100644
--- a/sysdeps/linux/procsegment.c
+++ b/sysdeps/linux/procsegment.c
@@ -53,7 +53,7 @@ glibtop_get_proc_segment_s (glibtop *server, glibtop_proc_segment *buf,
pid_t pid)
{
char buffer [BUFSIZ], *p;
- const unsigned pageshift = get_pageshift();
+ const size_t pagesize = getpagesize();
glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_SEGMENT, 0);
@@ -86,10 +86,10 @@ glibtop_get_proc_segment_s (glibtop *server, glibtop_proc_segment *buf,
buf->data_rss = strtoull (p, &p, 0);
buf->dirty_size = strtoull (p, &p, 0);
- buf->text_rss <<= pageshift;
- buf->shlib_rss <<= pageshift;
- buf->data_rss <<= pageshift;
- buf->dirty_size <<= pageshift;
+ buf->text_rss *= pagesize;
+ buf->shlib_rss *= pagesize;
+ buf->data_rss *= pagesize;
+ buf->dirty_size *= pagesize;
buf->flags |= _glibtop_sysdeps_proc_segment_statm;
}