diff options
108 files changed, 72722 insertions, 3299 deletions
diff --git a/Affinity.c b/Affinity.c new file mode 100644 index 00000000..0b2bd465 --- /dev/null +++ b/Affinity.c @@ -0,0 +1,36 @@ + +#include "config.h" +#include "Affinity.h" +#include <stdlib.h> + +/*{ + +typedef struct Affinity_ { + int size; + int used; + int* cpus; +} Affinity; + +}*/ + +Affinity* Affinity_new() { + Affinity* this = calloc(sizeof(Affinity), 1); + this->size = 8; + this->cpus = calloc(sizeof(int), this->size); + return this; +} + +void Affinity_delete(Affinity* this) { + free(this->cpus); + free(this); +} + +void Affinity_add(Affinity* this, int id) { + if (this->used == this->size) { + this->size *= 2; + this->cpus = realloc(this->cpus, sizeof(int) * this->size); + } + this->cpus[this->used] = id; + this->used++; +} + diff --git a/AffinityPanel.c b/AffinityPanel.c index b3ea4123..504638e7 100644 --- a/AffinityPanel.c +++ b/AffinityPanel.c @@ -1,9 +1,8 @@ +#include "ProcessList.h" #include "AffinityPanel.h" - #include "Panel.h" #include "CheckItem.h" -#include "ProcessList.h" #include "debug.h" #include <assert.h> @@ -26,25 +25,33 @@ static HandlerResult AffinityPanel_eventHandler(Panel* this, int ch) { return result; } -Panel* AffinityPanel_new(ProcessList* pl, unsigned long mask) { +Panel* AffinityPanel_new(ProcessList* pl, Affinity* affinity) { Panel* this = Panel_new(1, 1, 1, 1, CHECKITEM_CLASS, true, ListItem_compare); this->eventHandler = AffinityPanel_eventHandler; Panel_setHeader(this, "Use CPUs:"); + int curCpu = 0; for (int i = 0; i < pl->cpuCount; i++) { char number[10]; snprintf(number, 9, "%d", ProcessList_cpuId(pl, i)); - Panel_add(this, (Object*) CheckItem_new(String_copy(number), NULL, mask & (1 << i))); + bool mode; + if (curCpu < affinity->used && affinity->cpus[curCpu] == i) { + mode = true; + curCpu++; + } else { + mode = false; + } + Panel_add(this, (Object*) CheckItem_new(String_copy(number), NULL, mode)); } return this; } -unsigned long AffinityPanel_getAffinity(Panel* this) { +Affinity* AffinityPanel_getAffinity(Panel* this) { + Affinity* affinity = Affinity_new(); int size = Panel_size(this); - unsigned long mask = 0; for (int i = 0; i < size; i++) { if (CheckItem_get((CheckItem*)Panel_get(this, i))) - mask = mask | (1 << i); + Affinity_add(affinity, i); } - return mask; + return affinity; } diff --git a/AffinityPanel.h b/AffinityPanel.h index 4324610b..8ab39633 100644 --- a/AffinityPanel.h +++ b/AffinityPanel.h @@ -3,16 +3,15 @@ #ifndef HEADER_AffinityPanel #define HEADER_AffinityPanel - +#include "ProcessList.h" #include "Panel.h" #include "CheckItem.h" -#include "ProcessList.h" #include "debug.h" #include <assert.h> -Panel* AffinityPanel_new(ProcessList* pl, unsigned long mask); +Panel* AffinityPanel_new(ProcessList* pl, Affinity* affinity); -unsigned long AffinityPanel_getAffinity(Panel* this); +Affinity* AffinityPanel_getAffinity(Panel* this); #endif diff --git a/DebugMemory.c b/DebugMemory.c index f9f38e70..7a0f584d 100644 --- a/DebugMemory.c +++ b/DebugMemory.c @@ -1,5 +1,4 @@ -#define _GNU_SOURCE #include <string.h> #include <stdlib.h> #include <stdio.h> diff --git a/DebugMemory.h b/DebugMemory.h index ea262089..a67a5f2b 100644 --- a/DebugMemory.h +++ b/DebugMemory.h @@ -3,7 +3,6 @@ #ifndef HEADER_DebugMemory #define HEADER_DebugMemory -#define _GNU_SOURCE #include <string.h> #include <stdlib.h> #include <stdio.h> diff --git a/Makefile.am b/Makefile.am index 9bf73e48..57651a93 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,9 +1,9 @@ -if HAVE_PLPA -SUBDIRS = plpa-1.3.2 +if HAVE_HWLOC +SUBDIRS = hwloc-1.2.1 endif -ACLOCAL_AMFLAGS=-I m4 +ACLOCAL_AMFLAGS = -I m4 -I hwloc-1.2.1/config bin_PROGRAMS = htop dist_man_MANS = htop.1 @@ -15,6 +15,7 @@ pixmapdir = $(datadir)/pixmaps pixmap_DATA = htop.png htop_CFLAGS = -pedantic -Wall -std=c99 -rdynamic -D_XOPEN_SOURCE_EXTENDED +AM_CFLAGS = AM_CPPFLAGS = -DSYSCONFDIR=\"$(sysconfdir)\" myhtopsources = AvailableMetersPanel.c CategoriesPanel.c CheckItem.c \ @@ -24,7 +25,7 @@ LoadAverageMeter.c MemoryMeter.c Meter.c MetersPanel.c Object.c Panel.c \ BatteryMeter.c Process.c ProcessList.c RichString.c ScreenManager.c Settings.c \ SignalItem.c SignalsPanel.c String.c SwapMeter.c TasksMeter.c TraceScreen.c \ UptimeMeter.c UsersTable.c Vector.c AvailableColumnsPanel.c AffinityPanel.c \ -HostnameMeter.c Open |