diff --git a/headers/os/kernel/OS.h b/headers/os/kernel/OS.h index 1b2e7f8849..2ba449ce09 100644 --- a/headers/os/kernel/OS.h +++ b/headers/os/kernel/OS.h @@ -420,23 +420,6 @@ extern void ktrace_vprintf(const char *format, va_list args); /* System information */ -#if __INTEL__ -# define B_MAX_CPU_COUNT 8 -#elif __x86_64__ -# define B_MAX_CPU_COUNT 8 -#elif __POWERPC__ -# define B_MAX_CPU_COUNT 8 -#elif __M68K__ -# define B_MAX_CPU_COUNT 1 -#elif __ARM__ -# define B_MAX_CPU_COUNT 1 -#elif __MIPSEL__ -# define B_MAX_CPU_COUNT 1 -#else -# warning Unknown cpu -# define B_MAX_CPU_COUNT 1 -#endif - typedef enum cpu_types { /* TODO: add latest models */ @@ -740,7 +723,7 @@ typedef struct { int32 cpu_count; /* number of cpus */ enum cpu_types cpu_type; /* type of cpu */ int32 cpu_revision; /* revision # of cpu */ - cpu_info cpu_infos[B_MAX_CPU_COUNT]; /* info about individual cpus */ + cpu_info cpu_infos[8]; /* info about individual cpus */ int64 cpu_clock_speed; /* processor clock speed (Hz) */ int64 bus_clock_speed; /* bus clock speed (Hz) */ enum platform_types platform_type; /* type of machine we're on */ diff --git a/src/apps/processcontroller/ProcessController.cpp b/src/apps/processcontroller/ProcessController.cpp index 3987582371..8e9765ea35 100644 --- a/src/apps/processcontroller/ProcessController.cpp +++ b/src/apps/processcontroller/ProcessController.cpp @@ -158,7 +158,11 @@ ProcessController::ProcessController(BRect frame, bool temp) fTrackerIcon(kTrackerSig), fDeskbarIcon(kDeskbarSig), fTerminalIcon(kTerminalSig), - fTemp(temp) + kCPUCount(sysconf(_SC_NPROCESSORS_CONF)), + fTemp(temp), + fLastBarHeight(new float[kCPUCount]), + fCPUTimes(new double[kCPUCount]), + fPrevActive(new bigtime_t[kCPUCount]) { if (!temp) { Init(); @@ -178,7 +182,11 @@ ProcessController::ProcessController(BMessage *data) fTrackerIcon(kTrackerSig), fDeskbarIcon(kDeskbarSig), fTerminalIcon(kTerminalSig), - fTemp(false) + kCPUCount(sysconf(_SC_NPROCESSORS_CONF)), + fTemp(false), + fLastBarHeight(new float[kCPUCount]), + fCPUTimes(new double[kCPUCount]), + fPrevActive(new bigtime_t[kCPUCount]) { Init(); } @@ -191,7 +199,11 @@ ProcessController::ProcessController() fTrackerIcon(kTrackerSig), fDeskbarIcon(kDeskbarSig), fTerminalIcon(kTerminalSig), - fTemp(false) + kCPUCount(sysconf(_SC_NPROCESSORS_CONF)), + fTemp(false), + fLastBarHeight(new float[kCPUCount]), + fCPUTimes(new double[kCPUCount]), + fPrevActive(new bigtime_t[kCPUCount]) { Init(); } @@ -208,6 +220,10 @@ ProcessController::~ProcessController() delete fMessageRunner; gPCView = NULL; + + delete[] fPrevActive; + delete[] fCPUTimes; + delete[] fLastBarHeight; } diff --git a/src/apps/processcontroller/ProcessController.h b/src/apps/processcontroller/ProcessController.h index 02cd76f067..80c3a08c2b 100644 --- a/src/apps/processcontroller/ProcessController.h +++ b/src/apps/processcontroller/ProcessController.h @@ -60,12 +60,13 @@ class ProcessController : public BView { void Init(); void _HandleDebugRequest(team_id team, thread_id thread); + const int32 kCPUCount; bool fTemp; float fMemoryUsage; - float fLastBarHeight[B_MAX_CPU_COUNT]; + float* fLastBarHeight; float fLastMemoryHeight; - double fCPUTimes[B_MAX_CPU_COUNT]; - bigtime_t fPrevActive[B_MAX_CPU_COUNT]; + double* fCPUTimes; + bigtime_t* fPrevActive; bigtime_t fPrevTime; BMessageRunner* fMessageRunner; rgb_color frame_color, active_color, idle_color, memory_color, swap_color; diff --git a/src/apps/pulse/MiniPulseView.cpp b/src/apps/pulse/MiniPulseView.cpp index e36089869c..923810f439 100644 --- a/src/apps/pulse/MiniPulseView.cpp +++ b/src/apps/pulse/MiniPulseView.cpp @@ -64,7 +64,7 @@ MiniPulseView::MiniPulseView(BMessage *message) void MiniPulseView::Draw(BRect rect) { system_info sys_info; get_system_info(&sys_info); - if (sys_info.cpu_count > B_MAX_CPU_COUNT || sys_info.cpu_count <= 0) + if (sys_info.cpu_count <= 0) return; BRect bounds(Bounds()); diff --git a/src/apps/pulse/PulseView.cpp b/src/apps/pulse/PulseView.cpp index bc5969a0af..9370875a59 100644 --- a/src/apps/pulse/PulseView.cpp +++ b/src/apps/pulse/PulseView.cpp @@ -26,8 +26,14 @@ #define B_TRANSLATION_CONTEXT "PulseView" -PulseView::PulseView(BRect rect, const char *name) : - BView(rect, name, B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_PULSE_NEEDED | B_FRAME_EVENTS) { +PulseView::PulseView(BRect rect, const char *name) + : + BView(rect, name, B_FOLLOW_ALL_SIDES, + B_WILL_DRAW | B_PULSE_NEEDED | B_FRAME_EVENTS), + kCPUCount(sysconf(_SC_NPROCESSORS_CONF)), + cpu_times(new double[kCPUCount]), + prev_active(new bigtime_t[kCPUCount]) +{ popupmenu = NULL; cpu_menu_items = NULL; @@ -40,7 +46,13 @@ PulseView::PulseView(BRect rect, const char *name) : } // This version will be used by the instantiated replicant -PulseView::PulseView(BMessage *message) : BView(message) { +PulseView::PulseView(BMessage *message) + : + BView(message), + kCPUCount(sysconf(_SC_NPROCESSORS_CONF)), + cpu_times(new double[kCPUCount]), + prev_active(new bigtime_t[kCPUCount]) +{ SetResizingMode(B_FOLLOW_ALL_SIDES); SetFlags(B_WILL_DRAW | B_PULSE_NEEDED); @@ -138,5 +150,8 @@ void PulseView::ChangeCPUState(BMessage *message) { PulseView::~PulseView() { if (popupmenu != NULL) delete popupmenu; if (cpu_menu_items != NULL) delete cpu_menu_items; + + delete[] prev_active; + delete[] cpu_times; } diff --git a/src/apps/pulse/PulseView.h b/src/apps/pulse/PulseView.h index b61922a886..d6e0f9f4d6 100644 --- a/src/apps/pulse/PulseView.h +++ b/src/apps/pulse/PulseView.h @@ -32,8 +32,10 @@ class PulseView : public BView { BMenuItem *mode1, *mode2, *preferences, *about; BMenuItem **cpu_menu_items; - double cpu_times[B_MAX_CPU_COUNT]; - bigtime_t prev_active[B_MAX_CPU_COUNT]; + const int32 kCPUCount; + + double* cpu_times; + bigtime_t* prev_active; bigtime_t prev_time; }; diff --git a/src/system/kernel/arch/x86/arch_smp.cpp b/src/system/kernel/arch/x86/arch_smp.cpp index 0a97a97e51..adf89a247c 100644 --- a/src/system/kernel/arch/x86/arch_smp.cpp +++ b/src/system/kernel/arch/x86/arch_smp.cpp @@ -73,7 +73,7 @@ x86_smp_error_interrupt(void *data) uint32 x86_get_cpu_apic_id(int32 cpu) { - ASSERT(cpu >= 0 && cpu < B_MAX_CPU_COUNT); + ASSERT(cpu >= 0 && cpu < SMP_MAX_CPUS); return sCPUAPICIds[cpu]; }