add NetBSD total memory information
Yorick Hardy
yh at metroweb.co.za
Thu Mar 27 13:21:01 CST 2003
The patch adds the sysctl calls for NetBSD to determine
the physical memory available.
Also combine the FreeBSD and NetBSD sysctl calls using the
function common to both platforms, it should be okay but
can a FreeBSD developer double-check this ?
--
Yorick Hardy
--- memory/global.c.orig Wed Mar 26 10:19:07 2003
+++ memory/global.c Wed Mar 26 10:22:37 2003
@@ -1573,9 +1573,10 @@
#ifdef linux
FILE *f;
#endif
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__NetBSD__)
int *tmp;
int size_sys;
+ int mib[2] = { CTL_HW };
#endif
if (time(NULL)==cache_lastchecked) {
memcpy(lpmem,&cached_memstatus,sizeof(MEMORYSTATUS));
@@ -1637,17 +1638,19 @@
/ (TotalPhysical / 100);
}
}
-#elif defined(__FreeBSD__)
- sysctlbyname("hw.physmem", NULL, &size_sys, NULL, 0);
+#elif defined(__FreeBSD__) || defined(__NetBSD__)
+ mib[1] = HW_PHYSMEM;
+ sysctl(mib, 2, NULL, &size_sys, NULL, 0);
tmp = malloc(size_sys * sizeof(int));
- sysctlbyname("hw.physmem", tmp, &size_sys, NULL, 0);
+ sysctl(mib, 2, tmp, &size_sys, NULL, 0);
if (tmp && *tmp)
{
lpmem->dwTotalPhys = *tmp;
free(tmp);
- sysctlbyname("hw.usermem", NULL, &size_sys, NULL, 0);
+ mib[1] = HW_USERMEM;
+ sysctl(mib, 2, NULL, &size_sys, NULL, 0);
tmp = malloc(size_sys * sizeof(int));
- sysctlbyname("hw.usermem", tmp, &size_sys, NULL, 0);
+ sysctl(mib, 2, tmp, &size_sys, NULL, 0);
if (tmp && *tmp)
{
lpmem->dwAvailPhys = *tmp;
More information about the wine-patches
mailing list