all repos — slstatus @ 82eb6e3832dea63be4c22ac4415c3190add43f0b

my build of slstatus (tools.suckless.org/slstatus/)

consistent calculation of ram_* on openbsd
Tobias Tschinkowitz he4d@posteo.de
Wed, 16 May 2018 09:57:38 +0200
commit

82eb6e3832dea63be4c22ac4415c3190add43f0b

parent

ca02afb1d9c0f935f15b627477031f00e120c7cb

1 files changed, 4 insertions(+), 4 deletions(-)

jump to
M components/ram.ccomponents/ram.c

@@ -60,6 +60,7 @@ #include <sys/types.h>

#include <unistd.h> #define LOG1024 10 + #define pagetok(size, pageshift) ((size) << (pageshift - LOG1024)) inline int load_uvmexp(struct uvmexp *uvmexp)

@@ -81,7 +82,7 @@ int free_pages;

if (load_uvmexp(&uvmexp)) { free_pages = uvmexp.npages - uvmexp.active; - free = (float)(free_pages << (uvmexp.pageshift - LOG1024)) / 1024 / 1024; + free = (float)(pagetok(free_pages, uvmexp.pageshift)) / 1024 / 1024; return bprintf("%f", free); }

@@ -109,7 +110,7 @@ struct uvmexp uvmexp;

float total; if (load_uvmexp(&uvmexp)) { - total = (float)(uvmexp.npages << (uvmexp.pageshift - LOG1024)) / 1024 / 1024; + total = (float)(pagetok(uvmexp.npages, uvmexp.pageshift)) / 1024 / 1024; return bprintf("%f", total); }

@@ -123,8 +124,7 @@ struct uvmexp uvmexp;

float used; if (load_uvmexp(&uvmexp)) { - used = (double) (uvmexp.active * uvmexp.pagesize) / - 1024 / 1024 / 1024; + used = (float)(pagetok(uvmexp.active, uvmexp.pageshift)) / 1024 / 1024; return bprintf("%f", used); }