SURFEX v8.1
General documentation of Surfex
Surfex_Git2
src
LIB
XRD44
utilities
getstackusage.c
Go to the documentation of this file.
1
typedef
long
long
int
ll_t
;
2
typedef
unsigned
long
long
int
ull_t
;
3
4
#ifdef VPP
5
ll_t
getstackusage_dummy_
() {
return
0L; }
6
#else
7
8
#if defined(LINUX) && defined(USE_MEMORY_MONITOR)
9
#include <stdio.h>
10
#include <stdlib.h>
11
12
ll_t
getstackusage_
()
13
{
14
ll_t
rc = 0;
15
static
int
dont_bother = 0;
16
if
(dont_bother) {
17
rc = -2;
18
}
19
else
{
20
FILE *statfile = fopen (
"/proc/self/stat"
,
"r"
);
21
if
(!statfile) {
22
dont_bother = 1;
23
rc = -1;
24
}
25
else
{
26
char
dm[80];
27
ull_t
startstack, kstkesp;
/* stack start & ESP, the 28th and 29th columns, respectively */
28
/* Maybe not the brightest coding, but has to suffice for now (SS) */
29
int
nelem = fscanf(statfile,
30
"%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %llu %llu "
,
31
dm,dm,dm,dm,dm,dm,dm,dm,dm,dm,dm,dm,dm,dm,dm,dm,dm,dm,dm,dm,dm,dm,dm,dm,dm,dm,dm,&startstack,&kstkesp);
32
if
(nelem != 29) {
33
dont_bother = 1;
34
rc = -3;
35
}
36
else
{
37
rc = (
ll_t
)(startstack - kstkesp);
38
}
39
fclose(statfile);
40
}
41
}
42
return
rc;
43
}
44
45
#else
46
47
ll_t
getstackusage_
() {
return
0L; }
48
49
#endif
50
#endif
ll_t
long long int ll_t
Definition:
privpub.h:293
getstackusage_dummy_
ll_t getstackusage_dummy_()
Definition:
getstackusage.c:5
getstackusage_
ll_t getstackusage_()
Definition:
getstackusage.c:12
ull_t
unsigned long long int ull_t
Definition:
getstackusage.c:2
ll_t
long long int ll_t
Definition:
getstackusage.c:1
Generated on Tue Jan 16 2018 16:23:22 for SURFEX v8.1 by
1.8.13