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

Merge branch 'wip' of https://github.com/hishamhm/htop into freebsd

Conflicts:
	htop.c
	unsupported/Platform.h
parents c29e53c5 50000d80
This diff is collapsed.
...@@ -11,24 +11,57 @@ in the source distribution for its full text. ...@@ -11,24 +11,57 @@ in the source distribution for its full text.
#define DEFAULT_DELAY 15 #define DEFAULT_DELAY 15
#include "ProcessList.h" #include "Process.h"
#include "Header.h"
#include <stdbool.h> #include <stdbool.h>
typedef struct {
int len;
char** names;
int* modes;
} MeterColumnSettings;
typedef struct Settings_ { typedef struct Settings_ {
char* userSettings; char* filename;
ProcessList* pl;
Header* header; MeterColumnSettings columns[2];
ProcessField* fields;
int flags;
int colorScheme; int colorScheme;
int delay; int delay;
int direction;
ProcessField sortKey;
bool countCPUsFromZero;
bool detailedCPUTime;
bool treeView;
bool hideThreads;
bool shadowOtherUsers;
bool showThreadNames;
bool hideKernelThreads;
bool hideUserlandThreads;
bool highlightBaseName;
bool highlightMegabytes;
bool highlightThreads;
bool updateProcessNames;
bool accountGuestInCPUMeter;
bool headerMargin;
bool changed; bool changed;
} Settings; } Settings;
#ifndef Settings_cpuId
#define Settings_cpuId(settings, cpu) ((settings)->countCPUsFromZero ? (cpu) : (cpu)+1)
#endif
void Settings_delete(Settings* this); void Settings_delete(Settings* this);
bool Settings_write(Settings* this); bool Settings_write(Settings* this);
Settings* Settings_new(ProcessList* pl, Header* header, int cpuCount); Settings* Settings_new(int cpuCount);
void Settings_invertSortOrder(Settings* this);
#endif #endif
...@@ -8,7 +8,7 @@ in the source distribution for its full text. ...@@ -8,7 +8,7 @@ in the source distribution for its full text.
#include "SwapMeter.h" #include "SwapMeter.h"
#include "CRT.h" #include "CRT.h"
#include "ProcessList.h" #include "Platform.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
...@@ -34,11 +34,8 @@ static void SwapMeter_humanNumber(char* buffer, const long int* value) { ...@@ -34,11 +34,8 @@ static void SwapMeter_humanNumber(char* buffer, const long int* value) {
} }
static void SwapMeter_setValues(Meter* this, char* buffer, int len) { static void SwapMeter_setValues(Meter* this, char* buffer, int len) {
long int usedSwap = this->pl->usedSwap; Platform_setSwapValues(this);
this->total = this->pl->totalSwap; snprintf(buffer, len, "%ld/%ldMB", (long int) this->values[0] / MEGABYTE, (long int) this->total / MEGABYTE);
this->values[0] = usedSwap;
snprintf(buffer, len, "%ld/%ldMB", (long int) usedSwap / MEGABYTE, (long int) this->total / MEGABYTE);
} }
static void SwapMeter_display(Object* cast, RichString* out) { static void SwapMeter_display(Object* cast, RichString* out) {
......
...@@ -7,7 +7,7 @@ in the source distribution for its full text. ...@@ -7,7 +7,7 @@ in the source distribution for its full text.
#include "TasksMeter.h" #include "TasksMeter.h"
#include "ProcessList.h" #include "Platform.h"
#include "CRT.h" #include "CRT.h"
/*{ /*{
...@@ -15,42 +15,46 @@ in the source distribution for its full text. ...@@ -15,42 +15,46 @@ in the source distribution for its full text.
}*/ }*/
int TasksMeter_attributes[] = { int TasksMeter_attributes[] = {
TASKS_RUNNING CPU_KERNEL, PROCESS_THREAD, PROCESS, TASKS_RUNNING
}; };
static void TasksMeter_setValues(Meter* this, char* buffer, int len) { static void TasksMeter_setValues(Meter* this, char* buffer, int len) {
ProcessList* pl = this->pl; Platform_setTasksValues(this);
this->total = pl->totalTasks; if (this->pl->settings->hideKernelThreads) {
this->values[0] = pl->runningTasks; this->values[0] = 0;
snprintf(buffer, len, "%d/%d", (int) this->values[0], (int) this->total); }
snprintf(buffer, len, "%d/%d", (int) this->values[3], (int) this->total);
} }
static void TasksMeter_display(Object* cast, RichString* out) { static void TasksMeter_display(Object* cast, RichString* out) {
Meter* this = (Meter*)cast; Meter* this = (Meter*)cast;
ProcessList* pl = this->pl; Settings* settings = this->pl->settings;
char buffer[20]; char buffer[20];
sprintf(buffer, "%d", (int)(this->total - pl->userlandThreads - pl->kernelThreads));
int processes = (int) this->values[2];
sprintf(buffer, "%d", processes);
RichString_write(out, CRT_colors[METER_VALUE], buffer); RichString_write(out, CRT_colors[METER_VALUE], buffer);
int threadValueColor = CRT_colors[METER_VALUE]; int threadValueColor = CRT_colors[METER_VALUE];
int threadCaptionColor = CRT_colors[METER_TEXT]; int threadCaptionColor = CRT_colors[METER_TEXT];
if (pl->highlightThreads) { if (settings->highlightThreads) {
threadValueColor = CRT_colors[PROCESS_THREAD_BASENAME]; threadValueColor = CRT_colors[PROCESS_THREAD_BASENAME];
threadCaptionColor = CRT_colors[PROCESS_THREAD]; threadCaptionColor = CRT_colors[PROCESS_THREAD];
} }
if (!pl->hideUserlandThreads) { if (!settings->hideUserlandThreads) {
RichString_append(out, CRT_colors[METER_TEXT], ", "); RichString_append(out, CRT_colors[METER_TEXT], ", ");
sprintf(buffer, "%d", (int)pl->userlandThreads); sprintf(buffer, "%d", (int)this->values[1]);
RichString_append(out, threadValueColor, buffer); RichString_append(out, threadValueColor, buffer);
RichString_append(out, threadCaptionColor, " thr"); RichString_append(out, threadCaptionColor, " thr");
} }
if (!pl->hideKernelThreads) { if (!settings->hideKernelThreads) {
RichString_append(out, CRT_colors[METER_TEXT], ", "); RichString_append(out, CRT_colors[METER_TEXT], ", ");
sprintf(buffer, "%d", (int)pl->kernelThreads); sprintf(buffer, "%d", (int)this->values[0]);
RichString_append(out, threadValueColor, buffer); RichString_append(out, threadValueColor, buffer);
RichString_append(out, threadCaptionColor, " kthr"); RichString_append(out, threadCaptionColor, " kthr");
} }
RichString_append(out, CRT_colors[METER_TEXT], "; "); RichString_append(out, CRT_colors[METER_TEXT], "; ");
sprintf(buffer, "%d", (int)this->values[0]); sprintf(buffer, "%d", (int)this->values[3]);
RichString_append(out, CRT_colors[TASKS_RUNNING], buffer); RichString_append(out, CRT_colors[TASKS_RUNNING], buffer);
RichString_append(out, CRT_colors[METER_TEXT], " running"); RichString_append(out, CRT_colors[METER_TEXT], " running");
} }
...@@ -64,6 +68,7 @@ MeterClass TasksMeter_class = { ...@@ -64,6 +68,7 @@ MeterClass TasksMeter_class = {
.setValues = TasksMeter_setValues, .setValues = TasksMeter_setValues,
.defaultMode = TEXT_METERMODE, .defaultMode = TEXT_METERMODE,
.total = 100.0, .total = 100.0,
.maxItems = 4,
.attributes = TasksMeter_attributes, .attributes = TasksMeter_attributes,
.name = "Tasks", .name = "Tasks",
.uiName = "Task counter", .uiName = "Task counter",
......
...@@ -193,6 +193,10 @@ void Vector_insert(Vector* this, int idx, void* data_) { ...@@ -193,6 +193,10 @@ void Vector_insert(Vector* this, int idx, void* data_) {
assert(Object_isA(data, this->type)); assert(Object_isA(data, this->type));
assert(Vector_isConsistent(this)); assert(Vector_isConsistent(this));
if (idx > this->items) {
idx = this->items;
}
Vector_checkArraySize(this); Vector_checkArraySize(this);
//assert(this->array[this->items] == NULL); //assert(this->array[this->items] == NULL);
for (int i = this->items; i > idx; i--) { for (int i = this->items; i > idx; i--) {
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
AC_PREREQ(2.65) AC_PREREQ(2.65)
AC_INIT([htop],[1.0.3],[hisham@gobolinux.org]) AC_INIT([htop],[1.0.3],[hisham@gobolinux.org])
year=$(date +%Y)
# The following two lines are required by hwloc scripts # The following two lines are required by hwloc scripts
AC_USE_SYSTEM_EXTENSIONS AC_USE_SYSTEM_EXTENSIONS
AC_CANONICAL_TARGET AC_CANONICAL_TARGET
...@@ -71,6 +73,19 @@ AC_TRY_COMPILE(AC_INCLUDES_DEFAULT, [char *a; a = strdup("foo"); int i = 0; i++; ...@@ -71,6 +73,19 @@ AC_TRY_COMPILE(AC_INCLUDES_DEFAULT, [char *a; a = strdup("foo"); int i = 0; i++;
AC_MSG_ERROR([htop is written in C99. A newer version of gcc is required.])) AC_MSG_ERROR([htop is written in C99. A newer version of gcc is required.]))
CFLAGS="$save_cflags" CFLAGS="$save_cflags"
save_cflags="${CFLAGS}"
CFLAGS="$CFLAGS -Wextra"
AC_MSG_CHECKING([if compiler supports -Wextra])
AC_TRY_COMPILE([], [], [
wextra_flag=-Wextra
AC_MSG_RESULT([yes])
],[
wextra_flag=
AC_MSG_RESULT([no])
])
CFLAGS="$save_cflags"
AC_SUBST(wextra_flag)
# Checks for features and flags. # Checks for features and flags.
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
PROCDIR=/proc PROCDIR=/proc
...@@ -187,6 +202,8 @@ if test ! -z "$missing_headers"; then ...@@ -187,6 +202,8 @@ if test ! -z "$missing_headers"; then
AC_MSG_ERROR([missing headers: $missing_headers]) AC_MSG_ERROR([missing headers: $missing_headers])
fi fi
AC_DEFINE_UNQUOTED(COPYRIGHT, "(C) 2004-$year Hisham Muhammad", [Copyright message.])
# We're done, let's go! # We're done, let's go!
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
AM_CONDITIONAL([HTOP_LINUX], [test "$my_htop_platform" = linux]) AM_CONDITIONAL([HTOP_LINUX], [test "$my_htop_platform" = linux])
......
...@@ -319,13 +319,13 @@ Bytes of write(2) I/O for the process. ...@@ -319,13 +319,13 @@ Bytes of write(2) I/O for the process.
.B CNCLWB (IO_CANCEL) .B CNCLWB (IO_CANCEL)
Bytes of cancelled write(2) I/O. Bytes of cancelled write(2) I/O.
.TP .TP
.B IO_READ_RATE (IORR) .B IO_READ_RATE (DISK READ)
The I/O rate of read(2) in bytes per second, for the process. The I/O rate of read(2) in bytes per second, for the process.
.TP .TP
.B IO_WRITE_RATE (IOWR) .B IO_WRITE_RATE (DISK WRITE)
The I/O rate of write(2) in bytes per second, for the process. The I/O rate of write(2) in bytes per second, for the process.
.TP .TP
.B IO_RATE (IORW) .B IO_RATE (DISK R/W)
The I/O rate, IO_READ_RATE + IO_WRITE_RATE (see above). The I/O rate, IO_READ_RATE + IO_WRITE_RATE (see above).
.TP .TP
.B CGROUP .B CGROUP
......
This diff is collapsed.
...@@ -11,11 +11,8 @@ in the source distribution for its full text. ...@@ -11,11 +11,8 @@ in the source distribution for its full text.
//#link m //#link m
#define COPYRIGHT "(C) 2004-2014 Hisham Muhammad"
// ---------------------------------------- // ----------------------------------------
// ----------------------------------------
int main(int argc, char** argv); int main(int argc, char** argv);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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