Xinqi Bao's Git
projects
/
slstatus.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
Add he4d to LICENSE
[slstatus.git]
/
components
/
ram.c
diff --git
a/components/ram.c
b/components/ram.c
index
5611022
..
1178837
100644
(file)
--- a/
components/ram.c
+++ b/
components/ram.c
@@
-54,11
+54,13
@@
NULL;
}
#elif defined(__OpenBSD__)
NULL;
}
#elif defined(__OpenBSD__)
- #include <sys/types.h>
- #include <sys/sysctl.h>
#include <stdlib.h>
#include <stdlib.h>
+ #include <sys/sysctl.h>
+ #include <sys/types.h>
#include <unistd.h>
#include <unistd.h>
+ #define LOG1024 10
+
inline int
load_uvmexp(struct uvmexp *uvmexp)
{
inline int
load_uvmexp(struct uvmexp *uvmexp)
{
@@
-79,8
+81,7
@@
if (load_uvmexp(&uvmexp)) {
free_pages = uvmexp.npages - uvmexp.active;
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);
}
return bprintf("%f", free);
}
@@
-108,8
+109,7
@@
float total;
if (load_uvmexp(&uvmexp)) {
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);
}
return bprintf("%f", total);
}