[hackers] [slstatus] updated ram_total and ram_free (obsd) || Tobias Tschinkowitz

From: <git_AT_suckless.org>
Date: Wed, 16 May 2018 08:14:40 +0200 (CEST)

commit 0f9a1a836720c028d89891b85ec8b1dbbd12c485
Author: Tobias Tschinkowitz <he4d_AT_posteo.de>
AuthorDate: Wed May 16 00:45:41 2018 +0200
Commit: Aaron Marcher <me_AT_drkhsh.at>
CommitDate: Wed May 16 08:08:48 2018 +0200

    updated ram_total and ram_free (obsd)

diff --git a/components/ram.c b/components/ram.c
index 62e9807..1178837 100644
--- a/components/ram.c
+++ b/components/ram.c
_AT_@ -59,6 +59,8 @@
         #include <sys/types.h>
         #include <unistd.h>
 
+ #define LOG1024 10
+
         inline int
         load_uvmexp(struct uvmexp *uvmexp)
         {
_AT_@ -79,8 +81,7 @@
 
                 if (load_uvmexp(&uvmexp)) {
                         free_pages = uvmexp.npages - uvmexp.active;
- free = (double) (free_pages * uvmexp.pagesize) / 1024 /
- 1024 / 1024;
+ free = (float)(free_pages << (uvmexp.pageshift - LOG1024)) / 1024 / 1024;
                         return bprintf("%f", free);
                 }
 
_AT_@ -108,8 +109,7 @@
                 float total;
 
                 if (load_uvmexp(&uvmexp)) {
- total = (double) (uvmexp.npages * uvmexp.pagesize) /
- 1024 / 1024 / 1024;
+ total = (float)(uvmexp.npages << (uvmexp.pageshift - LOG1024)) / 1024 / 1024;
                         return bprintf("%f", total);
                 }
 
Received on Wed May 16 2018 - 08:14:40 CEST

This archive was generated by hypermail 2.3.0 : Wed May 16 2018 - 08:24:25 CEST