apps, kernel: Remove B_MAX_CPU_COUNT

This commit is contained in:
Pawel Dziepak
2013-12-06 21:57:58 +01:00
parent fd96cf08a7
commit bcfdf88186
7 changed files with 48 additions and 31 deletions
+1 -18
View File
@@ -420,23 +420,6 @@ extern void ktrace_vprintf(const char *format, va_list args);
/* System information */ /* 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 { typedef enum cpu_types {
/* TODO: add latest models */ /* TODO: add latest models */
@@ -740,7 +723,7 @@ typedef struct {
int32 cpu_count; /* number of cpus */ int32 cpu_count; /* number of cpus */
enum cpu_types cpu_type; /* type of cpu */ enum cpu_types cpu_type; /* type of cpu */
int32 cpu_revision; /* revision # 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 cpu_clock_speed; /* processor clock speed (Hz) */
int64 bus_clock_speed; /* bus clock speed (Hz) */ int64 bus_clock_speed; /* bus clock speed (Hz) */
enum platform_types platform_type; /* type of machine we're on */ enum platform_types platform_type; /* type of machine we're on */
@@ -158,7 +158,11 @@ ProcessController::ProcessController(BRect frame, bool temp)
fTrackerIcon(kTrackerSig), fTrackerIcon(kTrackerSig),
fDeskbarIcon(kDeskbarSig), fDeskbarIcon(kDeskbarSig),
fTerminalIcon(kTerminalSig), 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) { if (!temp) {
Init(); Init();
@@ -178,7 +182,11 @@ ProcessController::ProcessController(BMessage *data)
fTrackerIcon(kTrackerSig), fTrackerIcon(kTrackerSig),
fDeskbarIcon(kDeskbarSig), fDeskbarIcon(kDeskbarSig),
fTerminalIcon(kTerminalSig), 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(); Init();
} }
@@ -191,7 +199,11 @@ ProcessController::ProcessController()
fTrackerIcon(kTrackerSig), fTrackerIcon(kTrackerSig),
fDeskbarIcon(kDeskbarSig), fDeskbarIcon(kDeskbarSig),
fTerminalIcon(kTerminalSig), 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(); Init();
} }
@@ -208,6 +220,10 @@ ProcessController::~ProcessController()
delete fMessageRunner; delete fMessageRunner;
gPCView = NULL; gPCView = NULL;
delete[] fPrevActive;
delete[] fCPUTimes;
delete[] fLastBarHeight;
} }
@@ -60,12 +60,13 @@ class ProcessController : public BView {
void Init(); void Init();
void _HandleDebugRequest(team_id team, thread_id thread); void _HandleDebugRequest(team_id team, thread_id thread);
const int32 kCPUCount;
bool fTemp; bool fTemp;
float fMemoryUsage; float fMemoryUsage;
float fLastBarHeight[B_MAX_CPU_COUNT]; float* fLastBarHeight;
float fLastMemoryHeight; float fLastMemoryHeight;
double fCPUTimes[B_MAX_CPU_COUNT]; double* fCPUTimes;
bigtime_t fPrevActive[B_MAX_CPU_COUNT]; bigtime_t* fPrevActive;
bigtime_t fPrevTime; bigtime_t fPrevTime;
BMessageRunner* fMessageRunner; BMessageRunner* fMessageRunner;
rgb_color frame_color, active_color, idle_color, memory_color, swap_color; rgb_color frame_color, active_color, idle_color, memory_color, swap_color;
+1 -1
View File
@@ -64,7 +64,7 @@ MiniPulseView::MiniPulseView(BMessage *message)
void MiniPulseView::Draw(BRect rect) { void MiniPulseView::Draw(BRect rect) {
system_info sys_info; system_info sys_info;
get_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; return;
BRect bounds(Bounds()); BRect bounds(Bounds());
+18 -3
View File
@@ -26,8 +26,14 @@
#define B_TRANSLATION_CONTEXT "PulseView" #define B_TRANSLATION_CONTEXT "PulseView"
PulseView::PulseView(BRect rect, const char *name) : PulseView::PulseView(BRect rect, const char *name)
BView(rect, name, B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_PULSE_NEEDED | B_FRAME_EVENTS) { :
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; popupmenu = NULL;
cpu_menu_items = 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 // 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); SetResizingMode(B_FOLLOW_ALL_SIDES);
SetFlags(B_WILL_DRAW | B_PULSE_NEEDED); SetFlags(B_WILL_DRAW | B_PULSE_NEEDED);
@@ -138,5 +150,8 @@ void PulseView::ChangeCPUState(BMessage *message) {
PulseView::~PulseView() { PulseView::~PulseView() {
if (popupmenu != NULL) delete popupmenu; if (popupmenu != NULL) delete popupmenu;
if (cpu_menu_items != NULL) delete cpu_menu_items; if (cpu_menu_items != NULL) delete cpu_menu_items;
delete[] prev_active;
delete[] cpu_times;
} }
+4 -2
View File
@@ -32,8 +32,10 @@ class PulseView : public BView {
BMenuItem *mode1, *mode2, *preferences, *about; BMenuItem *mode1, *mode2, *preferences, *about;
BMenuItem **cpu_menu_items; BMenuItem **cpu_menu_items;
double cpu_times[B_MAX_CPU_COUNT]; const int32 kCPUCount;
bigtime_t prev_active[B_MAX_CPU_COUNT];
double* cpu_times;
bigtime_t* prev_active;
bigtime_t prev_time; bigtime_t prev_time;
}; };
+1 -1
View File
@@ -73,7 +73,7 @@ x86_smp_error_interrupt(void *data)
uint32 uint32
x86_get_cpu_apic_id(int32 cpu) 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]; return sCPUAPICIds[cpu];
} }