[PATCH v3 2/2] ntdll: Implement ProcessVmCounters for Linux.
Alex Henrie
alexhenrie24 at gmail.com
Mon Mar 20 23:55:37 CDT 2017
For https://bugs.winehq.org/show_bug.cgi?id=5657
The implementation is based on similar code in dlls/kernel32/heap.c for
GlobalMemoryStatusEx.
v3: Removed todo_wine from the test
Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
---
dlls/ntdll/process.c | 28 ++++++++++++++++++++++++++++
dlls/ntdll/tests/info.c | 5 +----
2 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/dlls/ntdll/process.c b/dlls/ntdll/process.c
index 8689d9b645..952225688c 100644
--- a/dlls/ntdll/process.c
+++ b/dlls/ntdll/process.c
@@ -131,6 +131,34 @@ static void fill_VM_COUNTERS(VM_COUNTERS* pvmi)
#endif
}
+#elif defined(linux)
+
+static void fill_VM_COUNTERS(VM_COUNTERS* pvmi)
+{
+ FILE *f;
+ char line[256];
+ unsigned long value;
+
+ f = fopen("/proc/self/status", "r");
+ if (!f) return;
+
+ while (fgets(line, sizeof(line), f))
+ {
+ if (sscanf(line, "VmPeak: %lu", &value))
+ pvmi->PeakVirtualSize = (ULONG64)value * 1024;
+ else if (sscanf(line, "VmSize: %lu", &value))
+ pvmi->VirtualSize = (ULONG64)value * 1024;
+ else if (sscanf(line, "VmHWM: %lu", &value))
+ pvmi->PeakWorkingSetSize = (ULONG64)value * 1024;
+ else if (sscanf(line, "VmRSS: %lu", &value))
+ pvmi->WorkingSetSize = (ULONG64)value * 1024;
+ else if (sscanf(line, "VmSwap: %lu", &value))
+ pvmi->PeakPagefileUsage = pvmi->PagefileUsage = (ULONG64)value * 1024;
+ }
+
+ fclose(f);
+}
+
#else
static void fill_VM_COUNTERS(VM_COUNTERS* pvmi)
diff --git a/dlls/ntdll/tests/info.c b/dlls/ntdll/tests/info.c
index 448bc64c28..35e25afd0e 100644
--- a/dlls/ntdll/tests/info.c
+++ b/dlls/ntdll/tests/info.c
@@ -1078,10 +1078,7 @@ static void test_query_process_vm(void)
/* Check if we have some return values */
trace("WorkingSetSize : %ld\n", pvi.WorkingSetSize);
- todo_wine
- {
- ok( pvi.WorkingSetSize > 0, "Expected a WorkingSetSize > 0\n");
- }
+ ok( pvi.WorkingSetSize > 0, "Expected a WorkingSetSize > 0\n");
}
static void test_query_process_io(void)
--
2.12.0
More information about the wine-patches
mailing list