summaryrefslogtreecommitdiff
path: root/sysdeps/linux
diff options
context:
space:
mode:
authorJason Xing <xinggang861@gmail.com>2013-12-12 22:36:10 +0200
committerRobert Roth <robert.roth.off@gmail.com>2013-12-12 22:36:10 +0200
commitefaaf6eb77e01f1ea002c19a261e4f3ac4788d25 (patch)
treea326d5b8e19601e2b99136c28b6fb54d7b2c83d1 /sysdeps/linux
parent47bcd423b5e58210d0283b09951ea3a68f54bb7e (diff)
downloadlibgtop-efaaf6eb77e01f1ea002c19a261e4f3ac4788d25.tar.gz
Extending the cpu number from 32 to 1024 (bgo #323354, bgo #681632)
From: Jason Xing <xinggang861@gmail.com> In 'Bug 323354 - Support a dynamic number of CPUs', there will be a solution which can dynamically allocate memory for large number of CPUs. As libgtop supports multiple operating systems, this work may take some time. This patch is a temporary patch, which worked before the whole solution comes out. It only supports linux platform with CPU number up to 1024. There are two Macroes which limit the statistics of CPU. One is GLIBTOP_NCPU. The other is a buffer size. This buffer used to read /proc/stat contents into. https://bugzilla.gnome.org/show_bug.cgi?id=323354 https://bugzilla.gnome.org/show_bug.cgi?id=681632
Diffstat (limited to 'sysdeps/linux')
-rw-r--r--sysdeps/linux/cpu.c3
-rw-r--r--sysdeps/linux/open.c3
2 files changed, 4 insertions, 2 deletions
diff --git a/sysdeps/linux/cpu.c b/sysdeps/linux/cpu.c
index bedeab59..f2cbb4ed 100644
--- a/sysdeps/linux/cpu.c
+++ b/sysdeps/linux/cpu.c
@@ -66,11 +66,12 @@ _glibtop_init_cpu_s (glibtop *server)
/* Provides information about cpu usage. */
#define FILENAME "/proc/stat"
+#define STAT_BUFSIZ 81920
void
glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf)
{
- char buffer [BUFSIZ], *p;
+ char buffer [STAT_BUFSIZ], *p;
int i;
memset (buf, 0, sizeof (glibtop_cpu));
diff --git a/sysdeps/linux/open.c b/sysdeps/linux/open.c
index b39b99ee..61c3d588 100644
--- a/sysdeps/linux/open.c
+++ b/sysdeps/linux/open.c
@@ -61,13 +61,14 @@ static void set_linux_version(glibtop *server)
/* Opens pipe to gtop server. Returns 0 on success and -1 on error. */
#define FILENAME "/proc/stat"
+#define STAT_BUFSIZ 81920
void
glibtop_open_s (glibtop *server, const char *program_name,
const unsigned long features,
const unsigned flags)
{
- char buffer [BUFSIZ], *p = buffer;
+ char buffer [STAT_BUFSIZ], *p = buffer;
server->name = program_name;