On Mon, Mar 29, 2021 at 01:50:54PM +0100, Stuart Henderson wrote: > On 2021/03/27 13:42, Stuart Henderson wrote: > > This updates htop to git head, support for displaying threads on OpenBSD > > was recently merged upstream. Usual rebasing needed for the NCPUONLINE > > patches, I have tidied them up a bit and opened a pull request upstream > > for those. Other patches seem to not be needed (and many of them no > > longer apply due to upstream work). > > > > OK? > > > > Ian, do you want to stay maintainer for this? (there have been a few > > maintainer timeout commits on recent updates to this port) > > as pointed out by cgzones on the upstream PR, the cpuIndex array is not > needed; now we are down to just 1 patch
I don't use htop, but as the release is approaching and it's fairly popular, I believe this should go in and be tested rather than potentially sitting in your tree and on this list for a week. ok tb > > Index: Makefile > =================================================================== > RCS file: /cvs/ports/sysutils/htop/Makefile,v > retrieving revision 1.25 > diff -u -p -r1.25 Makefile > --- Makefile 8 Dec 2020 16:23:17 -0000 1.25 > +++ Makefile 29 Mar 2021 12:50:14 -0000 > @@ -4,7 +4,9 @@ COMMENT = interactive process viewer > > GH_ACCOUNT = htop-dev > GH_PROJECT = htop > -GH_TAGNAME = 3.0.2 > +#GH_TAGNAME = 3.0.5 > +GH_COMMIT = 272e72680b84a52183d39a519d6704324063bae1 > +DISTNAME = htop-3.0.5pl20210325 > > CATEGORIES = sysutils > > @@ -12,7 +14,7 @@ HOMEPAGE = https://htop.dev > > MAINTAINER = Ian Sutton <[email protected]> > > -# GPLv2+ > +# GPLv2 only > PERMIT_PACKAGE = Yes > > WANTLIB = c curses kvm m > @@ -21,6 +23,8 @@ RUN_DEPENDS = devel/desktop-file-utils > > NO_TEST = Yes > > +DEBUG_PACKAGES = ${BUILD_PACKAEGS} > + > CONFIGURE_STYLE = autoreconf > AUTOCONF_VERSION = 2.69 > AUTOMAKE_VERSION = 1.16 > @@ -28,9 +32,7 @@ AUTORECONF = ./autogen.sh > CONFIGURE_ARGS += --disable-unicode \ > --disable-taskstats > > -# htop has some bugs which take hours or days to reach. > -# Keep the symbols to give a chance to the user to get an useful coredump. > -MAKE_FLAGS = AM_CPPFLAGS="-DDEBUG" > -DEBUG = -g > +post-install: > + rm -r ${PREFIX}/share/icons/ > > .include <bsd.port.mk> > Index: distinfo > =================================================================== > RCS file: /cvs/ports/sysutils/htop/distinfo,v > retrieving revision 1.6 > diff -u -p -r1.6 distinfo > --- distinfo 8 Dec 2020 16:23:17 -0000 1.6 > +++ distinfo 29 Mar 2021 12:50:14 -0000 > @@ -1,2 +1,2 @@ > -SHA256 (htop-3.0.2.tar.gz) = tHRKO+onnyo3Je2OXjX/2csQ1mZzvwfI/iH+s8RmEwU= > -SIZE (htop-3.0.2.tar.gz) = 176132 > +SHA256 (htop-3.0.5pl20210325-272e7268.tar.gz) = > vGQLe5GzuNBe8HVGjndJAvR5yrSCIA4gu24jaQgt7Rk= > +SIZE (htop-3.0.5pl20210325-272e7268.tar.gz) = 313192 > Index: patches/patch-CPUMeter_c > =================================================================== > RCS file: patches/patch-CPUMeter_c > diff -N patches/patch-CPUMeter_c > --- patches/patch-CPUMeter_c 8 Dec 2020 16:23:17 -0000 1.8 > +++ /dev/null 1 Jan 1970 00:00:00 -0000 > @@ -1,16 +0,0 @@ > -$OpenBSD: patch-CPUMeter_c,v 1.8 2020/12/08 16:23:17 sthen Exp $ > - > -Index: CPUMeter.c > ---- CPUMeter.c.orig > -+++ CPUMeter.c > -@@ -202,6 +202,10 @@ static void SingleColCPUsMeter_draw(Meter* this, int x > - int start, count; > - AllCPUsMeter_getRange(this, &start, &count); > - for (int i = 0; i < count; i++) { > -+ if(meters[i]->draw == 0x1) { > -+ AllCPUsMeter_init(meters[i]); > -+ meters[i]->draw = Meter_modes[meters[i]->mode]->draw; > -+ } > - meters[i]->draw(meters[i], x, y, w); > - y += meters[i]->h; > - } > Index: patches/patch-FunctionBar_c > =================================================================== > RCS file: patches/patch-FunctionBar_c > diff -N patches/patch-FunctionBar_c > --- patches/patch-FunctionBar_c 8 Dec 2020 16:23:17 -0000 1.4 > +++ /dev/null 1 Jan 1970 00:00:00 -0000 > @@ -1,23 +0,0 @@ > -$OpenBSD: patch-FunctionBar_c,v 1.4 2020/12/08 16:23:17 sthen Exp $ > - > -This function is called at the wrong time and will cause use-after-free's, > -so we leak for now. > - > -Index: FunctionBar.c > ---- FunctionBar.c.orig > -+++ FunctionBar.c > -@@ -59,14 +59,8 @@ FunctionBar* FunctionBar_new(const char* const* functi > - } > - > - void FunctionBar_delete(FunctionBar* this) { > -- for (int i = 0; i < 15 && this->functions[i]; i++) { > -- free(this->functions[i]); > -- } > - free(this->functions); > - if (!this->staticData) { > -- for (int i = 0; i < this->size; i++) { > -- free(this->keys[i]); > -- } > - free(this->keys); > - free(this->events); > - } > Index: patches/patch-Header_c > =================================================================== > RCS file: patches/patch-Header_c > diff -N patches/patch-Header_c > --- patches/patch-Header_c 8 Dec 2020 16:23:17 -0000 1.3 > +++ /dev/null 1 Jan 1970 00:00:00 -0000 > @@ -1,15 +0,0 @@ > -$OpenBSD: patch-Header_c,v 1.3 2020/12/08 16:23:17 sthen Exp $ > - > -Index: Header.c > ---- Header.c.orig > -+++ Header.c > -@@ -168,7 +168,8 @@ void Header_draw(const Header* this) { > - Header_forEachColumn(this, col) { > - Vector* meters = this->columns[col]; > - for (int y = (pad / 2), i = 0; i < Vector_size(meters); i++) { > -- Meter* meter = (Meter*) Vector_get(meters, i); > -+ Meter* meter = (Meter*) Vector_get(meters, i); > -+ if (meter == 0x1 || meter->draw == 0x1) continue; > - meter->draw(meter, x, y, width); > - y += meter->h; > - } > Index: patches/patch-Vector_c > =================================================================== > RCS file: patches/patch-Vector_c > diff -N patches/patch-Vector_c > --- patches/patch-Vector_c 8 Dec 2020 16:23:17 -0000 1.3 > +++ /dev/null 1 Jan 1970 00:00:00 -0000 > @@ -1,19 +0,0 @@ > -$OpenBSD: patch-Vector_c,v 1.3 2020/12/08 16:23:17 sthen Exp $ > - > -This function is called at the wrong time and will cause use-after-free's, > -so we leak for now. > - > -Index: Vector.c > ---- Vector.c.orig > -+++ Vector.c > -@@ -34,8 +34,8 @@ void Vector_delete(Vector* this) { > - if (this->array[i]) > - Object_delete(this->array[i]); > - } > -- free(this->array); > -- free(this); > -+ /* free(this->array); > -+ free(this); */ > - } > - > - #ifdef DEBUG > Index: patches/patch-openbsd_OpenBSDProcessList_c > =================================================================== > RCS file: > /cvs/ports/sysutils/htop/patches/patch-openbsd_OpenBSDProcessList_c,v > retrieving revision 1.4 > diff -u -p -r1.4 patch-openbsd_OpenBSDProcessList_c > --- patches/patch-openbsd_OpenBSDProcessList_c 8 Dec 2020 16:23:17 > -0000 1.4 > +++ patches/patch-openbsd_OpenBSDProcessList_c 29 Mar 2021 12:50:14 > -0000 > @@ -3,75 +3,57 @@ $OpenBSD: patch-openbsd_OpenBSDProcessLi > Don't include "offline" CPUs in the stats (i.e. CPUs which have been > disabled by sysctl hw.smt=0). > > +https://github.com/htop-dev/htop/pull/580 > + > Index: openbsd/OpenBSDProcessList.c > --- openbsd/OpenBSDProcessList.c.orig > +++ openbsd/OpenBSDProcessList.c > -@@ -30,24 +30,36 @@ in the source distribution for its full text. > - static long fscale; > +@@ -37,11 +37,15 @@ static int pageSize; > + static int pageSizeKB; > > ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* > pidMatchList, uid_t userId) { > -- int mib[] = { CTL_HW, HW_NCPU }; > -+ int nmib[] = { CTL_HW, HW_NCPU }; > -+ int mib[] = { CTL_HW, HW_NCPUONLINE }; > - int fmib[] = { CTL_KERN, KERN_FSCALE }; > -- int i, e; > +- const int mib[] = { CTL_HW, HW_NCPU }; > ++ const int nmib[] = { CTL_HW, HW_NCPU }; > ++ const int mib[] = { CTL_HW, HW_NCPUONLINE }; > + const int fmib[] = { CTL_KERN, KERN_FSCALE }; > + int ncmib[] = { CTL_KERN, KERN_CPUSTATS, 0 }; > -+ int i, e, ncpu, cpu_index_c; > - OpenBSDProcessList* opl; > - ProcessList* pl; > -- size_t size; > -+ size_t size, size_ncpu, size_cpustats; > + int r; > ++ unsigned int cpu_index_c = 0, ncpu; > + size_t size; > char errbuf[_POSIX2_LINE_MAX]; > + struct cpustats cpu_stats; > > - opl = xCalloc(1, sizeof(OpenBSDProcessList)); > - pl = (ProcessList*) opl; > - size = sizeof(pl->cpuCount); > -+ size_ncpu = sizeof(int); > -+ size_cpustats = sizeof(cpu_stats); > -+ cpu_index_c = 0; > - ProcessList_init(pl, Class(OpenBSDProcess), usersTable, pidMatchList, > userId); > - > - e = sysctl(mib, 2, &pl->cpuCount, &size, NULL, 0); > - if (e == -1 || pl->cpuCount < 1) { > - pl->cpuCount = 1; > + OpenBSDProcessList* opl = xCalloc(1, sizeof(OpenBSDProcessList)); > + ProcessList* pl = (ProcessList*) opl; > +@@ -54,6 +58,12 @@ ProcessList* ProcessList_new(UsersTable* usersTable, H > } > -+ e = sysctl(nmib, 2, &ncpu, &size_ncpu, NULL, 0); > -+ if (e == -1) { > -+ ncpu = pl->cpuCount; > -+ } > -+ > opl->cpus = xCalloc(pl->cpuCount + 1, sizeof(CPUData)); > -+ opl->cpuIndex = xRealloc(opl->cpuIndex, pl->cpuCount * sizeof(int)); > > ++ size = sizeof(int); > ++ r = sysctl(nmib, 2, &ncpu, &size, NULL, 0); > ++ if (r < 0) { > ++ ncpu = pl->cpuCount; > ++ } > ++ > size = sizeof(fscale); > if (sysctl(fmib, 2, &fscale, &size, NULL, 0) < 0) { > -@@ -65,6 +77,19 @@ ProcessList* ProcessList_new(UsersTable* usersTable, H > - errx(1, "kvm_open: %s", errbuf); > + CRT_fatalError("fscale sysctl call failed"); > +@@ -75,6 +85,18 @@ ProcessList* ProcessList_new(UsersTable* usersTable, H > } > > -+ for (i = 0; i < ncpu; i++) { > + opl->cpuSpeed = -1; > ++ > ++ size = sizeof(cpu_stats); > ++ for (unsigned int i = 0; i < ncpu; i++) { > + ncmib[2] = i; > -+ sysctl(ncmib, 3, &cpu_stats, &size_cpustats, NULL, 0); > ++ sysctl(ncmib, 3, &cpu_stats, &size, NULL, 0); > + if (cpu_stats.cs_flags & CPUSTATS_ONLINE) { > -+ opl->cpuIndex[cpu_index_c] = i; > -+ cpu_index_c++; > -+ } > -+ > -+ if (cpu_index_c == pl->cpuCount) { > -+ break; > ++ cpu_index_c++; > + } > -+ } > + > ++ if (cpu_index_c == pl->cpuCount) > ++ break; > ++ } > + > return pl; > } > - > -@@ -323,7 +348,7 @@ static void OpenBSDProcessList_scanCPUTime(OpenBSDProc > - u_int64_t avg[CPUSTATES] = {0}; > - > - for (int i = 0; i < this->super.cpuCount; i++) { > -- getKernelCPUTimes(i, kernelTimes); > -+ getKernelCPUTimes(this->cpuIndex[i], kernelTimes); > - CPUData* cpu = this->cpus + i + 1; > - kernelCPUTimesToHtop(kernelTimes, cpu); > - > Index: patches/patch-openbsd_OpenBSDProcessList_h > =================================================================== > RCS file: patches/patch-openbsd_OpenBSDProcessList_h > diff -N patches/patch-openbsd_OpenBSDProcessList_h > --- patches/patch-openbsd_OpenBSDProcessList_h 8 Dec 2020 16:23:17 > -0000 1.3 > +++ /dev/null 1 Jan 1970 00:00:00 -0000 > @@ -1,16 +0,0 @@ > -$OpenBSD: patch-openbsd_OpenBSDProcessList_h,v 1.3 2020/12/08 16:23:17 sthen > Exp $ > - > -Don't include "offline" CPUs in the stats (i.e. CPUs which have been > -disabled by sysctl hw.smt=0). > - > -Index: openbsd/OpenBSDProcessList.h > ---- openbsd/OpenBSDProcessList.h.orig > -+++ openbsd/OpenBSDProcessList.h > -@@ -36,6 +36,7 @@ typedef struct OpenBSDProcessList_ { > - > - CPUData* cpus; > - > -+ int *cpuIndex; > - } OpenBSDProcessList; > - > - > Index: patches/patch-openbsd_OpenBSDProcess_c > =================================================================== > RCS file: patches/patch-openbsd_OpenBSDProcess_c > diff -N patches/patch-openbsd_OpenBSDProcess_c > --- patches/patch-openbsd_OpenBSDProcess_c 8 Dec 2020 16:23:17 -0000 > 1.3 > +++ /dev/null 1 Jan 1970 00:00:00 -0000 > @@ -1,18 +0,0 @@ > -$OpenBSD: patch-openbsd_OpenBSDProcess_c,v 1.3 2020/12/08 16:23:17 sthen Exp > $ > - > -This function is called at the wrong time and will cause use-after-free's, > -so we leak for now. > - > -Index: openbsd/OpenBSDProcess.c > ---- openbsd/OpenBSDProcess.c.orig > -+++ openbsd/OpenBSDProcess.c > -@@ -173,9 +173,7 @@ OpenBSDProcess* OpenBSDProcess_new(Settings* settings) > - } > - > - void Process_delete(Object* cast) { > -- OpenBSDProcess* this = (OpenBSDProcess*) cast; > - Process_done((Process*)cast); > -- free(this); > - } > - > - void OpenBSDProcess_writeField(Process* this, RichString* str, ProcessField > field) { > Index: patches/patch-openbsd_Platform_c > =================================================================== > RCS file: patches/patch-openbsd_Platform_c > diff -N patches/patch-openbsd_Platform_c > --- patches/patch-openbsd_Platform_c 8 Dec 2020 16:23:17 -0000 1.9 > +++ /dev/null 1 Jan 1970 00:00:00 -0000 > @@ -1,14 +0,0 @@ > -$OpenBSD: patch-openbsd_Platform_c,v 1.9 2020/12/08 16:23:17 sthen Exp $ > - > -Index: openbsd/Platform.c > ---- openbsd/Platform.c.orig > -+++ openbsd/Platform.c > -@@ -227,7 +227,7 @@ void Platform_setSwapValues(Meter* this) { > - this->total = pl->totalSwap = total; > - this->values[0] = pl->usedSwap = used; > - > -- free(swdev); > -+ //free(swdev); > - } > - > - void Platform_setTasksValues(Meter* this) { >
