From e491343151ffad543e8d7430d57857ce1209a0d4 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Wed, 6 Jan 1999 19:26:45 +0000 Subject: [PATCH] Unconditionally enable SMP support for linux. 1999-01-06 Martin Baulig Unconditionally enable SMP support for linux. * open.c (_glibtop_open_s): Always determine the number of CPUs we have here, not only when SMP support was enabled. * cpu.c, proctime.c: Use `server->ncpu' to determine whether to enable SMP support. --- sysdeps/linux/ChangeLog | 10 ++++++++++ sysdeps/linux/cpu.c | 11 ++++------- sysdeps/linux/open.c | 5 ----- sysdeps/linux/proctime.c | 13 ++++++------- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/sysdeps/linux/ChangeLog b/sysdeps/linux/ChangeLog index f0a00c0a..0ade6d8a 100644 --- a/sysdeps/linux/ChangeLog +++ b/sysdeps/linux/ChangeLog @@ -1,3 +1,13 @@ +1999-01-06 Martin Baulig + + Unconditionally enable SMP support for linux. + + * open.c (_glibtop_open_s): Always determine the number of CPUs + we have here, not only when SMP support was enabled. + + * cpu.c, proctime.c: Use `server->ncpu' to determine whether to + enable SMP support. + 1998-12-28 Martin Baulig * netload.c: When using glibc, don't include diff --git a/sysdeps/linux/cpu.c b/sysdeps/linux/cpu.c index bd959d07..eaaed87e 100644 --- a/sysdeps/linux/cpu.c +++ b/sysdeps/linux/cpu.c @@ -38,11 +38,10 @@ static const unsigned long _glibtop_sysdeps_cpu_smp = void glibtop_init_cpu_s (glibtop *server) { -#if HAVE_LIBGTOP_SMP - server->sysdeps.cpu = _glibtop_sysdeps_cpu | _glibtop_sysdeps_cpu_smp; -#else server->sysdeps.cpu = _glibtop_sysdeps_cpu; -#endif + + if (server->ncpu) + server->sysdeps.cpu |= _glibtop_sysdeps_cpu_smp; } /* Provides information about cpu usage. */ @@ -83,8 +82,7 @@ glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf) buf->frequency = 100; buf->flags = _glibtop_sysdeps_cpu; -#if HAVE_LIBGTOP_SMP - for (i = 0; i < GLIBTOP_NCPU; i++) { + for (i = 0; i < server->ncpu; i++) { if (strncmp (p+1, "cpu", 3) || !isdigit (p [4])) break; @@ -99,5 +97,4 @@ glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf) } buf->flags |= _glibtop_sysdeps_cpu_smp; -#endif } diff --git a/sysdeps/linux/open.c b/sysdeps/linux/open.c index af51e9e3..54aef7d7 100644 --- a/sysdeps/linux/open.c +++ b/sysdeps/linux/open.c @@ -59,10 +59,8 @@ glibtop_open_s (glibtop *server, const char *program_name, const unsigned long features, const unsigned flags) { -#ifdef HAVE_LIBGTOP_SMP char buffer [BUFSIZ], *p; int fd, len, i; -#endif server->name = program_name; @@ -71,7 +69,6 @@ glibtop_open_s (glibtop *server, const char *program_name, server->ncpu = 0; -#ifdef HAVE_LIBGTOP_SMP fd = open (FILENAME, O_RDONLY); if (fd < 0) glibtop_error_io_r (server, "open (%s)", FILENAME); @@ -99,6 +96,4 @@ glibtop_open_s (glibtop *server, const char *program_name, #if DEBUG printf ("\nThis machine has %d CPUs.\n\n", server->ncpu); #endif - -#endif } diff --git a/sysdeps/linux/proctime.c b/sysdeps/linux/proctime.c index 951e789d..5f43487d 100644 --- a/sysdeps/linux/proctime.c +++ b/sysdeps/linux/proctime.c @@ -38,12 +38,10 @@ static const unsigned long _glibtop_sysdeps_proc_time_smp = void glibtop_init_proc_time_s (glibtop *server) { -#if HAVE_LIBGTOP_SMP - server->sysdeps.proc_time = _glibtop_sysdeps_proc_time | - _glibtop_sysdeps_proc_time_smp; -#else server->sysdeps.proc_time = _glibtop_sysdeps_proc_time; -#endif + + if (server->ncpu) + server->sysdeps.proc_time |= _glibtop_sysdeps_proc_time_smp; } /* Provides detailed information about a process. */ @@ -83,7 +81,9 @@ glibtop_get_proc_time_s (glibtop *server, glibtop_proc_time *buf, pid_t pid) buf->flags = _glibtop_sysdeps_proc_time; -#if HAVE_LIBGTOP_SMP + if (!server->ncpu) + return; + if (proc_file_to_buffer (buffer, "/proc/%d/cpu", pid)) return; @@ -101,5 +101,4 @@ glibtop_get_proc_time_s (glibtop *server, glibtop_proc_time *buf, pid_t pid) } buf->flags |= _glibtop_sysdeps_proc_time_smp; -#endif }