]> granicus.if.org Git - procps-ng/commitdiff
library: remove the ull_int result type, <MEMINFO> api
authorJim Warner <james.warner@comcast.net>
Thu, 12 May 2016 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@dropbear.xyz>
Thu, 12 May 2016 11:15:01 +0000 (21:15 +1000)
Because of the vast quantities of virtual memory which
may be allocated, it initially seemed like a good idea
to provide for a widest possible range through the use
of a 'ull_int' result type. However, on second thought
the implementation was a bit flawed for these reasons:

. that underlying meminfo_data variable 'VmallocTotal'
is 'unsigned long' not a required 'unsigned long long'

. there wasn't a convenient way to value it since each
variable was set with a strtoul() call, not strtoull()

So this patch will standardize on the 'ul_int' results
type (and reduce the associated delta to 's_int' too).
For now, we'll rely on protections under a 64-bit arch
where a 'ull_int' & 'ul_int' yield identical capacity.

Signed-off-by: Jim Warner <james.warner@comcast.net>
proc/meminfo.c
proc/meminfo.h

index ba6cad51d44467931f91661f627d3c04e35ae76c..36a48a6434c4dc5b6e35aacca0e39a5764d39a3a 100644 (file)
@@ -164,7 +164,7 @@ MEM_set(MEM_TOTAL,              ul_int,  MemTotal)
 MEM_set(MEM_UNEVICTABLE,        ul_int,  Unevictable)
 MEM_set(MEM_USED,               ul_int,  derived_mem_used)
 MEM_set(MEM_VM_ALLOC_CHUNK,     ul_int,  VmallocChunk)
-MEM_set(MEM_VM_ALLOC_TOTAL,    ull_int,  VmallocTotal)
+MEM_set(MEM_VM_ALLOC_TOTAL,     ul_int,  VmallocTotal)
 MEM_set(MEM_VM_ALLOC_USED,      ul_int,  VmallocUsed)
 MEM_set(MEM_WRITEBACK,          ul_int,  Writeback)
 MEM_set(MEM_WRITEBACK_TMP,      ul_int,  WritebackTmp)
@@ -204,7 +204,7 @@ HST_set(DELTA_TOTAL,             s_int,  MemTotal)
 HST_set(DELTA_UNEVICTABLE,       s_int,  Unevictable)
 HST_set(DELTA_USED,              s_int,  derived_mem_used)
 HST_set(DELTA_VM_ALLOC_CHUNK,    s_int,  VmallocChunk)
-HST_set(DELTA_VM_ALLOC_TOTAL,   sl_int,  VmallocTotal)
+HST_set(DELTA_VM_ALLOC_TOTAL,    s_int,  VmallocTotal)
 HST_set(DELTA_VM_ALLOC_USED,     s_int,  VmallocUsed)
 HST_set(DELTA_WRITEBACK,         s_int,  Writeback)
 HST_set(DELTA_WRITEBACK_TMP,     s_int,  WritebackTmp)
@@ -487,7 +487,7 @@ static inline void cleanup_stack (
         if (this->item >= PROCPS_MEMINFO_logical_end)
             break;
         if (this->item > PROCPS_MEMINFO_noop)
-            this->result.ull_int = 0;
+            this->result.ul_int = 0;
         ++this;
     }
 } // end: cleanup_stack
index 20f6e0ab3847c69d5faa63c587b052fc89a7445a..c7d148270a4b73f0b40aea647293e21f78bdc075 100644 (file)
@@ -62,7 +62,7 @@ enum meminfo_item {
     PROCPS_MEMINFO_MEM_UNEVICTABLE,       //  ul_int
     PROCPS_MEMINFO_MEM_USED,              //  ul_int
     PROCPS_MEMINFO_MEM_VM_ALLOC_CHUNK,    //  ul_int
-    PROCPS_MEMINFO_MEM_VM_ALLOC_TOTAL,    // ull_int
+    PROCPS_MEMINFO_MEM_VM_ALLOC_TOTAL,    //  ul_int
     PROCPS_MEMINFO_MEM_VM_ALLOC_USED,     //  ul_int
     PROCPS_MEMINFO_MEM_WRITEBACK,         //  ul_int
     PROCPS_MEMINFO_MEM_WRITEBACK_TMP,     //  ul_int
@@ -102,7 +102,7 @@ enum meminfo_item {
     PROCPS_MEMINFO_DELTA_UNEVICTABLE,     //   s_int
     PROCPS_MEMINFO_DELTA_USED,            //   s_int
     PROCPS_MEMINFO_DELTA_VM_ALLOC_CHUNK,  //   s_int
-    PROCPS_MEMINFO_DELTA_VM_ALLOC_TOTAL,  //  sl_int
+    PROCPS_MEMINFO_DELTA_VM_ALLOC_TOTAL,  //   s_int
     PROCPS_MEMINFO_DELTA_VM_ALLOC_USED,   //   s_int
     PROCPS_MEMINFO_DELTA_WRITEBACK,       //   s_int
     PROCPS_MEMINFO_DELTA_WRITEBACK_TMP,   //   s_int
@@ -126,10 +126,8 @@ struct procps_meminfo;
 struct meminfo_result {
     enum meminfo_item item;
     union {
-        signed int            s_int;
-        signed long          sl_int;
-        unsigned long        ul_int;
-        unsigned long long  ull_int;
+        signed int      s_int;
+        unsigned long  ul_int;
     } result;
 };