[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
old patch from mandrake for capping of memory with physmem calls
From: |
Mike Frysinger |
Subject: |
old patch from mandrake for capping of memory with physmem calls |
Date: |
Sun, 20 Aug 2006 06:26:49 -0400 |
User-agent: |
KMail/1.9.3 |
find attached a pretty old patch from Mandrake that they are still using ...
what do you guys think ? good idea/bad idea ?
-mike
pgp20V_LmGEA3.pgp
Description: PGP signature
--- textutils-2.0.17/lib/physmem.c.cap Sun Apr 8 13:31:12 2001
+++ textutils-2.0.17/lib/physmem.c Sun Apr 8 13:41:37 2001
@@ -31,6 +31,14 @@
# include <sys/pstat.h>
#endif
+/* Cap physical memory to something sane */
+static double
+physmem_cap (double mem)
+{
+ double max = 1L << (sizeof(void *)*8 - 4);
+ return mem > max ? max : mem;
+}
+
/* Return the total amount of physical memory. */
double
physmem_total (void)
@@ -52,7 +60,7 @@
double pages = pss.physical_memory;
double pagesize = pss.page_size;
if (0 <= pages && 0 <= pagesize)
- return pages * pagesize;
+ return physmem_cap(pages * pagesize);
}
}
#endif
@@ -84,7 +92,7 @@
double pages = psd.psd_free;
double pagesize = pss.page_size;
if (0 <= pages && 0 <= pagesize)
- return pages * pagesize;
+ return physmem_cap(pages * pagesize);
}
}
#endif
- old patch from mandrake for capping of memory with physmem calls,
Mike Frysinger <=