[gnome-system-monitor] Remove code specific to linux to compute the writable memory. Use instead libgtop flags.



commit 74cabb153e1f72447d57a037ce207de19269b029
Author: Benoit Dejean <bdejean gmail com>
Date:   Sat Feb 28 06:27:37 2015 +0100

    Remove code specific to linux to compute the writable memory. Use instead libgtop flags.
    
    Signed-off-by: Robert Roth <robert roth off gmail com>

 src/proctable.cpp |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/src/proctable.cpp b/src/proctable.cpp
index 0549ef2..cd848f9 100644
--- a/src/proctable.cpp
+++ b/src/proctable.cpp
@@ -681,16 +681,20 @@ get_process_memory_writable (ProcInfo *info)
 
     maps = glibtop_get_proc_map(&buf, info->pid);
 
+    const bool use_private_dirty = buf.flags & (1 << GLIBTOP_MAP_ENTRY_PRIVATE_DIRTY);
+
     gulong memwritable = 0;
     const unsigned number = buf.number;
 
     for (unsigned i = 0; i < number; ++i) {
-#ifdef __linux__
-        memwritable += maps[i].private_dirty;
-#else
-        if (maps[i].perm & GLIBTOP_MAP_PERM_WRITE)
+        if (use_private_dirty) {
+            // clang++ 3.4 is not smart enough to move this invariant out of the loop
+            // but who cares ?
+            memwritable += maps[i].private_dirty;
+        }
+        else if (maps[i].perm & GLIBTOP_MAP_PERM_WRITE) {
             memwritable += maps[i].size;
-#endif
+        }
     }
 
     info->memwritable = memwritable;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]