1
/*********************************************************
2
* Copyright (C) 1998 VMware, Inc. All rights reserved.
4
* This program is free software; you can redistribute it and/or modify it
5
* under the terms of the GNU Lesser General Public License as published
6
* by the Free Software Foundation version 2.1 and no later version.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10
* or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
11
* License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program; if not, write to the Free Software Foundation, Inc.,
15
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17
*********************************************************/
20
* stats_user_defs.h --
22
* Defines for user statcounters. This started life as a clone of
23
* stats_defs.h, which is too monitor entangled to easily work outside
24
* of vmx code (e.g. in lib).
27
#ifndef STATS_USER_DEFS_H
28
#define STATS_USER_DEFS_H
30
#define INCLUDE_ALLOW_MODULE
31
#define INCLUDE_ALLOW_USERLEVEL
32
#define INCLUDE_ALLOW_VMCORE
33
#include "includeCheck.h"
36
#error "stats_user_defs.h must be included with STATS_MODULE defined"
39
#define EXTERN_STAT_DECL(_name, _desc)
40
#define STAT_DECL(_name, _desc)
42
#define STATS_USER_MODULE_STR XSTR(XCONC(STATS_, STATS_MODULE))
43
#define STATS_USER_NAME(name) XCONC(STAT_, XCONC(STATS_MODULE, _##name))
44
#define STATS_USER_BLKVAR XCONC(_stats_, XCONC(STATS_MODULE, _Blk))
45
#define STATS_USER_LOG_FN(name)XCONC(name, _StatsLog)
46
#define STATS_USER_INST_NAME(name) \
47
XCONC(STATINST_, XCONC(STATS_MODULE, _##name))
48
#define STATS_USER_INIT_INST_FN(name) XCONC(name, _InitInstance)
49
#define STATS_USER_GETVAL_FN(name) XCONC(name, _StatsGetVal)
51
typedef struct StatsUserEntry {
55
typedef struct StatsUserBlock {
58
StatsUserEntry *counters;
59
struct StatsUserBlock *next;
62
EXTERN StatsUserBlock STATS_USER_BLKVAR;
64
#ifndef STATS_SKIP_ACCESSORS
65
#define STATS_IS_INITIALIZED() (STATS_USER_BLKVAR.counters != NULL)
66
#define STAT_GET(stat) \
67
(&(STATS_USER_BLKVAR.counters[STATS_USER_NAME(stat)]))
68
#define STAT_INST_GET(inst, stat) \
69
(&((inst)->counters[STATS_USER_INST_NAME(stat)]))
71
#define STAT_SAMPLE(stat) STAT_GET(stat)->count++
73
# define STAT_INC(stat) STAT_GET(stat)->count++
74
# define STAT_INC_BY(stat,inc) STAT_GET(stat)->count += (inc)
75
# define STAT_DEC_BY(stat,inc) STAT_GET(stat)->count -= (inc)
76
# define STAT_DEBUG_INC(stat) DEBUG_ONLY(STAT_INC(stat))
77
# define STAT_INST_INC(i,s) STAT_INST_GET((i), s)->count++
78
# define STAT_INST_INC_BY(i,s,inc) STAT_INST_GET((i), s)->count += (inc)
79
# define STAT_INST_DEC_BY(i,s,inc) STAT_INST_GET((i), s)->count -= (inc)
80
# define STAT_INST_DEBUG_INC(i,s) DEBUG_ONLY(STAT_INST_INC((i), s))
82
# define STAT_INC(stat)
83
# define STAT_INC_BY(stat,inc)
84
# define STAT_DEC_BY(stat,inc)
85
# define STAT_DEBUG_INC(stat)
86
# define STAT_INST_INC(inst,stat)
87
# define STAT_INST_INC_BY(inst,stat,inc)
88
# define STAT_INST_DEC_BY(inst,stat,inc)
89
# define STAT_INST_DEBUG_INC(stat)
91
#endif /* STATS_SKIP_ACCESSORS */
92
#endif /* STATS_DEFS_H */