[go: up one dir, main page]

Menu

[897c37]: / runtime / stats.h  Maximize  Restore  History

Download this file

43 lines (35 with data), 1.5 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
* Stats.h - interface to the stats package.
* Provides some macros -
* STAT_INIT(stat, flags, type, package, printname)
* STAT_INC(stat), STAT_DEC(stat)
* STAT_ADD(stat), STAT_SUB(stat)
*
* STAT_INIT should be called from your package's initialisation
* routine to register each stat with the stats package (it passes
* the #defined name and variable declaration). The "stat" parameter
* should have been created using the %token comment hack (generates
* a #define entry; should use an enum type, but have more control over
* non-recompilation if we use #defines).
* NB: STAT_ADD, etc, can all be used before STAT_INIT to alleviate
* some obvious startup programming difficulties.
*/
extern struct stats {
int value;
int flags; /* usage type */
char * type; /* memory, etc */
char * package; /* package generating those stats */
char * printfmt;/* and how to show it */
}
**stat_table;
#define STAT_TOTAL_TYPE 0x1 /* should this be added to totals for that type? */
#define STAT_TOTAL_PACK 0x2 /* in totals for the package? */
#define STAT_INIT(name, flags, usetype, package, printfmt) \
register_stat(name, flags, usetype, package, printfmt);
#define STAT_INC(x) stat_table[x].value++;
#define STAT_DEC(x) stat_table[x].value--;
#define STAT_ADD(x, v) stat_table[x].value += (v);
#define STAT_SUB(x, v) stat_table[x].value -= (v);
extern void register_stat _P((int, int, char *, char *, char *));
/* Grab the definitions of stat values, for people who forget */
#include "stats.Gen.h"