From fee5b1864199cdbe35a1e9ddc5bf8775d6c24daa Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Sat, 20 Nov 2004 02:08:16 +0000 Subject: [PATCH] removing mem.{buffer,cached} fields. replace with actual_{free,used} fields so we can portably adjust -/+ buffers/cache on linux and perhaps on other platforms w/ different semantics. --- bindings/dotnet/src/Sigar.cs | 4 ++-- examples/sigfreed.c | 4 ++-- include/sigar.h | 4 ++-- src/os/aix/aix_sigar.c | 4 ++-- src/os/darwin/darwin_sigar.c | 5 +++-- src/os/hpux/hpux_sigar.c | 5 ++++- src/os/linux/linux_sigar.c | 10 ++++++++-- src/os/osf1/osf1_sigar.c | 5 +++-- src/os/solaris/solaris_sigar.c | 7 ++++--- src/os/stub/stub_sigar.c | 5 ++--- src/os/win32/win32_sigar.c | 5 ++--- 11 files changed, 34 insertions(+), 24 deletions(-) diff --git a/bindings/dotnet/src/Sigar.cs b/bindings/dotnet/src/Sigar.cs index 8f852e21..8cf50eaf 100644 --- a/bindings/dotnet/src/Sigar.cs +++ b/bindings/dotnet/src/Sigar.cs @@ -143,8 +143,8 @@ namespace Hyperic.Sigar { public readonly ulong Used; public readonly ulong Free; public readonly ulong Shared; - private readonly ulong NA_buffer; - private readonly ulong NA_cached; + public readonly ulong ActualFree; + public readonly ulong ActualUsed; [DllImport(Sigar.LIBSIGAR)] private static extern int diff --git a/examples/sigfreed.c b/examples/sigfreed.c index 5c662f5f..9e66f627 100644 --- a/examples/sigfreed.c +++ b/examples/sigfreed.c @@ -33,8 +33,8 @@ int main(int argc, char *argv[]){ meminfo.buffer / 1024, meminfo.cached / 1024); fprintf(stdout, "-/+ buffers/cache: %10ld %10d\n", - (meminfo.used - meminfo.buffer - meminfo.cached) / 1024, - (meminfo.free + meminfo.buffer + meminfo.cached) / 1024); + meminfo.actual_used / 1024, + meminfo.actual_free / 1024); fprintf(stdout, "Swap: %10ld %10ld %10ld\n", swapinfo.total / 1024, swapinfo.used / 1024, diff --git a/include/sigar.h b/include/sigar.h index a63a5a6f..128e5ded 100644 --- a/include/sigar.h +++ b/include/sigar.h @@ -75,8 +75,8 @@ typedef struct { used, free, shared, - buffer, - cached; + actual_used, + actual_free; } sigar_mem_t; SIGAR_DECLARE(int) sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem); diff --git a/src/os/aix/aix_sigar.c b/src/os/aix/aix_sigar.c index 495386f3..d16e5e9d 100644 --- a/src/os/aix/aix_sigar.c +++ b/src/os/aix/aix_sigar.c @@ -354,10 +354,10 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem) mem->total = PAGESHIFT(vm.memsizepgs); /* lsattr -El sys0 -a realmem */ mem->free = PAGESHIFT(vm.numfrb); mem->used = mem->total - mem->free; + mem->actual_used = mem->used; + mem->actual_free = mem->free; mem->shared = -1; - mem->buffer = -1; - mem->cached = -1; sigar_mem_calc_ram(sigar, mem); diff --git a/src/os/darwin/darwin_sigar.c b/src/os/darwin/darwin_sigar.c index e0678e56..1fcaa5f0 100644 --- a/src/os/darwin/darwin_sigar.c +++ b/src/os/darwin/darwin_sigar.c @@ -124,8 +124,9 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem) mem->used = mem->total - mem->free; mem->shared = -1; /*XXX*/ - mem->buffer = -1; - mem->cached = -1; + + mem->actual_free = mem->free; + mem->actual_used = mem->used; return SIGAR_OK; } diff --git a/src/os/hpux/hpux_sigar.c b/src/os/hpux/hpux_sigar.c index a0a027a9..4ee5cd60 100644 --- a/src/os/hpux/hpux_sigar.c +++ b/src/os/hpux/hpux_sigar.c @@ -55,7 +55,10 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem) mem->used = mem->total - mem->free; /*XXX*/ - mem->shared = mem->buffer = mem->cached = 0; + mem->shared = 0; + + mem->actual_free = mem->free; + mem->actual_used = mem->used; return SIGAR_OK; } diff --git a/src/os/linux/linux_sigar.c b/src/os/linux/linux_sigar.c index 128dc6d7..2160232e 100644 --- a/src/os/linux/linux_sigar.c +++ b/src/os/linux/linux_sigar.c @@ -233,6 +233,7 @@ static SIGAR_INLINE sigar_uint64_t sigar_meminfo(char *buffer, int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem) { + sigar_uint64_t buffer, cached; char buffer[BUFSIZ]; int status = sigar_file2str(PROC_MEMINFO, @@ -244,9 +245,14 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem) mem->total = sigar_meminfo(buffer, MEMINFO_PARAM("MemTotal")); mem->free = sigar_meminfo(buffer, MEMINFO_PARAM("MemFree")); - mem->buffer = sigar_meminfo(buffer, MEMINFO_PARAM("Buffers")); - mem->cached = sigar_meminfo(buffer, MEMINFO_PARAM("Cached")); mem->used = mem->total - mem->free; + + buffer = sigar_meminfo(buffer, MEMINFO_PARAM("Buffers")); + cached = sigar_meminfo(buffer, MEMINFO_PARAM("Cached")); + + mem->actual_free = mem->free; + mem->actual_used = mem->used; + mem->shared = 0; /* XXX where did this go in 2.6?? */ if (get_ram(sigar, mem) != SIGAR_OK) { diff --git a/src/os/osf1/osf1_sigar.c b/src/os/osf1/osf1_sigar.c index 76a6474e..5073d67a 100644 --- a/src/os/osf1/osf1_sigar.c +++ b/src/os/osf1/osf1_sigar.c @@ -50,8 +50,9 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem) sigar_mem_calc_ram(sigar, mem); mem->shared = -1; - mem->buffer = -1; - mem->cached = -1; + + mem->actual_free = mem->free; + mem->actual_used = mem->used; return SIGAR_OK; } diff --git a/src/os/solaris/solaris_sigar.c b/src/os/solaris/solaris_sigar.c index 308fcff5..3d977386 100644 --- a/src/os/solaris/solaris_sigar.c +++ b/src/os/solaris/solaris_sigar.c @@ -180,11 +180,12 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem) mem->shared = KPAGE_SHIFT(kMEMPAGES(KSTAT_MEMPAGES_EXEC)); - mem->buffer = KPAGE_SHIFT(kMEMPAGES(KSTAT_MEMPAGES_VNODE)); - - mem->cached = -1; /*XXX*/ + /*mem->buffer = KPAGE_SHIFT(kMEMPAGES(KSTAT_MEMPAGES_VNODE));*/ } + mem->actual_free = mem->free; + mem->actual_used = mem->used; + return SIGAR_OK; } diff --git a/src/os/stub/stub_sigar.c b/src/os/stub/stub_sigar.c index 26d8504d..ffd787a0 100644 --- a/src/os/stub/stub_sigar.c +++ b/src/os/stub/stub_sigar.c @@ -28,9 +28,8 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem) mem->used = -1; mem->free = -1; mem->shared = -1; - mem->buffer = -1; - mem->cached = -1; - + mem->actual_free = mem->free; + mem->actual_used = mem->used; return SIGAR_OK; } diff --git a/src/os/win32/win32_sigar.c b/src/os/win32/win32_sigar.c index 4e60f516..ac19cf91 100644 --- a/src/os/win32/win32_sigar.c +++ b/src/os/win32/win32_sigar.c @@ -276,9 +276,8 @@ SIGAR_DECLARE(int) sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem) sigar_mem_calc_ram(sigar, mem); - /*XXX*/ - mem->buffer = 0; - mem->cached = 0; + mem->actual_free = mem->free; + mem->actual_used = mem->used; return SIGAR_OK; }