add more spacing
[personal-kdebase.git] / apps / kinfocenter / memory / memory_hpux.cpp
blob3b4e2be889000f2b8d0992f9717bc341d9c01027
1 /*
3 This file will be included by memory.cpp !
5 HP-UX is really ugly to retrieve information from !
6 Implemented on 24.04.1999 by Helge Deller (deller@gmx.de)
7 Tested on an HP9000/715/64 under HPUX-10.20.
8 Updated for QT 2.0 on 27.04.1999 (deller)
10 Sorry, but I don't know, who implemented the first (little) version of
11 update(), but it showed wrong sizes !
13 Many thanks goes also to Mike Romberg, who implemented such functions in
14 the program "xosview". Here's his copyright:
15 Copyright (c) 1994, 1995 by Mike Romberg ( romberg@fsl.noaa.gov )
19 #include <stdio.h>
20 #include <unistd.h>
21 #include <sys/param.h>
22 #include <sys/pstat.h>
25 #define MAX_SWAP_AREAS 16
27 void KCMMemory::fetchValues()
29 int page_size,i;
30 unsigned long total_mem, total_free,
31 total_physical, total_swap, free_physical,
32 used_physical, used_swap, free_swap;
34 struct pst_static pststatic;
35 struct pst_dynamic stats;
36 struct pst_vminfo vmstats;
37 unsigned long fields_[4];
38 struct pst_swapinfo swapinfo;
40 pstat_getstatic( &pststatic, sizeof( struct pst_static ), (size_t)1, 0);
41 total_physical = pststatic.physical_memory;
42 page_size = (int)pststatic.page_size;
44 pstat_getdynamic(&stats, sizeof( pst_dynamic ), (size_t)1, 0);
45 pstat_getvminfo(&vmstats, sizeof(vmstats), (size_t)1, 0);
47 fields_[0] = stats.psd_rmtxt + stats.psd_arm; // TEXT
48 fields_[1] = stats.psd_rm - stats.psd_rmtxt; // USED
49 fields_[2] = total_physical - fields_[0] - fields_[1] - stats.psd_free; //OTHER
50 fields_[3] = stats.psd_free; // FREE
52 used_physical = (total_physical - fields_[3]) * page_size;
53 total_physical *= page_size;
54 free_physical = (total_physical - used_physical);
57 /* Now check the SWAP-AREAS !! */
59 total_swap = free_swap = 0;
61 for (i = 0 ; i < MAX_SWAP_AREAS ; i++)
63 pstat_getswap(&swapinfo, sizeof(swapinfo), (size_t)1, i);
64 if (swapinfo.pss_idx == (unsigned)i)
66 swapinfo.pss_nfpgs *= 4; // nfpgs is in 512 Byte Blocks....
67 if (swapinfo.pss_nblksenabled == 0) // == 0 ??
68 swapinfo.pss_nblksenabled = swapinfo.pss_nfpgs;
69 total_swap += (((unsigned long)swapinfo.pss_nblksenabled) * 1024);
70 free_swap += (((unsigned long)swapinfo.pss_nfpgs ) * 1024);
74 used_swap = total_swap - free_swap;
77 /* Now display the results */
79 total_mem = total_physical; // + total_swap;
80 total_free = (total_physical - used_physical);// + free_swap;
82 memoryInfos[TOTAL_MEM] = MEMORY(total_mem); // total physical memory (without swaps)
83 memoryInfos[FREE_MEM] = MEMORY(total_free);// total free physical memory (without swaps)
84 memoryInfos[SHARED_MEM] = NO_MEMORY_INFO; /* FIXME ?? */
85 memoryInfos[BUFFER_MEM] = MEMORY(fields_[2])*page_size; /* FIXME ?? */
86 memoryInfos[SWAP_MEM] = MEMORY(total_swap); // total size of all swap-partitions
87 memoryInfos[FREESWAP_MEM] = MEMORY(free_swap); // free memory in swap-partitions
88 #ifdef __GNUC__
89 #warning "FIXME: memoryInfos[CACHED_MEM]"
90 #endif
91 memoryInfos[CACHED_MEM] = NO_MEMORY_INFO; // cached memory in ram