Support for getting memory size on FreeBSD.
This commit is contained in:
parent
0bd249dd6b
commit
f41ecf3782
|
@ -28,6 +28,9 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#ifdef HAVE_SYS_SYSCTL_H
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "wine/winbase16.h"
|
#include "wine/winbase16.h"
|
||||||
#include "wine/exception.h"
|
#include "wine/exception.h"
|
||||||
|
@ -1524,13 +1527,22 @@ VOID WINAPI GlobalMemoryStatus(
|
||||||
#ifdef linux
|
#ifdef linux
|
||||||
FILE *f;
|
FILE *f;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
int *tmp;
|
||||||
|
int size_sys;
|
||||||
|
#endif
|
||||||
if (time(NULL)==cache_lastchecked) {
|
if (time(NULL)==cache_lastchecked) {
|
||||||
memcpy(lpmem,&cached_memstatus,sizeof(MEMORYSTATUS));
|
memcpy(lpmem,&cached_memstatus,sizeof(MEMORYSTATUS));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cache_lastchecked = time(NULL);
|
cache_lastchecked = time(NULL);
|
||||||
|
|
||||||
|
lpmem->dwMemoryLoad = 0;
|
||||||
|
lpmem->dwTotalPhys = 16*1024*1024;
|
||||||
|
lpmem->dwAvailPhys = 16*1024*1024;
|
||||||
|
lpmem->dwTotalPageFile = 16*1024*1024;
|
||||||
|
lpmem->dwAvailPageFile = 16*1024*1024;
|
||||||
|
|
||||||
#ifdef linux
|
#ifdef linux
|
||||||
f = fopen( "/proc/meminfo", "r" );
|
f = fopen( "/proc/meminfo", "r" );
|
||||||
if (f)
|
if (f)
|
||||||
|
@ -1578,16 +1590,36 @@ VOID WINAPI GlobalMemoryStatus(
|
||||||
lpmem->dwMemoryLoad = (TotalPhysical-AvailPhysical)
|
lpmem->dwMemoryLoad = (TotalPhysical-AvailPhysical)
|
||||||
/ (TotalPhysical / 100);
|
/ (TotalPhysical / 100);
|
||||||
}
|
}
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
/* FIXME: should do something for other systems */
|
|
||||||
lpmem->dwMemoryLoad = 0;
|
|
||||||
lpmem->dwTotalPhys = 16*1024*1024;
|
|
||||||
lpmem->dwAvailPhys = 16*1024*1024;
|
|
||||||
lpmem->dwTotalPageFile = 16*1024*1024;
|
|
||||||
lpmem->dwAvailPageFile = 16*1024*1024;
|
|
||||||
}
|
}
|
||||||
|
#elif defined(__FreeBSD__)
|
||||||
|
sysctlbyname("hw.physmem", NULL, &size_sys, NULL, 0);
|
||||||
|
tmp = malloc(size_sys * sizeof(int));
|
||||||
|
sysctlbyname("hw.physmem", tmp, &size_sys, NULL, 0);
|
||||||
|
if (tmp && *tmp)
|
||||||
|
{
|
||||||
|
lpmem->dwTotalPhys = *tmp;
|
||||||
|
free(tmp);
|
||||||
|
sysctlbyname("hw.usermem", NULL, &size_sys, NULL, 0);
|
||||||
|
tmp = malloc(size_sys * sizeof(int));
|
||||||
|
sysctlbyname("hw.usermem", tmp, &size_sys, NULL, 0);
|
||||||
|
if (tmp && *tmp)
|
||||||
|
{
|
||||||
|
lpmem->dwAvailPhys = *tmp;
|
||||||
|
lpmem->dwTotalPageFile = *tmp;
|
||||||
|
lpmem->dwAvailPageFile = *tmp;
|
||||||
|
lpmem->dwMemoryLoad = lpmem->dwTotalPhys - lpmem->dwAvailPhys;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
lpmem->dwAvailPhys = lpmem->dwTotalPhys;
|
||||||
|
lpmem->dwTotalPageFile = lpmem->dwTotalPhys;
|
||||||
|
lpmem->dwAvailPageFile = lpmem->dwTotalPhys;
|
||||||
|
lpmem->dwMemoryLoad = 0;
|
||||||
|
}
|
||||||
|
free(tmp);
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
/* FIXME: should do something for other systems */
|
||||||
GetSystemInfo(&si);
|
GetSystemInfo(&si);
|
||||||
lpmem->dwTotalVirtual = si.lpMaximumApplicationAddress-si.lpMinimumApplicationAddress;
|
lpmem->dwTotalVirtual = si.lpMaximumApplicationAddress-si.lpMinimumApplicationAddress;
|
||||||
/* FIXME: we should track down all the already allocated VM pages and substract them, for now arbitrarily remove 64KB so that it matches NT */
|
/* FIXME: we should track down all the already allocated VM pages and substract them, for now arbitrarily remove 64KB so that it matches NT */
|
||||||
|
|
Loading…
Reference in New Issue