Commit adbfe3c3 authored by Hisham Muhammad's avatar Hisham Muhammad
Browse files

Get FreeBSD tree to compile again with latest changes.

parent 40f3391a
...@@ -129,7 +129,9 @@ ColumnsPanel* ColumnsPanel_new(Settings* settings) { ...@@ -129,7 +129,9 @@ ColumnsPanel* ColumnsPanel_new(Settings* settings) {
ProcessField* fields = this->settings->fields; ProcessField* fields = this->settings->fields;
for (; *fields; fields++) { for (; *fields; fields++) {
Panel_add(super, (Object*) ListItem_new(Process_fields[*fields].name, *fields)); if (Process_fields[*fields].name) {
Panel_add(super, (Object*) ListItem_new(Process_fields[*fields].name, *fields));
}
} }
return this; return this;
} }
......
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_MainPanel
#define HEADER_MainPanel
/*
htop - ColumnsPanel.h
(C) 2004-2015 Hisham H. Muhammad
Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/
#include "Panel.h"
#include "Action.h"
#include "Settings.h"
typedef struct MainPanel_ {
Panel super;
State* state;
FunctionBar* fuBar;
Htop_Action *keys;
pid_t pidSearch;
} MainPanel;
typedef bool(*MainPanel_ForeachProcessFn)(Process*, size_t);
void MainPanel_updateTreeFunctions(FunctionBar* fuBar, bool mode);
void MainPanel_pidSearch(MainPanel* this, int ch);
int MainPanel_selectedPid(MainPanel* this);
const char* MainPanel_getValue(MainPanel* this, int i);
bool MainPanel_foreachProcess(MainPanel* this, MainPanel_ForeachProcessFn fn, int arg, bool* wasAnyTagged);
extern PanelClass MainPanel_class;
MainPanel* MainPanel_new(FunctionBar* fuBar);
void MainPanel_setState(MainPanel* this, State* state);
void MainPanel_delete(Object* object);
#endif
...@@ -12,7 +12,7 @@ applications_DATA = htop.desktop ...@@ -12,7 +12,7 @@ applications_DATA = htop.desktop
pixmapdir = $(datadir)/pixmaps pixmapdir = $(datadir)/pixmaps
pixmap_DATA = htop.png pixmap_DATA = htop.png
htop_CFLAGS = -pedantic -Wall $(wextra_flag) -std=c99 -rdynamic -D_XOPEN_SOURCE_EXTENDED -DSYSCONFDIR=\"$(sysconfdir)\" -I"$(my_htop_platform)" htop_CFLAGS = -pedantic -Wall $(wextra_flag) -std=c99 -D_XOPEN_SOURCE_EXTENDED -DSYSCONFDIR=\"$(sysconfdir)\" -I"$(my_htop_platform)"
AM_CPPFLAGS = -DNDEBUG AM_CPPFLAGS = -DNDEBUG
myhtopsources = AvailableMetersPanel.c CategoriesPanel.c CheckItem.c \ myhtopsources = AvailableMetersPanel.c CategoriesPanel.c CheckItem.c \
...@@ -34,6 +34,7 @@ UptimeMeter.h TraceScreen.h UsersTable.h Vector.h Process.h AffinityPanel.h \ ...@@ -34,6 +34,7 @@ UptimeMeter.h TraceScreen.h UsersTable.h Vector.h Process.h AffinityPanel.h \
HostnameMeter.h OpenFilesScreen.h Affinity.h IncSet.h Action.h HostnameMeter.h OpenFilesScreen.h Affinity.h IncSet.h Action.h
if HTOP_LINUX if HTOP_LINUX
htop_CFLAGS += -rdynamic
myhtopplatsources = linux/Platform.c linux/IOPriorityPanel.c linux/IOPriority.c \ myhtopplatsources = linux/Platform.c linux/IOPriorityPanel.c linux/IOPriority.c \
linux/LinuxProcess.c linux/LinuxProcessList.c linux/LinuxCRT.c linux/Battery.c linux/LinuxProcess.c linux/LinuxProcessList.c linux/LinuxCRT.c linux/Battery.c
...@@ -43,10 +44,10 @@ endif ...@@ -43,10 +44,10 @@ endif
if HTOP_FREEBSD if HTOP_FREEBSD
myhtopplatsources = freebsd/Platform.c freebsd/FreeBSDProcessList.c \ myhtopplatsources = freebsd/Platform.c freebsd/FreeBSDProcessList.c \
freebsd/FreeBSDCRT.c freebsd/FreeBSDProcess.c freebsd/FreeBSDCRT.c freebsd/Battery.c
myhtopplatheaders = freebsd/Platform.h freebsd/FreeBSDProcessList.h \ myhtopplatheaders = freebsd/Platform.h freebsd/FreeBSDProcessList.h \
freebsd/FreeBSDCRT.h freebsd/FreeBSDProcess.h freebsd/FreeBSDCRT.h freebsd/Battery.h
endif endif
if HTOP_UNSUPPORTED if HTOP_UNSUPPORTED
......
...@@ -49,6 +49,16 @@ typedef struct ProcessList_ { ...@@ -49,6 +49,16 @@ typedef struct ProcessList_ {
bool topologyOk; bool topologyOk;
#endif #endif
unsigned long long int totalMem;
unsigned long long int usedMem;
unsigned long long int freeMem;
unsigned long long int sharedMem;
unsigned long long int buffersMem;
unsigned long long int cachedMem;
unsigned long long int totalSwap;
unsigned long long int usedSwap;
unsigned long long int freeSwap;
int cpuCount; int cpuCount;
} ProcessList; } ProcessList;
......
...@@ -43,6 +43,16 @@ typedef struct ProcessList_ { ...@@ -43,6 +43,16 @@ typedef struct ProcessList_ {
bool topologyOk; bool topologyOk;
#endif #endif
unsigned long long int totalMem;
unsigned long long int usedMem;
unsigned long long int freeMem;
unsigned long long int sharedMem;
unsigned long long int buffersMem;
unsigned long long int cachedMem;
unsigned long long int totalSwap;
unsigned long long int usedSwap;
unsigned long long int freeSwap;
int cpuCount; int cpuCount;
} ProcessList; } ProcessList;
......
...@@ -139,7 +139,7 @@ static void readFields(ProcessField* fields, int* flags, const char* line) { ...@@ -139,7 +139,7 @@ static void readFields(ProcessField* fields, int* flags, const char* line) {
for (j = 0, i = 0; i < Platform_numberOfFields && ids[i]; i++) { for (j = 0, i = 0; i < Platform_numberOfFields && ids[i]; i++) {
// This "+1" is for compatibility with the older enum format. // This "+1" is for compatibility with the older enum format.
int id = atoi(ids[i]) + 1; int id = atoi(ids[i]) + 1;
if (id > 0 && id < Platform_numberOfFields) { if (id > 0 && Process_fields[id].name && id < Platform_numberOfFields) {
fields[j] = id; fields[j] = id;
*flags |= Process_fields[id].flags; *flags |= Process_fields[id].flags;
j++; j++;
......
/*
htop - freebsd/Battery.c
(C) 2015 Hisham H. Muhammad
Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/
#include "BatteryMeter.h"
void Battery_getData(double* level, ACPresence* isOnAC) {
// TODO
*level = -1;
*isOnAC = AC_ERROR;
}
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_Battery
#define HEADER_Battery
/*
htop - freebsd/Battery.h
(C) 2015 Hisham H. Muhammad
Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/
void Battery_getData(double* level, ACPresence* isOnAC);
#endif
/*
htop - FreeBSDProcess.c
(C) 2015 Hisham H. Muhammad
Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/
#include "Process.h"
#include "ProcessList.h"
#include "FreeBSDProcess.h"
#include "Platform.h"
#include "CRT.h"
#include <stdlib.h>
#include <unistd.h>
#include <sys/syscall.h>
/*{
typedef enum FreeBSDProcessFields {
// Add platform-specific fields here, with ids >= 100
LAST_PROCESSFIELD = 100,
} FreeBSDProcessField;
typedef struct FreeBSDProcess_ {
Process super;
} FreeBSDProcess;
}*/
ProcessFieldData Process_fields[] = {
[0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, },
[PID] = { .name = "PID", .title = " PID ", .description = "Process/thread ID", .flags = 0, },
[COMM] = { .name = "Command", .title = "Command ", .description = "Command line", .flags = 0, },
[STATE] = { .name = "STATE", .title = "S ", .description = "Process state (S sleeping, R running, D disk, Z zombie, T traced, W paging)", .flags = 0, },
[PPID] = { .name = "PPID", .title = " PPID ", .description = "Parent process ID", .flags = 0, },
[PGRP] = { .name = "PGRP", .title = " PGRP ", .description = "Process group ID", .flags = 0, },
[SESSION] = { .name = "SESSION", .title = " SESN ", .description = "Process's session ID", .flags = 0, },
[TTY_NR] = { .name = "TTY_NR", .title = " TTY ", .description = "Controlling terminal", .flags = 0, },
[TPGID] = { .name = "TPGID", .title = " TPGID ", .description = "Process ID of the fg process group of the controlling terminal", .flags = 0, },
[MINFLT] = { .name = "MINFLT", .title = " MINFLT ", .description = "Number of minor faults which have not required loading a memory page from disk", .flags = 0, },
[MAJFLT] = { .name = "MAJFLT", .title = " MAJFLT ", .description = "Number of major faults which have required loading a memory page from disk", .flags = 0, },
[PRIORITY] = { .name = "PRIORITY", .title = "PRI ", .description = "Kernel's internal priority for the process", .flags = 0, },
[NICE] = { .name = "NICE", .title = " NI ", .description = "Nice value (the higher the value, the more it lets other processes take priority)", .flags = 0, },
[STARTTIME] = { .name = "STARTTIME", .title = "START ", .description = "Time the process was started", .flags = 0, },
[M_SIZE] = { .name = "M_SIZE", .title = " VIRT ", .description = "Total program size in virtual memory", .flags = 0, },
[M_RESIDENT] = { .name = "M_RESIDENT", .title = " RES ", .description = "Resident set size, size of the text and data sections, plus stack usage", .flags = 0, },
[ST_UID] = { .name = "ST_UID", .title = " UID ", .description = "User ID of the process owner", .flags = 0, },
[PERCENT_CPU] = { .name = "PERCENT_CPU", .title = "CPU% ", .description = "Percentage of the CPU time the process used in the last sampling", .flags = 0, },
[PERCENT_MEM] = { .name = "PERCENT_MEM", .title = "MEM% ", .description = "Percentage of the memory the process is using, based on resident memory size", .flags = 0, },
[USER] = { .name = "USER", .title = "USER ", .description = "Username of the process owner (or user ID if name cannot be determined)", .flags = 0, },
[TIME] = { .name = "TIME", .title = " TIME+ ", .description = "Total time the process has spent in user and system time", .flags = 0, },
[NLWP] = { .name = "NLWP", .title = "NLWP ", .description = "Number of threads in the process", .flags = 0, },
[TGID] = { .name = "TGID", .title = " TGID ", .description = "Thread group ID (i.e. process ID)", .flags = 0, },
[LAST_PROCESSFIELD] = { .name = "*** report bug! ***", .title = NULL, .description = NULL, .flags = 0, },
};
char* Process_pidFormat = "%7u ";
char* Process_tpgidFormat = "%7u ";
void Process_setupColumnWidths() {
int maxPid = Platform_getMaxPid();
if (maxPid == -1) return;
if (maxPid > 99999) {
Process_fields[PID].title = " PID ";
Process_fields[PPID].title = " PPID ";
Process_fields[TPGID].title = " TPGID ";
Process_fields[TGID].title = " TGID ";
Process_fields[PGRP].title = " PGRP ";
Process_fields[SESSION].title = " SESN ";
Process_pidFormat = "%7u ";
Process_tpgidFormat = "%7d ";
} else {
Process_fields[PID].title = " PID ";
Process_fields[PPID].title = " PPID ";
Process_fields[TPGID].title = "TPGID ";
Process_fields[TGID].title = " TGID ";
Process_fields[PGRP].title = " PGRP ";
Process_fields[SESSION].title = " SESN ";
Process_pidFormat = "%5u ";
Process_tpgidFormat = "%5d ";
}
}
FreeBSDProcess* FreeBSDProcess_new(Settings* settings) {
FreeBSDProcess* this = calloc(sizeof(FreeBSDProcess), 1);
Object_setClass(this, Class(Process));
Process_init(&this->super, settings);
return this;
}
void Process_delete(Object* cast) {
FreeBSDProcess* this = (FreeBSDProcess*) cast;
Process_done((Process*)cast);
free(this);
}
void Process_writeField(Process* this, RichString* str, ProcessField field) {
//FreeBSDProcess* fp = (FreeBSDProcess*) this;
char buffer[256]; buffer[255] = '\0';
int attr = CRT_colors[DEFAULT_COLOR];
//int n = sizeof(buffer) - 1;
switch (field) {
// add FreeBSD-specific fields here
default:
Process_writeDefaultField(this, str, field);
return;
}
RichString_append(str, attr, buffer);
}
long Process_compare(const void* v1, const void* v2) {
FreeBSDProcess *p1, *p2;
Settings *settings = ((Process*)v1)->settings;
if (settings->direction == 1) {
p1 = (FreeBSDProcess*)v1;
p2 = (FreeBSDProcess*)v2;
} else {
p2 = (FreeBSDProcess*)v1;
p1 = (FreeBSDProcess*)v2;
}
switch (settings->sortKey) {
// add FreeBSD-specific fields here
default:
return Process_defaultCompare(v1, v2);
}
}
bool Process_isThread(Process* this) {
(void) this;
// TODO
return false;
}
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_FreeBSDProcess
#define HEADER_FreeBSDProcess
/*
htop - FreeBSDProcess.h
(C) 2015 Hisham H. Muhammad
Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/
typedef enum FreeBSDProcessFields {
// Add platform-specific fields here, with ids >= 100
LAST_PROCESSFIELD = 100,
} FreeBSDProcessField;
typedef struct FreeBSDProcess_ {
Process super;
} FreeBSDProcess;
extern ProcessFieldData Process_fields[];
extern char* Process_pidFormat;
extern char* Process_tpgidFormat;
void Process_setupColumnWidths();
FreeBSDProcess* FreeBSDProcess_new(Settings* settings);
void Process_delete(Object* cast);
void Process_writeField(Process* this, RichString* str, ProcessField field);
long Process_compare(const void* v1, const void* v2);
bool Process_isThread(Process* this);
#endif
...@@ -18,9 +18,17 @@ in the source distribution for its full text. ...@@ -18,9 +18,17 @@ in the source distribution for its full text.
#include <kvm.h> #include <kvm.h>
typedef struct CPUData_ {
unsigned long long int totalTime;
unsigned long long int totalPeriod;
} CPUData;
typedef struct FreeBSDProcessList_ { typedef struct FreeBSDProcessList_ {
ProcessList super; ProcessList super;
kvm_t* kd; kvm_t* kd;
CPUData* cpus;
} FreeBSDProcessList; } FreeBSDProcessList;
}*/ }*/
...@@ -31,21 +39,21 @@ static int MIB_hw_physmem[2]; ...@@ -31,21 +39,21 @@ static int MIB_hw_physmem[2];
static int pageSizeKb; static int pageSizeKb;
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList) { ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId) {
FreeBSDProcessList* fpl = calloc(1, sizeof(FreeBSDProcessList)); FreeBSDProcessList* fpl = calloc(1, sizeof(FreeBSDProcessList));
ProcessList* pl = (ProcessList*) fpl; ProcessList* pl = (ProcessList*) fpl;
ProcessList_init(pl, usersTable, pidWhiteList); ProcessList_init(pl, usersTable, pidWhiteList, userId);
int cpus = 1; int cpus = 1;
size_t sizeof_cpus = sizeof(cpus); size_t sizeof_cpus = sizeof(cpus);
int err = sysctlbyname("hw.ncpu", &cpus, &sizeof_cpus, NULL, 0); int err = sysctlbyname("hw.ncpu", &cpus, &sizeof_cpus, NULL, 0);
if (err) cpus = 1; if (err) cpus = 1;
pl->cpuCount = MAX(cpus, 1); pl->cpuCount = MAX(cpus, 1);
pl->cpus = realloc(pl->cpus, cpus * sizeof(CPUData)); fpl->cpus = realloc(fpl->cpus, cpus * sizeof(CPUData));
for (int i = 0; i < cpus; i++) { for (int i = 0; i < cpus; i++) {
pl->cpus[i].totalTime = 1; fpl->cpus[i].totalTime = 1;
pl->cpus[i].totalPeriod = 1; fpl->cpus[i].totalPeriod = 1;
} }
size_t len; size_t len;
......
...@@ -12,13 +12,21 @@ in the source distribution for its full text. ...@@ -12,13 +12,21 @@ in the source distribution for its full text.
#include <kvm.h> #include <kvm.h>
typedef struct CPUData_ {
unsigned long long int totalTime;
unsigned long long int totalPeriod;
} CPUData;
typedef struct FreeBSDProcessList_ { typedef struct FreeBSDProcessList_ {
ProcessList super; ProcessList super;
kvm_t* kd; kvm_t* kd;
CPUData* cpus;
} FreeBSDProcessList; } FreeBSDProcessList;
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList); ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId);
void ProcessList_delete(ProcessList* this); void ProcessList_delete(ProcessList* this);
......
...@@ -15,6 +15,7 @@ in the source distribution for its full text. ...@@ -15,6 +15,7 @@ in the source distribution for its full text.
#include "UptimeMeter.h" #include "UptimeMeter.h"
#include "ClockMeter.h" #include "ClockMeter.h"
#include "HostnameMeter.h" #include "HostnameMeter.h"
#include "FreeBSDProcess.h"
#include <sys/types.h> #include <sys/types.h>
#include <sys/sysctl.h> #include <sys/sysctl.h>
...@@ -26,8 +27,15 @@ in the source distribution for its full text. ...@@ -26,8 +27,15 @@ in the source distribution for its full text.
/*{ /*{
#include "Action.h" #include "Action.h"
#include "BatteryMeter.h" #include "BatteryMeter.h"
extern ProcessFieldData Process_fields[];
}*/ }*/
ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_SIZE, M_RESIDENT, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 };
int Platform_numberOfFields = LAST_PROCESSFIELD;
void Platform_setBindings(Htop_Action* keys) { void Platform_setBindings(Htop_Action* keys) {
(void) keys; (void) keys;
} }
...@@ -94,9 +102,18 @@ int Platform_getMaxPid() { ...@@ -94,9 +102,18 @@ int Platform_getMaxPid() {
return maxPid; return maxPid;
} }
void Platform_getBatteryLevel(double* level, ACPresence* isOnAC) { double Platform_setCPUValues(Meter* this, int cpu) {
// TODO
}
void Platform_setMemoryValues(Meter* this) {
// TODO
}
void Platform_setSwapValues(Meter* this) {
// TODO // TODO
*level = -1;
*isOnAC = AC_ERROR;
} }
void Platform_setTasksValues(Meter* this) {
// TODO
}
...@@ -12,6 +12,13 @@ in the source distribution for its full text. ...@@ -12,6 +12,13 @@ in the source distribution for its full text.
#include "Action.h" #include "Action.h"
#include "BatteryMeter.h" #include "BatteryMeter.h"
extern ProcessFieldData Process_fields[];
extern ProcessField Platform_defaultFields[];
extern int Platform_numberOfFields;
void Platform_setBindings(Htop_Action* keys); void Platform_setBindings(Htop_Action* keys);
extern MeterClass* Platform_meterTypes[]; extern MeterClass* Platform_meterTypes[];
...@@ -22,7 +29,12 @@ void Platform_getLoadAverage(double* one, double* five, double* fifteen); ...@@ -22,7 +29,12 @@ void Platform_getLoadAverage(double* one, double* five, double* fifteen);
int Platform_getMaxPid(); int Platform_getMaxPid();
void Platform_getBatteryLevel(double* level, ACPresence* isOnAC); double Platform_setCPUValues(Meter* this, int cpu);
void Platform_setMemoryValues(Meter* this);
void Platform_setSwapValues(Meter* this);
void Platform_setTasksValues(Meter* this);
#endif #endif
...@@ -83,7 +83,7 @@ typedef enum LinuxProcessFields { ...@@ -83,7 +83,7 @@ typedef enum LinuxProcessFields {
OOM = 114, OOM = 114,
#endif #endif
IO_PRIORITY = 115, IO_PRIORITY = 115,
LAST_PROCESSFIELD LAST_PROCESSFIELD = 116,
} LinuxProcessField; } LinuxProcessField;
#include "IOPriority.h" #include "IOPriority.h"
......
...@@ -69,16 +69,6 @@ typedef struct LinuxProcessList_ { ...@@ -69,16 +69,6 @@ typedef struct LinuxProcessList_ {
CPUData* cpus; CPUData* cpus;
unsigned long long int totalMem;
unsigned long long int usedMem;
unsigned long long int freeMem;
unsigned long long int sharedMem;
unsigned long long int buffersMem;
unsigned long long int cachedMem;
unsigned long long int totalSwap;
unsigned long long int usedSwap;
unsigned long long int freeSwap;
} LinuxProcessList; } LinuxProcessList;
#ifndef PROCDIR #ifndef PROCDIR
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment