summaryrefslogtreecommitdiffstats
path: root/freebsd
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2015-03-16 03:13:42 -0300
committerHisham Muhammad <hisham@gobolinux.org>2015-03-16 03:14:20 -0300
commitadbfe3c3f171af332322d61f2a4912f36b57edda (patch)
tree6ac08e0b6c2b8b4d3d2582a0700164159034122d /freebsd
parent40f3391a3c5d391c096aa3d4c0a61cbf79c37060 (diff)
Get FreeBSD tree to compile again with latest changes.
Diffstat (limited to 'freebsd')
-rw-r--r--freebsd/Battery.c15
-rw-r--r--freebsd/Battery.h15
-rw-r--r--freebsd/FreeBSDProcess.c134
-rw-r--r--freebsd/FreeBSDProcess.h40
-rw-r--r--freebsd/FreeBSDProcessList.c18
-rw-r--r--freebsd/FreeBSDProcessList.h10
-rw-r--r--freebsd/Platform.c23
-rw-r--r--freebsd/Platform.h14
8 files changed, 259 insertions, 10 deletions
diff --git a/freebsd/Battery.c b/freebsd/Battery.c
new file mode 100644
index 00000000..ab63aa10
--- /dev/null
+++ b/freebsd/Battery.c
@@ -0,0 +1,15 @@
+/*
+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;
+}
+
diff --git a/freebsd/Battery.h b/freebsd/Battery.h
new file mode 100644
index 00000000..2b4a9a87
--- /dev/null
+++ b/freebsd/Battery.h
@@ -0,0 +1,15 @@
+/* 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
diff --git a/freebsd/FreeBSDProcess.c b/freebsd/FreeBSDProcess.c
new file mode 100644
index 00000000..614a6b8e
--- /dev/null
+++ b/freebsd/FreeBSDProcess.c
@@ -0,0 +1,134 @@
+/*
+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;
+}
diff --git a/freebsd/FreeBSDProcess.h b/freebsd/FreeBSDProcess.h
new file mode 100644
index 00000000..42a1fcb1
--- /dev/null
+++ b/freebsd/FreeBSDProcess.h
@@ -0,0 +1,40 @@
+/* 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
diff --git a/freebsd/FreeBSDProcessList.c b/freebsd/FreeBSDProcessList.c
index ac985005..24ab833e 100644
--- a/freebsd/FreeBSDProcessList.c
+++ b/freebsd/FreeBSDProcessList.c
@@ -18,9 +18,17 @@ in the source distribution for its full text.
#include <kvm.h>
+typedef struct CPUData_ {
+ unsigned long long int totalTime;
+ unsigned long long int totalPeriod;
+} CPUData;
+
typedef struct FreeBSDProcessList_ {
ProcessList super;
kvm_t* kd;
+
+ CPUData* cpus;
+
} FreeBSDProcessList;
}*/
@@ -31,21 +39,21 @@ static int MIB_hw_physmem[2];
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));
ProcessList* pl = (ProcessList*) fpl;
- ProcessList_init(pl, usersTable, pidWhiteList);
+ ProcessList_init(pl, usersTable, pidWhiteList, userId);
int cpus = 1;
size_t sizeof_cpus = sizeof(cpus);
int err = sysctlbyname("hw.ncpu", &cpus, &sizeof_cpus, NULL, 0);
if (err) 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++) {
- pl->cpus[i].totalTime = 1;
- pl->cpus[i].totalPeriod = 1;
+ fpl->cpus[i].totalTime = 1;
+ fpl->cpus[i].totalPeriod = 1;
}
size_t len;
diff --git a/freebsd/FreeBSDProcessList.h b/freebsd/FreeBSDProcessList.h
index 11a5dde7..5127175b 100644
--- a/freebsd/FreeBSDProcessList.h
+++ b/freebsd/FreeBSDProcessList.h
@@ -12,13 +12,21 @@ in the source distribution for its full text.
#include <kvm.h>
+typedef struct CPUData_ {
+ unsigned long long int totalTime;
+ unsigned long long int totalPeriod;
+} CPUData;
+
typedef struct FreeBSDProcessList_ {
ProcessList super;
kvm_t* kd;
+
+ CPUData* cpus;
+
} FreeBSDProcessList;
-ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList);
+ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId);
void ProcessList_delete(ProcessList* this);
diff --git a/freebsd/Platform.c b/freebsd/Platform.c
index 72f6e425..0254fe40 100644
--- a/freebsd/Platform.c
+++ b/freebsd/Platform.c
@@ -15,6 +15,7 @@ in the source distribution for its full text.
#include "UptimeMeter.h"
#include "ClockMeter.h"
#include "HostnameMeter.h"
+#include "FreeBSDProcess.h"
#include <sys/types.h>
#include <sys/sysctl.h>
@@ -26,8 +27,15 @@ in the source distribution for its full text.
/*{
#include "Action.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) keys;
}
@@ -94,9 +102,18 @@ int Platform_getMaxPid() {
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
- *level = -1;
- *isOnAC = AC_ERROR;
}
+void Platform_setTasksValues(Meter* this) {
+ // TODO
+}
diff --git a/freebsd/Platform.h b/freebsd/Platform.h
index eb2a8017..3758f57d 100644
--- a/freebsd/Platform.h
+++ b/freebsd/Platform.h
@@ -12,6 +12,13 @@ in the source distribution for its full text.
#include "Action.h"
#include "BatteryMeter.h"
+extern ProcessFieldData Process_fields[];
+
+
+extern ProcessField Platform_defaultFields[];
+
+extern int Platform_numberOfFields;
+
void Platform_setBindings(Htop_Action* keys);
extern MeterClass* Platform_meterTypes[];
@@ -22,7 +29,12 @@ void Platform_getLoadAverage(double* one, double* five, double* fifteen);
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

© 2014-2024 Faster IT GmbH | imprint | privacy policy