summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Action.c111
-rw-r--r--Action.h11
-rw-r--r--Affinity.c20
-rw-r--r--Affinity.h10
-rw-r--r--AffinityPanel.c24
-rw-r--r--AffinityPanel.h6
-rw-r--r--AvailableMetersPanel.c21
-rw-r--r--AvailableMetersPanel.h8
-rw-r--r--CPUMeter.c34
-rw-r--r--CategoriesPanel.c24
-rw-r--r--CategoriesPanel.h9
-rw-r--r--ClockMeter.c4
-rw-r--r--CommandLine.c26
-rw-r--r--DateMeter.c4
-rw-r--r--DateTimeMeter.c4
-rw-r--r--DiskIOMeter.c6
-rw-r--r--DynamicMeter.c4
-rw-r--r--Header.c24
-rw-r--r--Header.h8
-rw-r--r--LoadAverageMeter.c12
-rw-r--r--Machine.c60
-rw-r--r--Machine.h89
-rw-r--r--MainPanel.c23
-rw-r--r--Makefile.am2
-rw-r--r--MemorySwapMeter.c4
-rw-r--r--Meter.c12
-rw-r--r--Meter.h6
-rw-r--r--NetworkIOMeter.c6
-rw-r--r--Process.c52
-rw-r--r--Process.h11
-rw-r--r--ProcessList.c74
-rw-r--r--ProcessList.h49
-rw-r--r--ScreenManager.c33
-rw-r--r--ScreenManager.h6
-rw-r--r--TasksMeter.c9
-rw-r--r--darwin/DarwinProcess.c9
-rw-r--r--darwin/DarwinProcess.h4
-rw-r--r--darwin/DarwinProcessList.c31
-rw-r--r--darwin/DarwinProcessList.h8
-rw-r--r--darwin/Platform.c15
-rw-r--r--dragonflybsd/DragonFlyBSDProcess.c4
-rw-r--r--dragonflybsd/DragonFlyBSDProcess.h4
-rw-r--r--dragonflybsd/DragonFlyBSDProcessList.c33
-rw-r--r--dragonflybsd/DragonFlyBSDProcessList.h8
-rw-r--r--dragonflybsd/Platform.c11
-rw-r--r--freebsd/FreeBSDProcess.c4
-rw-r--r--freebsd/FreeBSDProcess.h4
-rw-r--r--freebsd/FreeBSDProcessList.c75
-rw-r--r--freebsd/FreeBSDProcessList.h8
-rw-r--r--freebsd/Platform.c31
-rw-r--r--linux/HugePageMeter.c2
-rw-r--r--linux/LinuxProcess.c6
-rw-r--r--linux/LinuxProcess.h4
-rw-r--r--linux/LinuxProcessList.c106
-rw-r--r--linux/LinuxProcessList.h8
-rw-r--r--linux/Platform.c39
-rw-r--r--netbsd/NetBSDProcess.c4
-rw-r--r--netbsd/NetBSDProcess.h4
-rw-r--r--netbsd/NetBSDProcessList.c64
-rw-r--r--netbsd/NetBSDProcessList.h8
-rw-r--r--netbsd/Platform.c21
-rw-r--r--openbsd/OpenBSDProcess.c4
-rw-r--r--openbsd/OpenBSDProcess.h4
-rw-r--r--openbsd/OpenBSDProcessList.c60
-rw-r--r--openbsd/OpenBSDProcessList.h8
-rw-r--r--openbsd/Platform.c21
-rw-r--r--pcp/PCPDynamicColumn.c2
-rw-r--r--pcp/PCPProcess.c6
-rw-r--r--pcp/PCPProcess.h4
-rw-r--r--pcp/PCPProcessList.c86
-rw-r--r--pcp/PCPProcessList.h8
-rw-r--r--pcp/Platform.c34
-rw-r--r--solaris/Platform.c27
-rw-r--r--solaris/SolarisProcess.c4
-rw-r--r--solaris/SolarisProcess.h4
-rw-r--r--solaris/SolarisProcessList.c64
-rw-r--r--solaris/SolarisProcessList.h8
-rw-r--r--unsupported/UnsupportedProcess.c6
-rw-r--r--unsupported/UnsupportedProcess.h4
-rw-r--r--unsupported/UnsupportedProcessList.c24
-rw-r--r--unsupported/UnsupportedProcessList.h8
81 files changed, 989 insertions, 718 deletions
diff --git a/Action.c b/Action.c
index 73b86062..d6b2a1ce 100644
--- a/Action.c
+++ b/Action.c
@@ -27,6 +27,7 @@ in the source distribution for its full text.
#include "MainPanel.h"
#include "OpenFilesScreen.h"
#include "Process.h"
+#include "ProcessList.h"
#include "ProcessLocksScreen.h"
#include "ProvideCurses.h"
#include "Scheduling.h"
@@ -45,9 +46,10 @@ in the source distribution for its full text.
Object* Action_pickFromVector(State* st, Panel* list, int x, bool followProcess) {
MainPanel* mainPanel = st->mainPanel;
Header* header = st->header;
+ Machine* host = st->host;
int y = ((Panel*)mainPanel)->y;
- ScreenManager* scr = ScreenManager_new(header, st->settings, st, false);
+ ScreenManager* scr = ScreenManager_new(header, host, st, false);
scr->allowFocusChange = false;
ScreenManager_add(scr, list, x);
ScreenManager_add(scr, (Panel*)mainPanel, -1);
@@ -55,13 +57,13 @@ Object* Action_pickFromVector(State* st, Panel* list, int x, bool followProcess)
int ch;
bool unfollow = false;
int pid = followProcess ? MainPanel_selectedPid(mainPanel) : -1;
- if (followProcess && header->pl->following == -1) {
- header->pl->following = pid;
+ if (followProcess && host->pl->following == -1) {
+ host->pl->following = pid;
unfollow = true;
}
ScreenManager_run(scr, &panelFocus, &ch, NULL);
if (unfollow) {
- header->pl->following = -1;
+ host->pl->following = -1;
}
ScreenManager_delete(scr);
Panel_move((Panel*)mainPanel, 0, y);
@@ -84,12 +86,13 @@ Object* Action_pickFromVector(State* st, Panel* list, int x, bool followProcess)
// ----------------------------------------
static void Action_runSetup(State* st) {
- ScreenManager* scr = ScreenManager_new(st->header, st->settings, st, true);
- CategoriesPanel_new(scr, st->settings, st->header, st->pl);
+ const Settings* settings = st->host->settings;
+ ScreenManager* scr = ScreenManager_new(st->header, st->host, st, true);
+ CategoriesPanel_new(scr, st->header, st->host);
ScreenManager_run(scr, NULL, NULL, "Setup");
ScreenManager_delete(scr);
- if (st->settings->changed) {
- CRT_setMouse(st->settings->enableMouse);
+ if (settings->changed) {
+ CRT_setMouse(settings->enableMouse);
Header_writeBackToSettings(st->header);
}
}
@@ -166,7 +169,8 @@ static Htop_Reaction actionSetSortColumn(State* st) {
Htop_Reaction reaction = HTOP_OK;
Panel* sortPanel = Panel_new(0, 0, 0, 0, Class(ListItem), true, FunctionBar_newEnterEsc("Sort ", "Cancel "));
Panel_setHeader(sortPanel, "Sort by");
- const Settings* settings = st->settings;
+ Machine* host = st->host;
+ Settings* settings = host->settings;
const ProcessField* fields = settings->ss->fields;
Hashtable* dynamicColumns = settings->dynamicColumns;
for (int i = 0; fields[i]; i++) {
@@ -187,74 +191,80 @@ static Htop_Reaction actionSetSortColumn(State* st) {
}
const ListItem* field = (const ListItem*) Action_pickFromVector(st, sortPanel, 14, false);
if (field) {
- reaction |= Action_setSortKey(st->settings, field->key);
+ reaction |= Action_setSortKey(settings, field->key);
}
Object_delete(sortPanel);
- st->pl->needsSort = true;
+ host->pl->needsSort = true;
return reaction | HTOP_REFRESH | HTOP_REDRAW_BAR | HTOP_UPDATE_PANELHDR;
}
static Htop_Reaction actionSortByPID(State* st) {
- return Action_setSortKey(st->settings, PID);
+ return Action_setSortKey(st->host->settings, PID);
}
static Htop_Reaction actionSortByMemory(State* st) {
- return Action_setSortKey(st->settings, PERCENT_MEM);
+ return Action_setSortKey(st->host->settings, PERCENT_MEM);
}
static Htop_Reaction actionSortByCPU(State* st) {
- return Action_setSortKey(st->settings, PERCENT_CPU);
+ return Action_setSortKey(st->host->settings, PERCENT_CPU);
}
static Htop_Reaction actionSortByTime(State* st) {
- return Action_setSortKey(st->settings, TIME);
+ return Action_setSortKey(st->host->settings, TIME);
}
static Htop_Reaction actionToggleKernelThreads(State* st) {
- st->settings->hideKernelThreads = !st->settings->hideKernelThreads;
- st->settings->lastUpdate++;
+ Settings* settings = st->host->settings;
+ settings->hideKernelThreads = !settings->hideKernelThreads;
+ settings->lastUpdate++;
return HTOP_RECALCULATE | HTOP_SAVE_SETTINGS | HTOP_KEEP_FOLLOWING;
}
static Htop_Reaction actionToggleUserlandThreads(State* st) {
- st->settings->hideUserlandThreads = !st->settings->hideUserlandThreads;
- st->settings->lastUpdate++;
+ Settings* settings = st->host->settings;
+ settings->hideUserlandThreads = !settings->hideUserlandThreads;
+ settings->lastUpdate++;
return HTOP_RECALCULATE | HTOP_SAVE_SETTINGS | HTOP_KEEP_FOLLOWING;
}
static Htop_Reaction actionToggleRunningInContainer(State* st) {
- st->settings->hideRunningInContainer = !st->settings->hideRunningInContainer;
- st->settings->lastUpdate++;
+ Settings* settings = st->host->settings;
+ settings->hideRunningInContainer = !settings->hideRunningInContainer;
+ settings->lastUpdate++;
return HTOP_RECALCULATE | HTOP_SAVE_SETTINGS | HTOP_KEEP_FOLLOWING;
}
static Htop_Reaction actionToggleProgramPath(State* st) {
- st->settings->showProgramPath = !st->settings->showProgramPath;
- st->settings->lastUpdate++;
+ Settings* settings = st->host->settings;
+ settings->showProgramPath = !settings->showProgramPath;
+ settings->lastUpdate++;
return HTOP_REFRESH | HTOP_SAVE_SETTINGS | HTOP_KEEP_FOLLOWING;
}
static Htop_Reaction actionToggleMergedCommand(State* st) {
- st->settings->showMergedCommand = !st->settings->showMergedCommand;
- st->settings->lastUpdate++;
+ Settings* settings = st->host->settings;
+ settings->showMergedCommand = !settings->showMergedCommand;
+ settings->lastUpdate++;
return HTOP_REFRESH | HTOP_SAVE_SETTINGS | HTOP_KEEP_FOLLOWING | HTOP_UPDATE_PANELHDR;
}
static Htop_Reaction actionToggleTreeView(State* st) {
- ScreenSettings* ss = st->settings->ss;
+ Machine* host = st->host;
+ ScreenSettings* ss = host->settings->ss;
ss->treeView = !ss->treeView;
if (!ss->allBranchesCollapsed)
- ProcessList_expandTree(st->pl);
+ ProcessList_expandTree(host->pl);
- st->pl->needsSort = true;
+ host->pl->needsSort = true;
return HTOP_REFRESH | HTOP_SAVE_SETTINGS | HTOP_KEEP_FOLLOWING | HTOP_REDRAW_BAR | HTOP_UPDATE_PANELHDR;
}
@@ -265,22 +275,24 @@ static Htop_Reaction actionToggleHideMeters(State* st) {
}
static Htop_Reaction actionExpandOrCollapseAllBranches(State* st) {
- ScreenSettings* ss = st->settings->ss;
+ Machine* host = st->host;
+ ScreenSettings* ss = host->settings->ss;
if (!ss->treeView) {
return HTOP_OK;
}
ss->allBranchesCollapsed = !ss->allBranchesCollapsed;
if (ss->allBranchesCollapsed)
- ProcessList_collapseAllBranches(st->pl);
+ ProcessList_collapseAllBranches(host->pl);
else
- ProcessList_expandTree(st->pl);
+ ProcessList_expandTree(host->pl);
return HTOP_REFRESH | HTOP_SAVE_SETTINGS;
}
static Htop_Reaction actionIncFilter(State* st) {
+ Machine* host = st->host;
IncSet* inc = (st->mainPanel)->inc;
IncSet_activate(inc, INC_FILTER, (Panel*)st->mainPanel);
- st->pl->incFilter = IncSet_filter(inc);
+ host->pl->incFilter = IncSet_filter(inc);
return HTOP_REFRESH | HTOP_KEEP_FOLLOWING;
}
@@ -307,13 +319,14 @@ static Htop_Reaction actionLowerPriority(State* st) {
}
static Htop_Reaction actionInvertSortOrder(State* st) {
- ScreenSettings_invertSortOrder(st->settings->ss);
- st->pl->needsSort = true;
+ Machine* host = st->host;
+ ScreenSettings_invertSortOrder(host->settings->ss);
+ host->pl->needsSort = true;
return HTOP_REFRESH | HTOP_SAVE_SETTINGS | HTOP_KEEP_FOLLOWING | HTOP_UPDATE_PANELHDR;
}
static Htop_Reaction actionExpandOrCollapse(State* st) {
- if (!st->settings->ss->treeView)
+ if (!st->host->settings->ss->treeView)
return HTOP_OK;
bool changed = expandCollapse((Panel*)st->mainPanel);
@@ -321,7 +334,7 @@ static Htop_Reaction actionExpandOrCollapse(State* st) {
}
static Htop_Reaction actionCollapseIntoParent(State* st) {
- if (!st->settings->ss->treeView) {
+ if (!st->host->settings->ss->treeView) {
return HTOP_OK;
}
bool changed = collapseIntoParent((Panel*)st->mainPanel);
@@ -329,11 +342,11 @@ static Htop_Reaction actionCollapseIntoParent(State* st) {
}
static Htop_Reaction actionExpandCollapseOrSortColumn(State* st) {
- return st->settings->ss->treeView ? actionExpandOrCollapse(st) : actionSetSortColumn(st);
+ return st->host->settings->ss->treeView ? actionExpandOrCollapse(st) : actionSetSortColumn(st);
}
static Htop_Reaction actionNextScreen(State* st) {
- Settings* settings = st->settings;
+ Settings* settings = st->host->settings;
settings->ssIndex++;
if (settings->ssIndex == settings->nScreens) {
settings->ssIndex = 0;
@@ -343,7 +356,7 @@ static Htop_Reaction actionNextScreen(State* st) {
}
static Htop_Reaction actionPrevScreen(State* st) {
- Settings* settings = st->settings;
+ Settings* settings = st->host->settings;
if (settings->ssIndex == 0) {
settings->ssIndex = settings->nScreens - 1;
} else {
@@ -379,7 +392,8 @@ static Htop_Reaction actionSetAffinity(State* st) {
if (Settings_isReadonly())
return HTOP_OK;
- if (st->pl->activeCPUs == 1)
+ Machine* host = st->host;
+ if (host->activeCPUs == 1)
return HTOP_OK;
#if (defined(HAVE_LIBHWLOC) || defined(HAVE_AFFINITY))
@@ -387,17 +401,17 @@ static Htop_Reaction actionSetAffinity(State* st) {
if (!p)
return HTOP_OK;
- Affinity* affinity1 = Affinity_get(p, st->pl);
+ Affinity* affinity1 = Affinity_get(p, host);
if (!affinity1)
return HTOP_OK;
int width;
- Panel* affinityPanel = AffinityPanel_new(st->pl, affinity1, &width);
+ Panel* affinityPanel = AffinityPanel_new(host, affinity1, &width);
Affinity_delete(affinity1);
const void* set = Action_pickFromVector(st, affinityPanel, width, true);
if (set) {
- Affinity* affinity2 = AffinityPanel_getAffinity(affinityPanel, st->pl);
+ Affinity* affinity2 = AffinityPanel_getAffinity(affinityPanel, host);
bool ok = MainPanel_foreachProcess(st->mainPanel, Affinity_set, (Arg) { .v = affinity2 }, NULL);
if (!ok)
beep();
@@ -479,16 +493,17 @@ static Htop_Reaction actionKill(State* st) {
static Htop_Reaction actionFilterByUser(State* st) {
Panel* usersPanel = Panel_new(0, 0, 0, 0, Class(ListItem), true, FunctionBar_newEnterEsc("Show ", "Cancel "));
Panel_setHeader(usersPanel, "Show processes of:");
- UsersTable_foreach(st->ut, addUserToVector, usersPanel);
+ Machine* host = st->host;
+ UsersTable_foreach(host->usersTable, addUserToVector, usersPanel);
Vector_insertionSort(usersPanel->items);
ListItem* allUsers = ListItem_new("All users", -1);
Panel_insert(usersPanel, 0, (Object*) allUsers);
const ListItem* picked = (ListItem*) Action_pickFromVector(st, usersPanel, 19, false);
if (picked) {
if (picked == allUsers) {
- st->pl->userId = (uid_t)-1;
+ host->userId = (uid_t)-1;
} else {
- Action_setUserOnly(ListItem_getRef(picked), &(st->pl->userId));
+ Action_setUserOnly(ListItem_getRef(picked), &host->userId);
}
}
Panel_delete((Object*)usersPanel);
@@ -496,7 +511,7 @@ static Htop_Reaction actionFilterByUser(State* st) {
}
Htop_Reaction Action_follow(State* st) {
- st->pl->following = MainPanel_selectedPid(st->mainPanel);
+ st->host->pl->following = MainPanel_selectedPid(st->mainPanel);
Panel_setSelectionColor((Panel*)st->mainPanel, PANEL_SELECTION_FOLLOW);
return HTOP_KEEP_FOLLOWING;
}
@@ -660,7 +675,7 @@ static Htop_Reaction actionHelp(State* st) {
addbartext(CRT_colors[CPU_NICE_TEXT], "", "low");
addbartext(CRT_colors[CPU_NORMAL], "/", "normal");
addbartext(CRT_colors[CPU_SYSTEM], "/", "kernel");
- if (st->settings->detailedCPUTime) {
+ if (st->host->settings->detailedCPUTime) {
addbartext(CRT_colors[CPU_IRQ], "/", "irq");
addbartext(CRT_colors[CPU_SOFTIRQ], "/", "soft-irq");
addbartext(CRT_colors[CPU_STEAL], "/", "steal");
diff --git a/Action.h b/Action.h
index 04d090f8..3540e93e 100644
--- a/Action.h
+++ b/Action.h
@@ -13,10 +13,10 @@ in the source distribution for its full text.
#include <sys/types.h>
#include "Header.h"
+#include "Machine.h"
#include "Object.h"
#include "Panel.h"
#include "Process.h"
-#include "ProcessList.h"
#include "Settings.h"
#include "UsersTable.h"
@@ -36,9 +36,7 @@ typedef enum {
struct MainPanel_; // IWYU pragma: keep
typedef struct State_ {
- Settings* settings;
- UsersTable* ut;
- ProcessList* pl;
+ Machine* host;
struct MainPanel_* mainPanel;
Header* header;
bool pauseUpdate;
@@ -47,12 +45,13 @@ typedef struct State_ {
} State;
static inline bool State_hideFunctionBar(const State* st) {
- return st->settings->hideFunctionBar == 2 || (st->settings->hideFunctionBar == 1 && st->hideSelection);
+ const Settings* settings = st->host->settings;
+ return settings->hideFunctionBar == 2 || (settings->hideFunctionBar == 1 && st->hideSelection);
}
typedef Htop_Reaction (*Htop_Action)(State* st);
-Object* Action_pickFromVector(State* st, Panel* list, int x, bool followProcess);
+Object* Action_pickFromVector(State* st, Panel* list, int x, bool follow);
bool Action_setUserOnly(const char* userName, uid_t* userId);
diff --git a/Affinity.c b/Affinity.c
index dc6a7fba..f7c597bf 100644
--- a/Affinity.c
+++ b/Affinity.c
@@ -27,11 +27,11 @@ in the source distribution for its full text.
#endif
-Affinity* Affinity_new(ProcessList* pl) {
+Affinity* Affinity_new(Machine* host) {
Affinity* this = xCalloc(1, sizeof(Affinity));
this->size = 8;
this->cpus = xCalloc(this->size, sizeof(unsigned int));
- this->pl = pl;
+ this->host = host;
return this;
}
@@ -52,14 +52,14 @@ void Affinity_add(Affinity* this, unsigned int id) {
#if defined(HAVE_LIBHWLOC)
-Affinity* Affinity_get(const Process* proc, ProcessList* pl) {
+Affinity* Affinity_get(const Process* proc, Machine* host) {
hwloc_cpuset_t cpuset = hwloc_bitmap_alloc();
- bool ok = (hwloc_get_proc_cpubind(pl->topology, proc->pid, cpuset, HTOP_HWLOC_CPUBIND_FLAG) == 0);
+ bool ok = (hwloc_get_proc_cpubind(host->topology, proc->pid, cpuset, HTOP_HWLOC_CPUBIND_FLAG) == 0);
Affinity* affinity = NULL;
if (ok) {
- affinity = Affinity_new(pl);
+ affinity = Affinity_new(host);
if (hwloc_bitmap_last(cpuset) == -1) {
- for (unsigned int i = 0; i < pl->existingCPUs; i++) {
+ for (unsigned int i = 0; i < host->existingCPUs; i++) {
Affinity_add(affinity, i);
}
} else {
@@ -79,21 +79,21 @@ bool Affinity_set(Process* proc, Arg arg) {
for (unsigned int i = 0; i < this->used; i++) {
hwloc_bitmap_set(cpuset, this->cpus[i]);
}
- bool ok = (hwloc_set_proc_cpubind(this->pl->topology, proc->pid, cpuset, HTOP_HWLOC_CPUBIND_FLAG) == 0);
+ bool ok = (hwloc_set_proc_cpubind(this->host->topology, proc->pid, cpuset, HTOP_HWLOC_CPUBIND_FLAG) == 0);
hwloc_bitmap_free(cpuset);
return ok;
}
#elif defined(HAVE_AFFINITY)
-Affinity* Affinity_get(const Process* proc, ProcessList* pl) {
+Affinity* Affinity_get(const Process* proc, Machine* host) {
cpu_set_t cpuset;
bool ok = (sched_getaffinity(proc->pid, sizeof(cpu_set_t), &cpuset) == 0);
if (!ok)
return NULL;
- Affinity* affinity = Affinity_new(pl);
- for (unsigned int i = 0; i < pl->existingCPUs; i++) {
+ Affinity* affinity = Affinity_new(host);
+ for (unsigned int i = 0; i < host->existingCPUs; i++) {
if (CPU_ISSET(i, &cpuset)) {
Affinity_add(affinity, i);
}
diff --git a/Affinity.h b/Affinity.h
index 5e7bfe2e..58d9bd73 100644
--- a/Affinity.h
+++ b/Affinity.h
@@ -3,14 +3,14 @@
/*
htop - Affinity.h
(C) 2004-2011 Hisham H. Muhammad
-(C) 2020 Red Hat, Inc. All Rights Reserved.
+(C) 2020,2023 Red Hat, Inc. All Rights Reserved.
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/
#include "config.h" // IWYU pragma: keep
-#include "ProcessList.h"
+#include "Machine.h"
#if defined(HAVE_LIBHWLOC) || defined(HAVE_AFFINITY)
#include <stdbool.h>
@@ -26,13 +26,13 @@ in the source distribution for its full text.
typedef struct Affinity_ {
- ProcessList* pl;
+ Machine* host;
unsigned int size;
unsigned int u