wine/dlls/kernel heap.c
Alexandre Julliard
julliard at wine.codeweavers.com
Tue Nov 8 10:10:02 CST 2005
ChangeSet ID: 21170
CVSROOT: /opt/cvs-commit
Module name: wine
Changes by: julliard at winehq.org 2005/11/08 10:10:02
Modified files:
dlls/kernel : heap.c
Log message:
Robert Lunnon <bobl at optushome.com.au>
Implement GlobalMemoryStatusEx for Solaris.
Patch: http://cvs.winehq.org/patch.py?id=21170
Old revision New revision Changes Path
1.20 1.21 +40 -3 wine/dlls/kernel/heap.c
Index: wine/dlls/kernel/heap.c
diff -u -p wine/dlls/kernel/heap.c:1.20 wine/dlls/kernel/heap.c:1.21
--- wine/dlls/kernel/heap.c:1.20 8 Nov 2005 16:10: 2 -0000
+++ wine/dlls/kernel/heap.c 8 Nov 2005 16:10: 2 -0000
@@ -40,6 +40,16 @@
# include <unistd.h>
#endif
+#ifdef sun
+/* FIXME: Unfortunately swapctl can't be used with largefile.... */
+# undef _FILE_OFFSET_BITS
+# define _FILE_OFFSET_BITS 32
+# include <sys/resource.h>
+# include <sys/stat.h>
+# include <sys/swap.h>
+#endif
+
+
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
@@ -1132,6 +1142,12 @@ BOOL WINAPI GlobalMemoryStatusEx( LPMEMO
int size_sys;
int mib[2] = { CTL_HW };
#endif
+#ifdef sun
+ long pagesize,maxpages,freepages,swapspace,swapfree;
+ struct anoninfo swapinf;
+ int rval;
+#endif
+
if (time(NULL)==cache_lastchecked) {
memcpy(lpmemex,&cached_memstatus,sizeof(*lpmemex));
return TRUE;
@@ -1200,9 +1216,9 @@ BOOL WINAPI GlobalMemoryStatusEx( LPMEMO
if (tmp && *tmp)
{
lpmemex->ullTotalPhys = *tmp;
- free(tmp);
- mib[1] = HW_USERMEM;
- sysctl(mib, 2, NULL, &size_sys, NULL, 0);
+ free(tmp);
+ mib[1] = HW_USERMEM;
+ sysctl(mib, 2, NULL, &size_sys, NULL, 0);
tmp = malloc(size_sys * sizeof(int));
sysctl(mib, 2, tmp, &size_sys, NULL, 0);
if (tmp && *tmp)
@@ -1221,6 +1237,27 @@ BOOL WINAPI GlobalMemoryStatusEx( LPMEMO
free(tmp);
}
+#elif defined ( sun )
+ pagesize=sysconf(_SC_PAGESIZE);
+ maxpages=sysconf(_SC_PHYS_PAGES);
+ freepages=sysconf(_SC_AVPHYS_PAGES);
+ rval=swapctl(SC_AINFO, &swapinf);
+ if(rval >-1)
+ {
+ swapspace=swapinf.ani_max*pagesize;
+ swapfree=swapinf.ani_free*pagesize;
+ }else
+ {
+
+ WARN("Swap size cannot be determined , assuming equal to physical memory\n");
+ swapspace=maxpages*pagesize;
+ swapfree=maxpages*pagesize;
+ }
+ lpmemex->ullTotalPhys=pagesize*maxpages;
+ lpmemex->ullAvailPhys = pagesize*freepages;
+ lpmemex->ullTotalPageFile = swapspace;
+ lpmemex->ullAvailPageFile = swapfree;
+ lpmemex->dwMemoryLoad = lpmemex->ullTotalPhys - lpmemex->ullAvailPhys;
#endif
/* Project2k refuses to start if it sees less than 1Mb of free swap */
More information about the wine-cvs
mailing list