Commit a0879217 authored by Yorick Hardy's avatar Yorick Hardy Committed by Alexandre Julliard

Added the sysctl calls for NetBSD to determine the physical memory

available.
parent 401a9e09
...@@ -1573,9 +1573,10 @@ VOID WINAPI GlobalMemoryStatus( ...@@ -1573,9 +1573,10 @@ VOID WINAPI GlobalMemoryStatus(
#ifdef linux #ifdef linux
FILE *f; FILE *f;
#endif #endif
#ifdef __FreeBSD__ #if defined(__FreeBSD__) || defined(__NetBSD__)
int *tmp; int *tmp;
int size_sys; int size_sys;
int mib[2] = { CTL_HW };
#endif #endif
if (time(NULL)==cache_lastchecked) { if (time(NULL)==cache_lastchecked) {
memcpy(lpmem,&cached_memstatus,sizeof(MEMORYSTATUS)); memcpy(lpmem,&cached_memstatus,sizeof(MEMORYSTATUS));
...@@ -1637,17 +1638,19 @@ VOID WINAPI GlobalMemoryStatus( ...@@ -1637,17 +1638,19 @@ VOID WINAPI GlobalMemoryStatus(
/ (TotalPhysical / 100); / (TotalPhysical / 100);
} }
} }
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__) || defined(__NetBSD__)
sysctlbyname("hw.physmem", NULL, &size_sys, NULL, 0); mib[1] = HW_PHYSMEM;
sysctl(mib, 2, NULL, &size_sys, NULL, 0);
tmp = malloc(size_sys * sizeof(int)); 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) if (tmp && *tmp)
{ {
lpmem->dwTotalPhys = *tmp; lpmem->dwTotalPhys = *tmp;
free(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)); 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) if (tmp && *tmp)
{ {
lpmem->dwAvailPhys = *tmp; lpmem->dwAvailPhys = *tmp;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment