| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#ifndef __linux |
|
2
|
|
|
|
|
|
|
#error "No linux. Compile aborted." |
|
3
|
|
|
|
|
|
|
#endif |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
#include "EXTERN.h" |
|
6
|
|
|
|
|
|
|
#include "perl.h" |
|
7
|
|
|
|
|
|
|
#include "XSUB.h" |
|
8
|
|
|
|
|
|
|
#include "stdlib.h" |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
/* VERSION: 0.15 */ |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
MODULE = Linux::loadavg PACKAGE = Linux::loadavg |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
void |
|
15
|
|
|
|
|
|
|
loadavg(...) |
|
16
|
|
|
|
|
|
|
PROTOTYPE: ;$ |
|
17
|
|
|
|
|
|
|
PREINIT: |
|
18
|
|
|
|
|
|
|
double loadavg[3]; |
|
19
|
|
|
|
|
|
|
int rc, i; |
|
20
|
|
|
|
|
|
|
int nelem; |
|
21
|
|
|
|
|
|
|
PPCODE: |
|
22
|
1000004
|
100
|
|
|
|
|
if (items == 0) { |
|
23
|
1000001
|
|
|
|
|
|
nelem = 3; |
|
24
|
|
|
|
|
|
|
} else { |
|
25
|
3
|
|
|
|
|
|
nelem = atoi(SvPV_nolen(ST(0))); |
|
26
|
|
|
|
|
|
|
} |
|
27
|
1000004
|
50
|
|
|
|
|
if (nelem > 3 || nelem < 1) |
|
|
|
50
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
croak("invalid nelem (%d)", nelem); |
|
29
|
1000004
|
50
|
|
|
|
|
if ((rc = getloadavg(loadavg, nelem)) != nelem) |
|
30
|
0
|
|
|
|
|
|
croak("getloadavg failed (%d)", rc); |
|
31
|
1000004
|
50
|
|
|
|
|
EXTEND(SP,nelem); |
|
|
|
50
|
|
|
|
|
|
|
32
|
4000013
|
100
|
|
|
|
|
for(i=0; i
|
|
33
|
3000009
|
|
|
|
|
|
PUSHs(sv_2mortal(newSVnv(loadavg[i]))); |
|
34
|
|
|
|
|
|
|
} |