Commit 3b950e41 authored by Hisham Muhammad's avatar Hisham Muhammad
Browse files

BSD related fixes:

* BUGFIX: Correct page size calculation for FreeBSD systems
  (thanks to Andrew Paulsen)
* Allow compilation without PLPA on systems that don't support it
  (thanks to Timothy Redaelli)
parent b93e5c00
...@@ -6,6 +6,10 @@ What's new in version 0.8.2 ...@@ -6,6 +6,10 @@ What's new in version 0.8.2
(thanks to Thorsten Schifferdecker) (thanks to Thorsten Schifferdecker)
* Corrections to the desktop entry file * Corrections to the desktop entry file
(thanks by Samuli Suominen) (thanks by Samuli Suominen)
* BUGFIX: Correct page size calculation for FreeBSD systems
(thanks to Andrew Paulsen)
* Allow compilation without PLPA on systems that don't support it
(thanks to Timothy Redaelli)
* BUGFIX: Fix missing tree view when userland threads are hidden * BUGFIX: Fix missing tree view when userland threads are hidden
(thanks to Josh Stone) (thanks to Josh Stone)
* BUGFIX: Fix for VPID on OpenVZ systems * BUGFIX: Fix for VPID on OpenVZ systems
......
if HAVE_PLPA
SUBDIRS = plpa-1.1 SUBDIRS = plpa-1.1
endif
bin_PROGRAMS = htop bin_PROGRAMS = htop
dist_man_MANS = htop.1 dist_man_MANS = htop.1
...@@ -35,7 +37,9 @@ SUFFIXES = .h ...@@ -35,7 +37,9 @@ SUFFIXES = .h
BUILT_SOURCES = $(myhtopheaders) BUILT_SOURCES = $(myhtopheaders)
htop_SOURCES = $(myhtopheaders) $(myhtopsources) config.h debug.h htop_SOURCES = $(myhtopheaders) $(myhtopsources) config.h debug.h
if HAVE_PLPA
htop_LDADD = $(top_builddir)/plpa-1.1/src/libplpa_included.la htop_LDADD = $(top_builddir)/plpa-1.1/src/libplpa_included.la
endif
profile: profile:
$(MAKE) all CFLAGS="-pg -O2" $(MAKE) all CFLAGS="-pg -O2"
......
...@@ -28,13 +28,16 @@ in the source distribution for its full text. ...@@ -28,13 +28,16 @@ in the source distribution for its full text.
#include <pwd.h> #include <pwd.h>
#include <sched.h> #include <sched.h>
#ifdef HAVE_PLPA
#include <plpa.h> #include <plpa.h>
#endif
// This works only with glibc 2.1+. On earlier versions // This works only with glibc 2.1+. On earlier versions
// the behavior is similar to have a hardcoded page size. // the behavior is similar to have a hardcoded page size.
#ifndef PAGE_SIZE #ifndef PAGE_SIZE
#define PAGE_SIZE ( sysconf(_SC_PAGESIZE) / 1024 ) #define PAGE_SIZE ( sysconf(_SC_PAGESIZE) )
#endif #endif
#define PAGE_SIZE_KB ( PAGE_SIZE / ONE_K )
#define PROCESS_COMM_LEN 300 #define PROCESS_COMM_LEN 300
...@@ -351,13 +354,13 @@ static void Process_writeField(Process* this, RichString* str, ProcessField fiel ...@@ -351,13 +354,13 @@ static void Process_writeField(Process* this, RichString* str, ProcessField fiel
: attr; : attr;
break; break;
} }
case M_DRS: Process_printLargeNumber(this, str, this->m_drs * PAGE_SIZE); return; case M_DRS: Process_printLargeNumber(this, str, this->m_drs * PAGE_SIZE_KB); return;
case M_DT: Process_printLargeNumber(this, str, this->m_dt * PAGE_SIZE); return; case M_DT: Process_printLargeNumber(this, str, this->m_dt * PAGE_SIZE_KB); return;
case M_LRS: Process_printLargeNumber(this, str, this->m_lrs * PAGE_SIZE); return; case M_LRS: Process_printLargeNumber(this, str, this->m_lrs * PAGE_SIZE_KB); return;
case M_TRS: Process_printLargeNumber(this, str, this->m_trs * PAGE_SIZE); return; case M_TRS: Process_printLargeNumber(this, str, this->m_trs * PAGE_SIZE_KB); return;
case M_SIZE: Process_printLargeNumber(this, str, this->m_size * PAGE_SIZE); return; case M_SIZE: Process_printLargeNumber(this, str, this->m_size * PAGE_SIZE_KB); return;
case M_RESIDENT: Process_printLargeNumber(this, str, this->m_resident * PAGE_SIZE); return; case M_RESIDENT: Process_printLargeNumber(this, str, this->m_resident * PAGE_SIZE_KB); return;
case M_SHARE: Process_printLargeNumber(this, str, this->m_share * PAGE_SIZE); return; case M_SHARE: Process_printLargeNumber(this, str, this->m_share * PAGE_SIZE_KB); return;
case ST_UID: snprintf(buffer, n, "%4d ", this->st_uid); break; case ST_UID: snprintf(buffer, n, "%4d ", this->st_uid); break;
case USER: { case USER: {
if (Process_getuid != this->st_uid) if (Process_getuid != this->st_uid)
...@@ -493,6 +496,7 @@ bool Process_setPriority(Process* this, int priority) { ...@@ -493,6 +496,7 @@ bool Process_setPriority(Process* this, int priority) {
return (err == 0); return (err == 0);
} }
#ifdef HAVE_PLPA
unsigned long Process_getAffinity(Process* this) { unsigned long Process_getAffinity(Process* this) {
unsigned long mask = 0; unsigned long mask = 0;
plpa_sched_getaffinity(this->pid, sizeof(unsigned long), (plpa_cpu_set_t*) &mask); plpa_sched_getaffinity(this->pid, sizeof(unsigned long), (plpa_cpu_set_t*) &mask);
...@@ -502,6 +506,7 @@ unsigned long Process_getAffinity(Process* this) { ...@@ -502,6 +506,7 @@ unsigned long Process_getAffinity(Process* this) {
bool Process_setAffinity(Process* this, unsigned long mask) { bool Process_setAffinity(Process* this, unsigned long mask) {
return (plpa_sched_setaffinity(this->pid, sizeof(unsigned long), (plpa_cpu_set_t*) &mask) == 0); return (plpa_sched_setaffinity(this->pid, sizeof(unsigned long), (plpa_cpu_set_t*) &mask) == 0);
} }
#endif
void Process_sendSignal(Process* this, int signal) { void Process_sendSignal(Process* this, int signal) {
kill(this->pid, signal); kill(this->pid, signal);
......
...@@ -31,13 +31,16 @@ in the source distribution for its full text. ...@@ -31,13 +31,16 @@ in the source distribution for its full text.
#include <pwd.h> #include <pwd.h>
#include <sched.h> #include <sched.h>
#ifdef HAVE_PLPA
#include <plpa.h> #include <plpa.h>
#endif
// This works only with glibc 2.1+. On earlier versions // This works only with glibc 2.1+. On earlier versions
// the behavior is similar to have a hardcoded page size. // the behavior is similar to have a hardcoded page size.
#ifndef PAGE_SIZE #ifndef PAGE_SIZE
#define PAGE_SIZE ( sysconf(_SC_PAGESIZE) / 1024 ) #define PAGE_SIZE ( sysconf(_SC_PAGESIZE) )
#endif #endif
#define PAGE_SIZE_KB ( PAGE_SIZE / ONE_K )
#define PROCESS_COMM_LEN 300 #define PROCESS_COMM_LEN 300
...@@ -172,9 +175,11 @@ void Process_toggleTag(Process* this); ...@@ -172,9 +175,11 @@ void Process_toggleTag(Process* this);
bool Process_setPriority(Process* this, int priority); bool Process_setPriority(Process* this, int priority);
#ifdef HAVE_PLPA
unsigned long Process_getAffinity(Process* this); unsigned long Process_getAffinity(Process* this);
bool Process_setAffinity(Process* this, unsigned long mask); bool Process_setAffinity(Process* this, unsigned long mask);
#endif
void Process_sendSignal(Process* this, int signal); void Process_sendSignal(Process* this, int signal);
......
...@@ -696,7 +696,7 @@ static bool ProcessList_processEntries(ProcessList* this, char* dirname, Process ...@@ -696,7 +696,7 @@ static bool ProcessList_processEntries(ProcessList* this, char* dirname, Process
period * 100.0; period * 100.0;
process->percent_cpu = MAX(MIN(percent_cpu, processors*100.0), 0.0); process->percent_cpu = MAX(MIN(percent_cpu, processors*100.0), 0.0);
process->percent_mem = (process->m_resident * PAGE_SIZE) / process->percent_mem = (process->m_resident * PAGE_SIZE_KB) /
(float)(this->totalMem) * (float)(this->totalMem) *
100.0; 100.0;
......
...@@ -97,8 +97,9 @@ AC_CHECK_FILE($PROCDIR/meminfo,,AC_MSG_ERROR(Cannot find /proc/meminfo. Make sur ...@@ -97,8 +97,9 @@ AC_CHECK_FILE($PROCDIR/meminfo,,AC_MSG_ERROR(Cannot find /proc/meminfo. Make sur
PLPA_INCLUDED(plpa-1.1) PLPA_INCLUDED(plpa-1.1)
PLPA_INIT(plpa_happy=yes, plpa_happy=no) PLPA_INIT(plpa_happy=yes, plpa_happy=no)
if test "x$plpa_happy" = xno; then AM_CONDITIONAL([HAVE_PLPA], [test "$plpa_happy" = "yes"])
AC_MSG_ERROR([Failed to initialize PLPA.]) if test "$plpa_happy" = "yes"; then
AC_DEFINE([HAVE_PLPA], [1], [Have plpa])
fi fi
AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([Makefile])
......
...@@ -112,9 +112,11 @@ static void showHelp(ProcessList* pl) { ...@@ -112,9 +112,11 @@ static void showHelp(ProcessList* pl) {
mvaddstr(15, 0, " F9 k: kill process/tagged processes P: sort by CPU%"); mvaddstr(15, 0, " F9 k: kill process/tagged processes P: sort by CPU%");
mvaddstr(16, 0, " + [ F7: lower priority (+ nice) M: sort by MEM%"); mvaddstr(16, 0, " + [ F7: lower priority (+ nice) M: sort by MEM%");
mvaddstr(17, 0, " - ] F8: higher priority (root only) T: sort by TIME"); mvaddstr(17, 0, " - ] F8: higher priority (root only) T: sort by TIME");
#ifdef HAVE_PLPA
if (pl->processorCount > 1) if (pl->processorCount > 1)
mvaddstr(18, 0, " a: set CPU affinity F4 I: invert sort order"); mvaddstr(18, 0, " a: set CPU affinity F4 I: invert sort order");
else else
#endif
mvaddstr(18, 0, " F4 I: invert sort order"); mvaddstr(18, 0, " F4 I: invert sort order");
mvaddstr(19, 0, " F2 S: setup F6 >: select sort column"); mvaddstr(19, 0, " F2 S: setup F6 >: select sort column");
mvaddstr(20, 0, " F1 h: show this help screen"); mvaddstr(20, 0, " F1 h: show this help screen");
...@@ -131,8 +133,10 @@ static void showHelp(ProcessList* pl) { ...@@ -131,8 +133,10 @@ static void showHelp(ProcessList* pl) {
mvaddstr(16, 0, " + [ F7"); mvaddstr(16,40, " M"); mvaddstr(16, 0, " + [ F7"); mvaddstr(16,40, " M");
mvaddstr(17, 0, " - ] F8"); mvaddstr(17,40, " T"); mvaddstr(17, 0, " - ] F8"); mvaddstr(17,40, " T");
mvaddstr(18,40, " F4 I"); mvaddstr(18,40, " F4 I");
#if HAVE_PLPA
if (pl->processorCount > 1) if (pl->processorCount > 1)
mvaddstr(18, 0, " a:"); mvaddstr(18, 0, " a:");
#endif
mvaddstr(19, 0, " F2 S"); mvaddstr(19,40, " F6 >"); mvaddstr(19, 0, " F2 S"); mvaddstr(19,40, " F6 >");
mvaddstr(20, 0, " F1 h"); mvaddstr(20, 0, " F1 h");
mvaddstr(21, 0, " F10 q"); mvaddstr(21,40, " s"); mvaddstr(21, 0, " F10 q"); mvaddstr(21,40, " s");
...@@ -630,6 +634,7 @@ int main(int argc, char** argv) { ...@@ -630,6 +634,7 @@ int main(int argc, char** argv) {
refreshTimeout = 0; refreshTimeout = 0;
break; break;
} }
#ifdef HAVE_PLPA
case 'a': case 'a':
{ {
if (pl->processorCount == 1) if (pl->processorCount == 1)
...@@ -665,6 +670,7 @@ int main(int argc, char** argv) { ...@@ -665,6 +670,7 @@ int main(int argc, char** argv) {
refreshTimeout = 0; refreshTimeout = 0;
break; break;
} }
#endif
case KEY_F(10): case KEY_F(10):
case 'q': case 'q':
quit = 1; quit = 1;
......
...@@ -122,7 +122,6 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ ...@@ -122,7 +122,6 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@ PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@ PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@ RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@ SET_MAKE = @SET_MAKE@
SHELL = @SHELL@ SHELL = @SHELL@
STRIP = @STRIP@ STRIP = @STRIP@
......
...@@ -157,7 +157,6 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ ...@@ -157,7 +157,6 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@ PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@ PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@ RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@ SET_MAKE = @SET_MAKE@
SHELL = @SHELL@ SHELL = @SHELL@
STRIP = @STRIP@ STRIP = @STRIP@
......
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