summaryrefslogtreecommitdiffstats
path: root/kcontrol/info/memory_sgi.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit4aed2c8219774f5d797760606b8489a92ddc5163 (patch)
tree3f8c130f7d269626bf6a9447407ef6c35954426a /kcontrol/info/memory_sgi.cpp
downloadtdebase-4aed2c8219774f5d797760606b8489a92ddc5163.tar.gz
tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kcontrol/info/memory_sgi.cpp')
-rw-r--r--kcontrol/info/memory_sgi.cpp75
1 files changed, 75 insertions, 0 deletions
diff --git a/kcontrol/info/memory_sgi.cpp b/kcontrol/info/memory_sgi.cpp
new file mode 100644
index 000000000..2bc0d0c65
--- /dev/null
+++ b/kcontrol/info/memory_sgi.cpp
@@ -0,0 +1,75 @@
+
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/sysmp.h>
+#include <sys/ipc.h>
+
+// The following define is needed for SGI IRIX 6.2
+#define _KMEMUSER
+#include <sys/shm.h>
+
+#include <sys/param.h>
+#include <sys/swap.h>
+
+#ifndef UBSIZE
+#define UBSIZE 512
+#endif
+
+
+void KMemoryWidget::update()
+{
+ int pagesize = getpagesize();
+
+ struct rminfo rmi;
+ if( sysmp(MP_SAGET, MPSA_RMINFO, &rmi, sizeof(rmi)) == -1 )
+ return;
+ Memory_Info[TOTAL_MEM] = MEMORY(rmi.physmem) * pagesize; // total physical memory (without swaps)
+ Memory_Info[FREE_MEM] = MEMORY(rmi.freemem) * pagesize; // total free physical memory (without swaps)
+ Memory_Info[BUFFER_MEM] = MEMORY(rmi.bufmem) * pagesize;
+
+
+ //FIXME: Memory_Info[CACHED_MEM]"
+ Memory_Info[CACHED_MEM] = NO_MEMORY_INFO; // cached memory in ram
+
+ long val;
+ swapctl(SC_GETSWAPTOT, &val);
+ Memory_Info[SWAP_MEM] = MEMORY(val) * UBSIZE; // total size of all swap-partitions
+
+ swapctl(SC_GETFREESWAP, &val);
+ Memory_Info[FREESWAP_MEM] = MEMORY(val) * UBSIZE; // free memory in swap-partitions
+
+#ifndef MPKA_SHMINFO
+ /* Irix 6.5 (also 6.4?) */
+ Memory_Info[SHARED_MEM] = NO_MEMORY_INFO;
+#else
+ FILE *kmem = fopen("/dev/kmem", "r");
+ if( kmem == 0 ) {
+ Memory_Info[SHARED_MEM] = NO_MEMORY_INFO;
+ return;
+ }
+
+ long shmip = sysmp(MP_KERNADDR, MPKA_SHMINFO);
+ fseek( kmem, shmip, 0 );
+ struct shminfo shmi;
+ fread( &shmi, sizeof(shmi), 1, kmem );
+
+ long shmem = sysmp(MP_KERNADDR, MPKA_SHM);
+
+ val = 0;
+ long pos;
+ struct shmid_ds shmid;
+ for( int i=0 ; i<shmi.shmmni ; i++ ) {
+ fseek( kmem, shmem, 0 );
+ shmem += sizeof(shmem);
+ fread( &pos, sizeof(shmem), 1, kmem );
+ if(pos != 0) {
+ fseek( kmem, pos, 0 );
+ fread( &shmid, sizeof(shmid), 1, kmem );
+ val += shmid.shm_segsz;
+ }
+ }
+ Memory_Info[SHARED_MEM] = MEMORY(val);
+
+ fclose(kmem);
+#endif
+}