MemInfo.xs

filter: Statementstmt 100% 18 / 18 Branchbran 55.0% 11 / 20 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 76.3% 29 / 38 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
↑ Summary blib/lib/Sys/MemInfo.pm »
1 #include "EXTERN.h"
2 #include "perl.h"
3 #include "XSUB.h"
4  
5 MODULE = Sys::MemInfo PACKAGE = Sys::MemInfo
6  
7 #include "arch/functions.h"
8 #include <stdio.h>
9 #include <unistd.h>
10 #include <sys/sysinfo.h>
11  
12 void
13 availkeys()
14 PREINIT:
15 PPCODE:
16 2 ▶ XPUSHs(sv_2mortal(newSVpv(_totalmem, strlen(_totalmem))));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVpv(_totalmem, strlen(_totalmem)))); 0 2 2
17 2 ▶ XPUSHs(sv_2mortal(newSVpv(_freemem, strlen(_freemem))));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVpv(_freemem, strlen(_freemem)))); 0 2 2
18 2 ▶ XPUSHs(sv_2mortal(newSVpv(_totalswap, strlen(_totalswap))));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVpv(_totalswap, strlen(_totalswap)))); 0 2 2
19 2 ▶ XPUSHs(sv_2mortal(newSVpv(_freeswap, strlen(_freeswap))));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVpv(_freeswap, strlen(_freeswap)))); 0 2 2
20
21 double
22 totalmem()
23 PROTOTYPE: DISABLE
24 CODE:
25 2 const long long pagetotal = sysconf (_SC_PHYS_PAGES);
26 2 const long long pagesize = sysconf (_SC_PAGESIZE);
27 2 double ret = (pagetotal *pagesize);
28 2 ▶ RETVAL = ret;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = ret; 0 2 2
29 OUTPUT:
30 RETVAL
31  
32 double
33 freemem()
34 PROTOTYPE: DISABLE
35 CODE:
36 2 const long long pagesize = sysconf (_SC_PAGESIZE);
37 2 const long long pageavail = sysconf (_SC_AVPHYS_PAGES);
38 2 double ret= (pageavail * pagesize);
39 2 ▶ RETVAL = ret;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = ret; 1 1 2
40 OUTPUT:
41 RETVAL
42  
43 double
44 totalswap()
45 PROTOTYPE: DISABLE
46 CODE:
47 struct sysinfo info;
48 1 double ret= 0;
49 #ifdef OLDKERNEL
50 if (0==sysinfo(&info)) ret = info.totalswap;
51 #else
52 1 ▶ if (0==sysinfo(&info)) ret = info.mem_unit * info.totalswap;
Branch: 1 branch
BranchTrueFalseTotal
if (0==sysinfo(&info)) ret = info.mem_unit * info.totalswap; 1 0 1
53 #endif
54 1 ▶ RETVAL = ret;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = ret; 1 0 1
55 OUTPUT:
56 RETVAL
57  
58 double
59 freeswap()
60 PROTOTYPE: DISABLE
61 CODE:
62 struct sysinfo info;
63 1 double ret= 0;
64 #ifdef OLDKERNEL
65 if (0==sysinfo(&info)) ret = info.freeswap;
66 #else
67 1 ▶ if (0==sysinfo(&info)) ret = info.mem_unit * info.freeswap;
Branch: 1 branch
BranchTrueFalseTotal
if (0==sysinfo(&info)) ret = info.mem_unit * info.freeswap; 1 0 1
68 #endif
69 1 ▶ RETVAL = ret;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = ret; 1 0 1
70 OUTPUT:
71 RETVAL
72  
73 # vim:et:ts=2:sts=2:sw=2
↑ Summary blib/lib/Sys/MemInfo.pm »