Use longs vs. ints in calculating the amount of swap. This fixed getting

negative swap values on an Alpha with 2GB swap.  I should probably use
`long long' for large swap x86 machines.  (anybody want to help test?)
This commit is contained in:
David E. O'Brien 2001-08-21 18:33:51 +00:00
parent db9c952504
commit c9e00131ca
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=46605
5 changed files with 63 additions and 2 deletions

View file

@ -1,5 +1,5 @@
--- bsd/kernel.cc.orig Mon Jul 5 21:09:30 1999 --- bsd/kernel.cc.orig Mon Jul 5 21:09:30 1999
+++ bsd/kernel.cc Sat Jun 10 14:25:05 2000 +++ bsd/kernel.cc Tue Aug 21 10:49:26 2001
@@ -284,7 +284,12 @@ @@ -284,7 +284,12 @@
while (nlp && nlp->n_name) { while (nlp && nlp->n_name) {
if ((nlp->n_type == 0) || (nlp->n_value == 0)) if ((nlp->n_type == 0) || (nlp->n_value == 0))
@ -13,6 +13,15 @@
nlp++; nlp++;
} }
#ifdef HAVE_DEVSTAT #ifdef HAVE_DEVSTAT
@@ -457,7 +462,7 @@
//
void
-BSDGetSwapCtlInfo(int *totalp, int *freep) {
+BSDGetSwapCtlInfo(long *totalp, long *freep) {
int totalinuse, totalsize;
int rnswap, nswap = swapctl(SWAP_NSWAP, 0, 0);
struct swapent *swapiter;
@@ -792,25 +797,25 @@ @@ -792,25 +797,25 @@
OpenKDIfNeeded(); OpenKDIfNeeded();
nintr = (nlst[EINTRCNT_SYM_INDEX].n_value - nintr = (nlst[EINTRCNT_SYM_INDEX].n_value -

View file

@ -1,5 +1,14 @@
--- bsd/kernel.h.orig Fri May 29 14:21:36 1998 --- bsd/kernel.h.orig Fri May 29 14:21:36 1998
+++ bsd/kernel.h Sat Jun 10 14:18:22 2000 +++ bsd/kernel.h Tue Aug 21 10:50:17 2001
@@ -52,7 +52,7 @@
#ifdef HAVE_SWAPCTL
void
-BSDGetSwapCtlInfo(int* total, int* free);
+BSDGetSwapCtlInfo(long* total, long* free);
#endif
int
@@ -67,7 +67,11 @@ @@ -67,7 +67,11 @@
#endif #endif

View file

@ -0,0 +1,24 @@
--- bsd/swapinternal.cc.orig Tue Nov 16 23:16:20 1999
+++ bsd/swapinternal.cc Tue Aug 21 11:27:26 2001
@@ -437,16 +437,17 @@
#endif /* XOSVIEW_FREEBSD */
void
-BSDGetSwapInfo(int* total, int* free)
+BSDGetSwapInfo(long* total, long* free)
{
- int i, avail, npfree, used=0, xsize, xfree;
+ int i, npfree, xsize, xfree;
+ long avail, used=0;
fetchswap();
#ifdef USE_KVM_GETSWAPINFO
avail = used = 0;
if (kvnsw == 0) {
- avail += pagesize * kvmsw[0].ksw_total;
- used += pagesize * kvmsw[0].ksw_used;
+ avail += pagesize * (long)kvmsw[0].ksw_total;
+ used += pagesize * (long)kvmsw[0].ksw_used;
}
*total = avail;
*free = avail - used;

View file

@ -0,0 +1,12 @@
--- bsd/swapinternal.h.orig Wed Feb 11 21:04:07 1998
+++ bsd/swapinternal.h Tue Aug 21 10:51:00 2001
@@ -12,7 +12,7 @@
BSDInitSwapInfo();
void
-BSDGetSwapInfo(int* total, int* free);
+BSDGetSwapInfo(long* total, long* free);
void
-BSDGetSwapCtlInfo(int* total, int* free);
+BSDGetSwapCtlInfo(long* total, long* free);

View file

@ -0,0 +1,7 @@
--- bsd/swapmeter.cc.orig Tue Aug 21 10:52:35 2001
+++ bsd/swapmeter.cc Tue Aug 21 10:53:02 2001
@@ -76,3 +76,3 @@
void SwapMeter::getswapinfo( void ){
- int total_int, free_int;
+ long total_int, free_int;